@@ -774,7 +774,7 module ApplicationHelper | |||
|
774 | 774 | end |
|
775 | 775 | when 'attachment' |
|
776 | 776 | attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil) |
|
777 |
if attachments && attachment = attachments |
|
|
777 | if attachments && attachment = Attachment.latest_attach(attachments, name) | |
|
778 | 778 | link = link_to_attachment(attachment, :only_path => only_path, :download => true, :class => 'attachment') |
|
779 | 779 | end |
|
780 | 780 | when 'project' |
@@ -129,4 +129,16 module ObjectHelpers | |||
|
129 | 129 | board.save! |
|
130 | 130 | board |
|
131 | 131 | end |
|
132 | ||
|
133 | def Attachment.generate!(attributes={}) | |
|
134 | @generated_filename ||= 'testfile0' | |
|
135 | @generated_filename.succ! | |
|
136 | attributes = attributes.dup | |
|
137 | attachment = Attachment.new(attributes) | |
|
138 | attachment.container ||= Issue.find(1) | |
|
139 | attachment.author ||= User.find(2) | |
|
140 | attachment.filename = @generated_filename if attachment.filename.blank? | |
|
141 | attachment.save! | |
|
142 | attachment | |
|
143 | end | |
|
132 | 144 | end |
@@ -555,6 +555,15 RAW | |||
|
555 | 555 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => Issue.find(3).attachments), "#{text} failed" } |
|
556 | 556 | end |
|
557 | 557 | |
|
558 | def test_attachment_link_should_link_to_latest_attachment | |
|
559 | set_tmp_attachments_directory | |
|
560 | a1 = Attachment.generate!(:filename => "test.txt", :created_on => 1.hour.ago) | |
|
561 | a2 = Attachment.generate!(:filename => "test.txt") | |
|
562 | ||
|
563 | assert_equal %(<p><a href="/attachments/download/#{a2.id}/test.txt" class="attachment">test.txt</a></p>), | |
|
564 | textilizable('attachment:test.txt', :attachments => [a1, a2]) | |
|
565 | end | |
|
566 | ||
|
558 | 567 | def test_wiki_links |
|
559 | 568 | to_test = { |
|
560 | 569 | '[[CookBook documentation]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation" class="wiki-page">CookBook documentation</a>', |
General Comments 0
You need to be logged in to leave comments.
Login now