diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-11-24 05:31:29 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-11-24 05:31:29 +0000 |
commit | 564321b2d5b84a3b7d45b804c932790f8c6acac5 (patch) | |
tree | 606b818ba2d0f2017abd300b60304888a44611ce /test | |
parent | 627dfd80b6371a44bdfa6825aa1ed0078a0f1dde (diff) | |
download | redmine-564321b2d5b84a3b7d45b804c932790f8c6acac5.tar.gz redmine-564321b2d5b84a3b7d45b804c932790f8c6acac5.zip |
move logic to use latest image file attachment to class method for common use (#3261)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7908 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/attachment_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb index 85404a375..c290fe960 100644 --- a/test/unit/attachment_test.rb +++ b/test/unit/attachment_test.rb @@ -121,4 +121,24 @@ class AttachmentTest < ActiveSupport::TestCase end end end + + def test_latest_attach + Attachment.storage_path = "#{Rails.root}/test/fixtures/files" + a1 = Attachment.find(16) + assert_equal "testfile.png", a1.filename + assert a1.readable? + assert (! a1.visible?(User.anonymous)) + assert a1.visible?(User.find(2)) + a2 = Attachment.find(17) + assert_equal "testfile.PNG", a2.filename + assert a2.readable? + assert (! a2.visible?(User.anonymous)) + assert a2.visible?(User.find(2)) + assert a1.created_on < a2.created_on + + la1 = Attachment.latest_attach([a1, a2], "testfile.png") + assert_equal 17, la1.id + la2 = Attachment.latest_attach([a1, a2], "Testfile.PNG") + assert_equal 17, la2.id + end end |