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
|
2014-08-06 14:47:47 +02:00
|
|
|
older_event = Event.new event.attributes
|
2014-07-20 21:46:28 +02:00
|
|
|
|
2014-09-26 01:26:33 +02:00
|
|
|
event.tags += ' ho'
|
2014-07-20 21:46:28 +02:00
|
|
|
event.start_time += 1.day
|
|
|
|
event.description = event.description + '
|
|
|
|
hello world'
|
|
|
|
|
2014-08-06 14:47:47 +02:00
|
|
|
mail = ModerationMailer.update older_event, event, User.last
|
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-07-20 21:46:28 +02:00
|
|
|
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
|
|
|
|
mail = ModerationMailer.accept Event.unscoped.last, User.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
|
2014-08-06 14:47:47 +02:00
|
|
|
mail = ModerationMailer.destroy Event.unscoped.last, User.last,
|
|
|
|
'hello world'
|
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
|