agenda-libre-ruby/test/mailers/moderation_mailer_test.rb

52 lines
1.6 KiB
Ruby
Raw Normal View History

2014-06-09 12:18:40 +02:00
require 'test_helper'
# 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
assert_match(/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
event = Event.last
# Added so paper trail can have some bit of history
event.save
event.tag_list.add 'ho'
event.start_time += 1.day
event.description = event.description + '
hello world'
mail = ModerationMailer.update event
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
mail = ModerationMailer.accept Event.unscoped.last
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
event = Event.unscoped.last
event.reason = 'hello world'
mail = ModerationMailer.destroy event
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