From dab0c07fba561c2c1e712ec0bca640bc2a1e8c35 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 20 Feb 2010 10:07:53 +0000 Subject: [PATCH] Fixed: Links in Forum mails should redirect to message, not topic (#4884). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3458 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/mailer.rb | 2 +- test/unit/mailer_test.rb | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 00a390a02..1834a7f8e 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -161,7 +161,7 @@ class Mailer < ActionMailer::Base cc((message.root.watcher_recipients + message.board.watcher_recipients).uniq - @recipients) subject "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}" body :message => message, - :message_url => url_for(:controller => 'messages', :action => 'show', :board_id => message.board_id, :id => message.root) + :message_url => url_for(message.event_url) render_multipart('message_posted', body) end diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb index badd9cb21..83495a32d 100644 --- a/test/unit/mailer_test.rb +++ b/test/unit/mailer_test.rb @@ -22,6 +22,12 @@ class MailerTest < ActiveSupport::TestCase include ActionController::Assertions::SelectorAssertions fixtures :projects, :enabled_modules, :issues, :users, :members, :member_roles, :roles, :documents, :attachments, :news, :tokens, :journals, :journal_details, :changesets, :trackers, :issue_statuses, :enumerations, :messages, :boards, :repositories + def setup + ActionMailer::Base.deliveries.clear + Setting.host_name = 'mydomain.foo' + Setting.protocol = 'http' + end + def test_generated_links_in_emails ActionMailer::Base.deliveries.clear Setting.host_name = 'mydomain.foo' @@ -155,23 +161,29 @@ class MailerTest < ActiveSupport::TestCase end def test_message_posted_message_id - ActionMailer::Base.deliveries.clear message = Message.find(1) Mailer.deliver_message_posted(message) mail = ActionMailer::Base.deliveries.last assert_not_nil mail assert_equal Mailer.message_id_for(message), mail.message_id assert_nil mail.references + assert_select_email do + # link to the message + assert_select "a[href=?]", "http://mydomain.foo/boards/#{message.board.id}/topics/#{message.id}", :text => message.subject + end end def test_reply_posted_message_id - ActionMailer::Base.deliveries.clear message = Message.find(3) Mailer.deliver_message_posted(message) mail = ActionMailer::Base.deliveries.last assert_not_nil mail assert_equal Mailer.message_id_for(message), mail.message_id assert_equal Mailer.message_id_for(message.parent), mail.references.first.to_s + assert_select_email do + # link to the reply + assert_select "a[href=?]", "http://mydomain.foo/boards/#{message.board.id}/topics/#{message.root.id}?r=#{message.id}#message-#{message.id}", :text => message.subject + end end context("#issue_add") do