48 lines
1.6 KiB
Ruby
48 lines
1.6 KiB
Ruby
require 'test_helper'
|
|
|
|
# Test mails sent related to event moderation
|
|
class ModerationMailerTest < ActionMailer::TestCase
|
|
setup do
|
|
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
|
|
end
|
|
|
|
test 'create' do
|
|
mail = ModerationMailer.create Event.unscoped.last
|
|
assert_match(/\[Agenda du Libre\] Nouvel événement à modérer: .*/,
|
|
mail.subject)
|
|
assert_equal ['moderateurs@agendadulibre.org'], mail.to
|
|
assert_equal ['moderateurs@agendadulibre.org'], mail.from
|
|
end
|
|
|
|
test 'update' do
|
|
event = Event.last
|
|
older_event = Event.new event.attributes
|
|
|
|
event.tags += ', ho'
|
|
event.start_time += 1.day
|
|
event.description = event.description + '
|
|
hello world'
|
|
|
|
mail = ModerationMailer.update older_event, event, User.last
|
|
assert_match(/\[Agenda du Libre\] Édition de l'événement .*/, mail.subject)
|
|
assert_equal ['moderateurs@agendadulibre.org'], mail.to
|
|
assert_equal ['moderateurs@agendadulibre.org'], mail.from
|
|
assert_match(/^{/, mail.body.to_s)
|
|
end
|
|
|
|
test 'accept' do
|
|
mail = ModerationMailer.accept Event.unscoped.last, User.last
|
|
assert_match(/\[Agenda du Libre\] Événement .* modéré/, mail.subject)
|
|
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'
|
|
assert_match(/\[Agenda du Libre\] Événement .* refusé/, mail.subject)
|
|
assert_equal ['moderateurs@agendadulibre.org'], mail.to
|
|
assert_equal ['moderateurs@agendadulibre.org'], mail.from
|
|
end
|
|
end
|