cirandas.net

ref: master

plugins/spaminator/test/unit/spaminator_plugin/mailer_test.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require 'test_helper'

class SpaminatorPlugin::MailerTest < ActiveSupport::TestCase
  CHARSET = "utf-8"

  def setup
    Noosfero::Plugin::MailerBase.delivery_method = :test
    Noosfero::Plugin::MailerBase.perform_deliveries = true
    Noosfero::Plugin::MailerBase.deliveries = []
    @environment = Environment.default
    @settings = Noosfero::Plugin::Settings.new(@environment, SpaminatorPlugin)
  end

  attr_accessor :environment, :settings

  should 'be able to send a inactive person notification message' do
    environment.noreply_email = 'no-reply@noosfero.org'
    environment.save

    person = create_user('spammer').person
    mail = SpaminatorPlugin::Mailer.inactive_person_notification(person).deliver

    assert_equal ['spammer@noosfero.org'], mail.to
    assert_equal ['no-reply@noosfero.org'], mail.from
    assert_match(/You must reactivate your account/, mail.subject)
  end
end