[#513] Fix links to attachments in the issue history
This commit is contained in:
parent
df0c75c050
commit
dd6d9d1c68
@ -68,6 +68,7 @@ class IssuesTest < ActionController::IntegrationTest
|
|||||||
:notes => 'Some notes',
|
:notes => 'Some notes',
|
||||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}
|
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}
|
||||||
assert_redirected_to "/issues/1"
|
assert_redirected_to "/issues/1"
|
||||||
|
follow_redirect!
|
||||||
|
|
||||||
# make sure attachment was saved
|
# make sure attachment was saved
|
||||||
attachment = Issue.find(1).attachments.find_by_filename("testfile.txt")
|
attachment = Issue.find(1).attachments.find_by_filename("testfile.txt")
|
||||||
@ -79,6 +80,12 @@ class IssuesTest < ActionController::IntegrationTest
|
|||||||
# verify that the attachment was written to disk
|
# verify that the attachment was written to disk
|
||||||
assert File.exist?(attachment.diskfile)
|
assert File.exist?(attachment.diskfile)
|
||||||
|
|
||||||
|
assert_select "#history" do
|
||||||
|
assert_select ".journal .details" do
|
||||||
|
assert_select "a", :text => /testfile.txt/
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# remove the attachments
|
# remove the attachments
|
||||||
Issue.find(1).attachments.each(&:destroy)
|
Issue.find(1).attachments.each(&:destroy)
|
||||||
assert_equal 0, Issue.find(1).attachments.length
|
assert_equal 0, Issue.find(1).attachments.length
|
||||||
|
@ -27,8 +27,18 @@ module JournalFormatter
|
|||||||
include CustomFieldsHelper
|
include CustomFieldsHelper
|
||||||
include ActionView::Helpers::TagHelper
|
include ActionView::Helpers::TagHelper
|
||||||
include ActionView::Helpers::UrlHelper
|
include ActionView::Helpers::UrlHelper
|
||||||
|
include ActionController::UrlWriter
|
||||||
extend Redmine::I18n
|
extend Redmine::I18n
|
||||||
|
|
||||||
|
def self.included(base)
|
||||||
|
base.class_eval do
|
||||||
|
# Required to use any link_to in the formatters
|
||||||
|
def self.default_url_options
|
||||||
|
{:only_path => true }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.register(hash)
|
def self.register(hash)
|
||||||
if hash[:class]
|
if hash[:class]
|
||||||
klazz = hash.delete(:class)
|
klazz = hash.delete(:class)
|
||||||
@ -90,9 +100,7 @@ module JournalFormatter
|
|||||||
|
|
||||||
def format_html_attachment_detail(key, value)
|
def format_html_attachment_detail(key, value)
|
||||||
if !value.blank? && a = Attachment.find_by_id(key.to_i)
|
if !value.blank? && a = Attachment.find_by_id(key.to_i)
|
||||||
# Link to the attachment if it has not been removed
|
link_to_attachment(a)
|
||||||
# FIXME: this is broken => link_to_attachment(a)
|
|
||||||
a.filename
|
|
||||||
else
|
else
|
||||||
content_tag("i", h(value)) if value.present?
|
content_tag("i", h(value)) if value.present?
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user