From bc059a7ca6b134f6582921cf2845e5d4738e3d85 Mon Sep 17 00:00:00 2001
From: Alex Shulgin <ash@commandprompt.com>
Date: Mon, 1 Aug 2011 23:59:15 +0300
Subject: [PATCH 06/25] Show URL to attached file in plain text issue email.

---
 app/helpers/application_helper.rb |    9 +++++----
 app/helpers/issues_helper.rb      |    6 +++++-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 0e12d51..9cf167f 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -100,10 +100,11 @@ module ApplicationHelper
     opt_only_path = {}
     opt_only_path[:only_path] = (options[:only_path] == false ? false : true)
     options.delete(:only_path)
-    link_to(h(text),
-           {:controller => 'attachments', :action => action,
-            :id => attachment, :filename => attachment.filename}.merge(opt_only_path),
-           options)
+    link_to(h(text), route_to_attachment(attachment, action).merge(opt_only_path), options)
+  end
+
+  def route_to_attachment(attachment, action = 'show')
+    { :controller => 'attachments', :action => action, :id => attachment, :filename => attachment.filename }
   end
 
   # Generates a link to a SCM revision
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index 422c9a7..60e433d 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -285,7 +285,11 @@ module IssuesHelper
           l(:text_journal_set_to, :label => label, :value => value).html_safe
         end
       when 'attachment'
-        l(:text_journal_added, :label => label, :value => value).html_safe
+        s = l(:text_journal_added, :label => label, :value => value)
+        if no_html && !value.blank? && a = Attachment.find_by_id(detail.prop_key)
+          s << ": " + url_for(route_to_attachment(a).merge(:only_path => false))
+        end
+        s.html_safe
       end
     else
       l(:text_journal_deleted, :label => label, :old => old_value).html_safe
-- 
1.7.0.4

