summaryrefslogtreecommitdiffstats
path: root/test/unit/attachment_test.rb
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2018-12-15 02:37:00 +0000
committerGo MAEDA <maeda@farend.jp>2018-12-15 02:37:00 +0000
commitbda0de004466f9679cffac234ca6a201399f35d2 (patch)
tree8b2f99cbf65591415462a067c900835bd915ab74 /test/unit/attachment_test.rb
parent35587f9d39fca04714eaf60dc9ab3c21d6e613a8 (diff)
downloadredmine-bda0de004466f9679cffac234ca6a201399f35d2.tar.gz
redmine-bda0de004466f9679cffac234ca6a201399f35d2.zip
Allows re-use of thumbnails for identical attachments (#30177).
Patch by Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@17735 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/attachment_test.rb')
-rw-r--r--test/unit/attachment_test.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb
index 05abc5c63..15936c39e 100644
--- a/test/unit/attachment_test.rb
+++ b/test/unit/attachment_test.rb
@@ -430,11 +430,33 @@ class AttachmentTest < ActiveSupport::TestCase
assert_difference "Dir.glob(File.join(Attachment.thumbnails_storage_path, '*.thumb')).size" do
thumbnail = attachment.thumbnail
- assert_equal "16_8e0294de2441577c529f170b6fb8f638_100.thumb", File.basename(thumbnail)
+ assert_equal "8e0294de2441577c529f170b6fb8f638_2654_100.thumb", File.basename(thumbnail)
assert File.exists?(thumbnail)
end
end
+ def test_should_reuse_thumbnail
+ a = Attachment.create!(
+ :container => Issue.find(1),
+ :file => uploaded_test_file("2010/11/101123161450_testfile_1.png", "image/png"),
+ :author => User.find(1)
+ )
+ a_thumb = b_thumb = nil
+ assert_difference "Dir.glob(File.join(Attachment.thumbnails_storage_path, '*.thumb')).size" do
+ a_thumb = a.thumbnail
+ end
+
+ b = Attachment.create!(
+ :container => Issue.find(2),
+ :file => uploaded_test_file("2010/11/101123161450_testfile_1.png", "image/png"),
+ :author => User.find(1)
+ )
+ assert_no_difference "Dir.glob(File.join(Attachment.thumbnails_storage_path, '*.thumb')).size" do
+ b_thumb = b.thumbnail
+ end
+ assert_equal a_thumb, b_thumb
+ end
+
def test_thumbnail_should_return_nil_if_generation_fails
Redmine::Thumbnail.expects(:generate).raises(SystemCallError, 'Something went wrong')
set_fixtures_attachments_directory