##// END OF EJS Templates
Adds Attachment#title....
Jean-Philippe Lang -
r9829:5c2de4dfc952
parent child
Show More
@@ -137,6 +137,14 class Attachment < ActiveRecord::Base
137 137 File.join(self.class.storage_path, disk_filename.to_s)
138 138 end
139 139
140 def title
141 title = filename.to_s
142 if description.present?
143 title << " (#{description})"
144 end
145 title
146 end
147
140 148 def increment_download
141 149 increment!(:downloads)
142 150 end
@@ -150,6 +150,14 class AttachmentTest < ActiveSupport::TestCase
150 150 assert_equal 'cbb5b0f30978ba03731d61f9f6d10011', Attachment.disk_filename("test_accentué.ça")[13..-1]
151 151 end
152 152
153 def test_title
154 a = Attachment.new(:filename => "test.png")
155 assert_equal "test.png", a.title
156
157 a = Attachment.new(:filename => "test.png", :description => "Cool image")
158 assert_equal "test.png (Cool image)", a.title
159 end
160
153 161 def test_prune_should_destroy_old_unattached_attachments
154 162 Attachment.create!(:file => uploaded_test_file("testfile.txt", ""), :author_id => 1, :created_on => 2.days.ago)
155 163 Attachment.create!(:file => uploaded_test_file("testfile.txt", ""), :author_id => 1, :created_on => 2.days.ago)
General Comments 0
You need to be logged in to leave comments. Login now