Defect #29215 » fix-system-test-issues.diff
app/helpers/application_helper.rb | ||
---|---|---|
98 | 98 |
# * :download - Force download (default: false) |
99 | 99 |
def link_to_attachment(attachment, options={}) |
100 | 100 |
text = options.delete(:text) || attachment.filename |
101 |
route_method = options.delete(:download) ? :download_named_attachment_url : :named_attachment_url |
|
102 |
html_options = options.slice!(:only_path) |
|
101 |
if options.delete(:download) |
|
102 |
route_method = :download_named_attachment_url |
|
103 |
options[:filename] = attachment.filename |
|
104 |
else |
|
105 |
route_method = :attachment_url |
|
106 |
# make sure we don't have an extraneous :filename in the options |
|
107 |
options.delete(:filename) |
|
108 |
end |
|
109 |
html_options = options.slice!(:only_path, :filename) |
|
103 | 110 |
options[:only_path] = true unless options.key?(:only_path) |
104 |
url = send(route_method, attachment, attachment.filename, options)
|
|
111 |
url = send(route_method, attachment, options) |
|
105 | 112 |
link_to text, url, html_options |
106 | 113 |
end |
107 | 114 | |
... | ... | |
263 | 270 |
:srcset => "#{thumbnail_path(attachment, :size => thumbnail_size * 2)} 2x", |
264 | 271 |
:style => "max-width: #{thumbnail_size}px; max-height: #{thumbnail_size}px;" |
265 | 272 |
), |
266 |
named_attachment_path( |
|
267 |
attachment, |
|
268 |
attachment.filename |
|
273 |
attachment_path( |
|
274 |
attachment |
|
269 | 275 |
), |
270 | 276 |
:title => attachment.filename |
271 | 277 |
) |
test/functional/issues_controller_test.rb | ||
---|---|---|
2081 | 2081 |
end |
2082 | 2082 | |
2083 | 2083 |
assert_select 'div.thumbnails' do |
2084 |
assert_select 'a[href="/attachments/16/testfile.png"]' do
|
|
2084 |
assert_select 'a[href="/attachments/16"]' do |
|
2085 | 2085 |
assert_select 'img[src="/attachments/thumbnail/16"]' |
2086 | 2086 |
end |
2087 | 2087 |
end |
test/helpers/application_helper_test.rb | ||
---|---|---|
677 | 677 | |
678 | 678 |
def test_attachment_links |
679 | 679 |
text = 'attachment:error281.txt' |
680 |
result = link_to("error281.txt", "/attachments/1/error281.txt",
|
|
680 |
result = link_to("error281.txt", "/attachments/1", |
|
681 | 681 |
:class => "attachment") |
682 | 682 |
assert_equal "<p>#{result}</p>", |
683 | 683 |
textilizable(text, |
... | ... | |
689 | 689 |
set_tmp_attachments_directory |
690 | 690 |
a1 = Attachment.generate!(:filename => "test.txt", :created_on => 1.hour.ago) |
691 | 691 |
a2 = Attachment.generate!(:filename => "test.txt") |
692 |
result = link_to("test.txt", "/attachments/#{a2.id}/test.txt",
|
|
692 |
result = link_to("test.txt", "/attachments/#{a2.id}", |
|
693 | 693 |
:class => "attachment") |
694 | 694 |
assert_equal "<p>#{result}</p>", |
695 | 695 |
textilizable('attachment:test.txt', :attachments => [a1, a2]) |
... | ... | |
700 | 700 | |
701 | 701 |
with_settings :text_formatting => 'textile' do |
702 | 702 |
raw = "attachment:image@2x.png should not be parsed in image@2x.png" |
703 |
assert_match %r{<p><a class="attachment" href="/attachments/#{attachment.id}/image@2x.png">image@2x.png</a> should not be parsed in image@2x.png</p>},
|
|
703 |
assert_match %r{<p><a class="attachment" href="/attachments/#{attachment.id}">image@2x.png</a> should not be parsed in image@2x.png</p>}, |
|
704 | 704 |
textilizable(raw, :attachments => [attachment]) |
705 | 705 |
end |
706 | 706 | |
707 | 707 |
with_settings :text_formatting => 'markdown' do |
708 | 708 |
raw = "attachment:image@2x.png should not be parsed in image@2x.png" |
709 |
assert_match %r{<p><a class="attachment" href="/attachments/#{attachment.id}/image@2x.png">image@2x.png</a> should not be parsed in image@2x.png</p>} ,
|
|
709 |
assert_match %r{<p><a class="attachment" href="/attachments/#{attachment.id}">image@2x.png</a> should not be parsed in image@2x.png</p>} , |
|
710 | 710 |
textilizable(raw, :attachments => [attachment]) |
711 | 711 |
end |
712 | 712 |
end |
... | ... | |
1445 | 1445 | |
1446 | 1446 |
def test_link_to_attachment |
1447 | 1447 |
a = Attachment.find(3) |
1448 |
assert_equal '<a href="/attachments/3/logo.gif">logo.gif</a>',
|
|
1448 |
assert_equal '<a href="/attachments/3">logo.gif</a>', |
|
1449 | 1449 |
link_to_attachment(a) |
1450 |
assert_equal '<a href="/attachments/3/logo.gif">Text</a>',
|
|
1450 |
assert_equal '<a href="/attachments/3">Text</a>', |
|
1451 | 1451 |
link_to_attachment(a, :text => 'Text') |
1452 |
result = link_to("logo.gif", "/attachments/3/logo.gif", :class => "foo")
|
|
1452 |
result = link_to("logo.gif", "/attachments/3", :class => "foo") |
|
1453 | 1453 |
assert_equal result, |
1454 | 1454 |
link_to_attachment(a, :class => 'foo') |
1455 | 1455 |
assert_equal '<a href="/attachments/download/3/logo.gif">logo.gif</a>', |
1456 | 1456 |
link_to_attachment(a, :download => true) |
1457 |
assert_equal '<a href="http://test.host/attachments/3/logo.gif">logo.gif</a>',
|
|
1457 |
assert_equal '<a href="http://test.host/attachments/3">logo.gif</a>', |
|
1458 | 1458 |
link_to_attachment(a, :only_path => false) |
1459 | 1459 |
end |
1460 | 1460 | |
... | ... | |
1462 | 1462 |
a = Attachment.find(3) |
1463 | 1463 |
assert_select_in thumbnail_tag(a), |
1464 | 1464 |
'a[href=?][title=?] img[src=?]', |
1465 |
"/attachments/3/logo.gif", "logo.gif", "/attachments/thumbnail/3"
|
|
1465 |
"/attachments/3", "logo.gif", "/attachments/thumbnail/3" |
|
1466 | 1466 |
end |
1467 | 1467 | |
1468 | 1468 |
def test_link_to_project |
1469 |
- |
test/system/issues_test.rb | ||
---|---|---|
21 | 21 |
fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles, |
22 | 22 |
:trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues, |
23 | 23 |
:enumerations, :custom_fields, :custom_values, :custom_fields_trackers, |
24 |
:watchers, :journals, :journal_details |
|
24 |
:watchers, :journals, :journal_details, :versions
|
|
25 | 25 | |
26 | 26 |
def test_create_issue |
27 | 27 |
log_user('jsmith', 'jsmith') |