]> source.dussan.org Git - redmine.git/commitdiff
add unit application helper test to use latest image file (#3261)
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 24 Nov 2011 03:34:57 +0000 (03:34 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 24 Nov 2011 03:34:57 +0000 (03:34 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7907 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/fixtures/attachments.yml
test/fixtures/files/101123161450_testfile_1.png [new file with mode: 0644]
test/fixtures/files/101223161450_testfile_2.png [new file with mode: 0644]
test/unit/helpers/application_helper_test.rb

index 438e21254e543a6f3badec10fa3398ab87f8894f..57bd23822e0e431ac563fd2cd492630bb1734b08 100644 (file)
@@ -182,3 +182,29 @@ attachments_015:
   author_id: 2
   content_type: text/x-diff
   description: attachement of a private issue
+attachments_016: 
+  content_type: image/png
+  downloads: 0
+  created_on: 2010-11-23 16:14:50 +09:00
+  disk_filename: 101123161450_testfile_1.png
+  container_id: 14
+  digest: 8e0294de2441577c529f170b6fb8f638
+  id: 16
+  container_type: Issue
+  description: ""
+  filename: testfile.png
+  filesize: 2654
+  author_id: 2
+attachments_017: 
+  content_type: image/png
+  downloads: 0
+  created_on: 2010-12-23 16:14:50 +09:00
+  disk_filename: 101223161450_testfile_2.png
+  container_id: 14
+  digest: 6bc2963e8d7ea0d3e68d12d1fba3d6ca
+  id: 17
+  container_type: Issue
+  description: ""
+  filename: testfile.PNG
+  filesize: 3582
+  author_id: 2
diff --git a/test/fixtures/files/101123161450_testfile_1.png b/test/fixtures/files/101123161450_testfile_1.png
new file mode 100644 (file)
index 0000000..6dad7f1
Binary files /dev/null and b/test/fixtures/files/101123161450_testfile_1.png differ
diff --git a/test/fixtures/files/101223161450_testfile_2.png b/test/fixtures/files/101223161450_testfile_2.png
new file mode 100644 (file)
index 0000000..aec3fcf
Binary files /dev/null and b/test/fixtures/files/101223161450_testfile_2.png differ
index 131959a256c12175142838eb0d828c4f988a9504..cc05fad3499b612159253c6c822ec9dde8c89d45 100644 (file)
@@ -29,6 +29,7 @@ class ApplicationHelperTest < ActionView::TestCase
 
   def setup
     super
+    set_tmp_attachments_directory
   end
 
   context "#link_to_if_authorized" do
@@ -182,6 +183,30 @@ RAW
     to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) }
   end
 
+  def test_attached_images_should_read_later
+    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
+
+    to_test = {
+      'Inline image: !testfile.png!' =>
+        'Inline image: <img src="/attachments/download/' + a2.id.to_s + '" alt="" />',
+      'Inline image: !Testfile.PNG!' =>
+        'Inline image: <img src="/attachments/download/' + a2.id.to_s + '" alt="" />',
+    }
+    attachments = [a1, a2]
+    to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) }
+  end
+
   def test_textile_external_links
     to_test = {
       'This is a "link":http://foo.bar' => 'This is a <a href="http://foo.bar" class="external">link</a>',