From: Jean-Philippe Lang Date: Sun, 23 Jan 2011 17:02:10 +0000 (+0000) Subject: Moves link_to_message to ApplicationHelper to make it available to redmine links. X-Git-Tag: 1.2.0~1038 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a2a01e6b72d81ad9b2c50bccc8f9d4d13d1c5a8a;p=redmine.git Moves link_to_message to ApplicationHelper to make it available to redmine links. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4760 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8e973d186..c6d88487f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -109,6 +109,20 @@ module ApplicationHelper link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => rev}, :title => l(:label_revision_id, format_revision(revision))) end + + # Generates a link to a message + def link_to_message(message, options={}, html_options = nil) + link_to( + h(truncate(message.subject, :length => 60)), + { :controller => 'messages', :action => 'show', + :board_id => message.board_id, + :id => message.root, + :r => (message.parent_id && message.id), + :anchor => (message.parent_id ? "message-#{message.id}" : nil) + }.merge(options), + html_options + ) + end # Generates a link to a project if active # Examples: @@ -632,13 +646,7 @@ module ApplicationHelper end when 'message' if message = Message.visible.find_by_id(oid, :include => :parent) - link = link_to h(truncate(message.subject, :length => 60)), {:only_path => only_path, - :controller => 'messages', - :action => 'show', - :board_id => message.board, - :id => message.root, - :anchor => (message.parent ? "message-#{message.id}" : nil)}, - :class => 'message' + link = link_to_message(message, {:only_path => only_path}, :class => 'message') end when 'project' if p = Project.visible.find_by_id(oid) diff --git a/app/helpers/messages_helper.rb b/app/helpers/messages_helper.rb index ed58ad796..ce118b4f9 100644 --- a/app/helpers/messages_helper.rb +++ b/app/helpers/messages_helper.rb @@ -16,14 +16,4 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. module MessagesHelper - - def link_to_message(message) - return '' unless message - link_to h(truncate(message.subject, :length => 60)), :controller => 'messages', - :action => 'show', - :board_id => message.board_id, - :id => message.root, - :r => (message.parent_id && message.id), - :anchor => (message.parent_id ? "message-#{message.id}" : nil) - end end diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 9232b1b8d..69eaf7456 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -200,7 +200,7 @@ RAW 'export:/some/file' => link_to('export:/some/file', source_url.merge(:format => 'raw'), :class => 'source download'), # message 'message#4' => link_to('Post 2', message_url, :class => 'message'), - 'message#5' => link_to('RE: post 2', message_url.merge(:anchor => 'message-5'), :class => 'message'), + 'message#5' => link_to('RE: post 2', message_url.merge(:anchor => 'message-5', :r => 5), :class => 'message'), # project 'project#3' => link_to('eCookbook Subproject 1', project_url, :class => 'project'), 'project:subproject1' => link_to('eCookbook Subproject 1', project_url, :class => 'project'),