2014-06-09 12:18:40 +02:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
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-07-18 19:30:59 +02:00
|
|
|
assert_match(/\[Agenda du Libre\] Nouvel événement à modérer: .*/, 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
|
|
|
|
olderEvent = Event.new event.attributes
|
|
|
|
|
|
|
|
event.tags += ', ho'
|
|
|
|
event.start_time += 1.day
|
|
|
|
event.description = event.description + '
|
|
|
|
hello world'
|
|
|
|
|
|
|
|
mail = ModerationMailer.update olderEvent, event, User.last
|
2014-07-18 19:30:59 +02:00
|
|
|
assert_match(/\[Agenda du Libre\] É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-07-18 19:30:59 +02:00
|
|
|
assert_match(/\[Agenda du Libre\] É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
|
|
|
|
mail = ModerationMailer.destroy Event.unscoped.last, User.last, 'hello world'
|
2014-07-18 19:30:59 +02:00
|
|
|
assert_match(/\[Agenda du Libre\] É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
|