From bb35cddaeb83efe90c9f9b024cc4f7c9d08814f7 Mon Sep 17 00:00:00 2001 From: echarp Date: Sun, 29 Jun 2014 13:37:08 +0200 Subject: [PATCH] =?UTF-8?q?Les=20mails=20peuvent=20maintenant=20g=C3=A9r?= =?UTF-8?q?=C3=A9s=20en=20converstation=20gr=C3=A2ce=20aux=20headers=20mes?= =?UTF-8?q?sage-id=20et=20in-reply-to?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/mailers/event_mailer.rb | 5 ++++- app/mailers/moderation_mailer.rb | 16 +++++++--------- app/mailers/note_mailer.rb | 4 +++- app/models/event.rb | 2 +- test/mailers/event_mailer_test.rb | 7 +++---- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/app/mailers/event_mailer.rb b/app/mailers/event_mailer.rb index 2ae26cb5..e46c0a79 100644 --- a/app/mailers/event_mailer.rb +++ b/app/mailers/event_mailer.rb @@ -3,6 +3,9 @@ class EventMailer < ActionMailer::Base def create(event) @event = event - mail to: event.contact, subject: t('event_mailer.create.subject', subject: event.title) + + mail 'Message-ID' => "", + to: event.contact, + subject: t('event_mailer.create.subject', subject: event.title) end end diff --git a/app/mailers/moderation_mailer.rb b/app/mailers/moderation_mailer.rb index 03fb968d..dc67add6 100644 --- a/app/mailers/moderation_mailer.rb +++ b/app/mailers/moderation_mailer.rb @@ -1,16 +1,12 @@ class ModerationMailer < ActionMailer::Base default from: 'moderateurs@agendadulibre.org' - TO = 'moderateurs@agendadulibre.org' + default to: 'moderateurs@agendadulibre.org' - # Subject can be set in your I18n file at config/locales/en.yml - # with the following lookup: - # - # en.moderation_mailer.create.subject - # def create(event) @event = event - mail to: TO, subject: t('moderation_mailer.create.subject', subject: event.title) + mail 'Message-ID' => "", + subject: t('moderation_mailer.create.subject', subject: event.title) end # Subject can be set in your I18n file at config/locales/en.yml @@ -22,7 +18,8 @@ class ModerationMailer < ActionMailer::Base @event = event @current_user = current_user - mail to: TO, subject: t('moderation_mailer.update.subject', subject: event.title) + mail 'In-Reply-To' => "", + subject: t('moderation_mailer.update.subject', subject: event.title) end # Subject can be set in your I18n file at config/locales/en.yml @@ -34,6 +31,7 @@ class ModerationMailer < ActionMailer::Base @event = event @current_user = current_user - mail to: TO, subject: t('moderation_mailer.moderate.subject', subject: event.title) + mail 'In-Reply-To' => "", + subject: t('moderation_mailer.moderate.subject', subject: event.title) end end diff --git a/app/mailers/note_mailer.rb b/app/mailers/note_mailer.rb index e0d6364c..1f6ad8dc 100644 --- a/app/mailers/note_mailer.rb +++ b/app/mailers/note_mailer.rb @@ -4,6 +4,8 @@ class NoteMailer < ActionMailer::Base def create(note) @note = note - mail to: note.event.contact, subject: t('note_mailer.create.subject', subject: note.event.title) + mail 'In-Reply-To' => "", + to: note.event.contact, + subject: t('note_mailer.create.subject', subject: note.event.title) end end diff --git a/app/models/event.rb b/app/models/event.rb index b7c3315b..885aef08 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -2,7 +2,7 @@ class Event < ActiveRecord::Base extend SimpleCalendar belongs_to :region, foreign_key: 'region' - has_many :notes + has_many :notes, dependent: :destroy has_one :related_city, foreign_key: :name, primary_key: :city, class_name: City validates_presence_of :title, :description, :city, :region, :url, :contact diff --git a/test/mailers/event_mailer_test.rb b/test/mailers/event_mailer_test.rb index 41cb15ce..58aefba3 100644 --- a/test/mailers/event_mailer_test.rb +++ b/test/mailers/event_mailer_test.rb @@ -5,12 +5,11 @@ class EventMailerTest < ActionMailer::TestCase ActionMailer::Base.default_url_options[:host] = 'localhost:3000' end - test "create" do - mail = EventMailer.create(Event.last) + test 'create' do + mail = EventMailer.create Event.last assert_match(/\[Agenda du Libre\] Votre évènement: .* est en attente de modération/, mail.subject) assert_equal [Event.last.contact], mail.to - assert_equal ["moderateurs@agendadulibre.org"], mail.from + assert_equal ['moderateurs@agendadulibre.org'], mail.from assert_match(/Bonjour.*/, mail.body.encoded) end - end