2015-07-25 18:32:27 +02:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
# Test and check how the organisations mailer is working
|
|
|
|
class OrgaMailerTest < ActionMailer::TestCase
|
|
|
|
setup do
|
|
|
|
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
|
|
|
|
|
|
|
|
@config = Rails.application.config
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'create' do
|
|
|
|
mail = OrgaMailer.create Orga.last
|
|
|
|
assert_match(/Organisation .* en attente de modération/,
|
|
|
|
mail.subject)
|
|
|
|
assert_equal [Orga.last.submitter], mail.to
|
|
|
|
assert_equal [@config.action_mailer.default_options[:from]],
|
|
|
|
mail.from
|
|
|
|
assert_match 'Bonjour', mail.body.encoded
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'update' do
|
2015-09-05 18:56:48 +02:00
|
|
|
@orga = Orga.last
|
|
|
|
# Necessary to have the proper paper_trail version
|
2018-03-17 15:49:43 +01:00
|
|
|
@orga.update name: 'My Title'
|
2015-09-05 18:56:48 +02:00
|
|
|
mail = OrgaMailer.update @orga
|
2015-07-25 18:32:27 +02:00
|
|
|
assert_match(/Organisation .* modifiée/, mail.subject)
|
|
|
|
assert_equal [Orga.last.submitter], mail.to
|
|
|
|
assert_equal [@config.action_mailer.default_options[:from]],
|
|
|
|
mail.from
|
|
|
|
assert_match 'Bonjour', mail.body.encoded
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'accept' do
|
|
|
|
mail = OrgaMailer.accept Orga.last
|
|
|
|
assert_match(/Organisation .* modérée/, mail.subject)
|
|
|
|
assert_equal [Orga.last.submitter], mail.to
|
|
|
|
assert_equal [@config.action_mailer.default_options[:from]],
|
|
|
|
mail.from
|
|
|
|
assert_match 'Bonjour', mail.body.encoded
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'destroy' do
|
|
|
|
mail = OrgaMailer.destroy Orga.last, 'hello world'
|
|
|
|
assert_match(/Organisation .* supprimée/, mail.subject)
|
|
|
|
assert_equal [Orga.last.submitter], mail.to
|
|
|
|
assert_equal [@config.action_mailer.default_options[:from]],
|
|
|
|
mail.from
|
|
|
|
assert_match 'Bonjour', mail.body.encoded
|
|
|
|
end
|
|
|
|
end
|