]> source.dussan.org Git - redmine.git/commitdiff
Moves link_to_message to ApplicationHelper to make it available to redmine links.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 23 Jan 2011 17:02:10 +0000 (17:02 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 23 Jan 2011 17:02:10 +0000 (17:02 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4760 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
app/helpers/messages_helper.rb
test/unit/helpers/application_helper_test.rb

index 8e973d186f55ef8aa6c5105f1799f628f2ceaf22..c6d88487fdf7512a146f77d92944414e08bd9f21 100644 (file)
@@ -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)
index ed58ad7968bf57b43950e970d465160ae082c45d..ce118b4f95aa7d1377626a41e3cd5fe798b14d92 100644 (file)
 # 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
index 9232b1b8d31992b5bb5bb7b3f2b8942de7dfc8cd..69eaf74561bc249da1abf9ee08a61093efdea153 100644 (file)
@@ -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'),