@@ -819,7 +819,7 module ApplicationHelper | |||||
819 | end |
|
819 | end | |
820 | when 'attachment' |
|
820 | when 'attachment' | |
821 | attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil) |
|
821 | attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil) | |
822 |
if attachments && attachment = attachments |
|
822 | if attachments && attachment = Attachment.latest_attach(attachments, name) | |
823 | link = link_to h(attachment.filename), {:only_path => only_path, :controller => 'attachments', :action => 'download', :id => attachment}, |
|
823 | link = link_to h(attachment.filename), {:only_path => only_path, :controller => 'attachments', :action => 'download', :id => attachment}, | |
824 | :class => 'attachment' |
|
824 | :class => 'attachment' | |
825 | end |
|
825 | end |
@@ -118,4 +118,16 module ObjectHelpers | |||||
118 | board.save! |
|
118 | board.save! | |
119 | board |
|
119 | board | |
120 | end |
|
120 | end | |
|
121 | ||||
|
122 | def Attachment.generate!(attributes={}) | |||
|
123 | @generated_filename ||= 'testfile0' | |||
|
124 | @generated_filename.succ! | |||
|
125 | attributes = attributes.dup | |||
|
126 | attachment = Attachment.new(attributes) | |||
|
127 | attachment.container ||= Issue.find(1) | |||
|
128 | attachment.author ||= User.find(2) | |||
|
129 | attachment.filename = @generated_filename if attachment.filename.blank? | |||
|
130 | attachment.save! | |||
|
131 | attachment | |||
|
132 | end | |||
121 | end |
|
133 | end |
@@ -551,6 +551,15 RAW | |||||
551 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => Issue.find(3).attachments), "#{text} failed" } |
|
551 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => Issue.find(3).attachments), "#{text} failed" } | |
552 | end |
|
552 | end | |
553 |
|
553 | |||
|
554 | def test_attachment_link_should_link_to_latest_attachment | |||
|
555 | set_tmp_attachments_directory | |||
|
556 | a1 = Attachment.generate!(:filename => "test.txt", :created_on => 1.hour.ago) | |||
|
557 | a2 = Attachment.generate!(:filename => "test.txt") | |||
|
558 | ||||
|
559 | assert_equal %(<p><a href="/attachments/download/#{a2.id}" class="attachment">test.txt</a></p>), | |||
|
560 | textilizable('attachment:test.txt', :attachments => [a1, a2]) | |||
|
561 | end | |||
|
562 | ||||
554 | def test_wiki_links |
|
563 | def test_wiki_links | |
555 | to_test = { |
|
564 | to_test = { | |
556 | '[[CookBook documentation]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation" class="wiki-page">CookBook documentation</a>', |
|
565 | '[[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