2014-06-09 12:18:40 +02:00
|
|
|
require 'test_helper'
|
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
# Test mails sent related to event moderation
|
2014-06-09 12:18:40 +02:00
|
|
|
class ModerationMailerTest < ActionMailer::TestCase
|
|
|
|
setup do
|
|
|
|
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
|
|
|
|
end
|
|
|
|
|
2014-07-01 15:50:39 +02:00
|
|
|
test 'create' do
|
|
|
|
mail = ModerationMailer.create Event.unscoped.last
|
2014-08-17 22:43:54 +02:00
|
|
|
assert_match(/Nouvel événement à modérer: .*/,
|
2014-08-06 14:47:47 +02:00
|
|
|
mail.subject)
|
2014-07-01 15:50:39 +02:00
|
|
|
assert_equal ['moderateurs@agendadulibre.org'], mail.to
|
|
|
|
assert_equal ['moderateurs@agendadulibre.org'], mail.from
|
2014-06-09 12:18:40 +02:00
|
|
|
end
|
|
|
|
|
2014-07-01 15:50:39 +02:00
|
|
|
test 'update' do
|
2014-07-20 21:46:28 +02:00
|
|
|
event = Event.last
|
2015-09-05 18:56:48 +02:00
|
|
|
|
|
|
|
# Added so paper trail can have some bit of history
|
|
|
|
event.save
|
2014-07-20 21:46:28 +02:00
|
|
|
|
2016-12-17 16:59:11 +01:00
|
|
|
event.tag_list.add 'ho'
|
2014-07-20 21:46:28 +02:00
|
|
|
event.start_time += 1.day
|
|
|
|
event.description = event.description + '
|
|
|
|
hello world'
|
|
|
|
|
2015-10-22 21:14:36 +02:00
|
|
|
mail = ModerationMailer.update event
|
2014-08-17 22:43:54 +02:00
|
|
|
assert_match(/Édition de l'événement .*/, mail.subject)
|
2014-07-01 15:50:39 +02:00
|
|
|
assert_equal ['moderateurs@agendadulibre.org'], mail.to
|
|
|
|
assert_equal ['moderateurs@agendadulibre.org'], mail.from
|
2014-10-03 01:14:45 +02:00
|
|
|
assert_match(/^-/, mail.body.to_s)
|
|
|
|
assert_match(/^+/, mail.body.to_s)
|
2014-06-09 12:18:40 +02:00
|
|
|
end
|
|
|
|
|
2014-07-01 15:50:39 +02:00
|
|
|
test 'accept' do
|
2015-10-22 21:14:36 +02:00
|
|
|
mail = ModerationMailer.accept Event.unscoped.last
|
2014-08-17 22:43:54 +02:00
|
|
|
assert_match(/Événement .* modéré/, mail.subject)
|
2014-07-01 15:50:39 +02:00
|
|
|
assert_equal ['moderateurs@agendadulibre.org'], mail.to
|
|
|
|
assert_equal ['moderateurs@agendadulibre.org'], mail.from
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'destroy' do
|
2015-10-22 21:14:36 +02:00
|
|
|
event = Event.unscoped.last
|
2016-05-21 12:02:19 +02:00
|
|
|
event.reason = 'hello world'
|
2015-10-22 21:14:36 +02:00
|
|
|
mail = ModerationMailer.destroy event
|
2014-08-17 22:43:54 +02:00
|
|
|
assert_match(/Événement .* refusé/, mail.subject)
|
2014-07-01 15:50:39 +02:00
|
|
|
assert_equal ['moderateurs@agendadulibre.org'], mail.to
|
|
|
|
assert_equal ['moderateurs@agendadulibre.org'], mail.from
|
2014-06-09 12:18:40 +02:00
|
|
|
end
|
|
|
|
end
|