2014-05-25 23:59:03 +02:00
|
|
|
require 'test_helper'
|
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
# Test mails related to event life cycle
|
2014-05-25 23:59:03 +02:00
|
|
|
class EventMailerTest < ActionMailer::TestCase
|
|
|
|
setup do
|
|
|
|
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
|
|
|
|
end
|
|
|
|
|
2014-06-29 13:37:08 +02:00
|
|
|
test 'create' do
|
|
|
|
mail = EventMailer.create Event.last
|
2014-08-06 14:47:47 +02:00
|
|
|
assert_match(/Votre événement: .* est en attente de modération/,
|
|
|
|
mail.subject)
|
2014-06-23 23:39:42 +02:00
|
|
|
assert_equal [Event.last.contact], mail.to
|
2014-06-29 13:37:08 +02:00
|
|
|
assert_equal ['moderateurs@agendadulibre.org'], mail.from
|
2014-05-25 23:59:03 +02:00
|
|
|
assert_match(/Bonjour.*/, mail.body.encoded)
|
|
|
|
end
|
2014-07-01 21:55:38 +02:00
|
|
|
|
2014-07-01 22:17:57 +02:00
|
|
|
test 'accept' do
|
2015-10-22 21:14:36 +02:00
|
|
|
mail = EventMailer.accept Event.last
|
2014-08-06 14:47:47 +02:00
|
|
|
assert_match(/Événement .* modéré/, mail.subject)
|
2014-07-07 13:14:17 +02:00
|
|
|
assert_equal [Event.last.contact], mail.to
|
|
|
|
assert_equal ['moderateurs@agendadulibre.org'], mail.from
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'destroy' do
|
2015-10-22 21:14:36 +02:00
|
|
|
event = Event.last
|
2016-05-21 12:02:19 +02:00
|
|
|
event.reason = 'hello world'
|
2015-10-22 21:14:36 +02:00
|
|
|
mail = EventMailer.destroy Event.last
|
2014-08-06 14:47:47 +02:00
|
|
|
assert_match(/Événement .* refusé/, mail.subject)
|
2014-07-01 22:17:57 +02:00
|
|
|
assert_equal [Event.last.contact], mail.to
|
2014-07-01 21:55:38 +02:00
|
|
|
assert_equal ['moderateurs@agendadulibre.org'], mail.from
|
|
|
|
end
|
2014-05-25 23:59:03 +02:00
|
|
|
end
|