]> source.dussan.org Git - redmine.git/commitdiff
Fixed: Inline images don't work if file name has upper case letters or if image is...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 28 Oct 2008 10:43:34 +0000 (10:43 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 28 Oct 2008 10:43:34 +0000 (10:43 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@1958 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
test/unit/helpers/application_helper_test.rb

index aad2c5bec661c8cebaea8d7cf383b6a6e6abfcfa..556b9551fa3a96cd60605ffbd868856131087d0f 100644 (file)
@@ -247,7 +247,7 @@ module ApplicationHelper
     
     if attachments
       attachments = attachments.sort_by(&:created_on).reverse
-      text = text.gsub(/!((\<|\=|\>)?(\([^\)]+\))?(\[[^\]]+\])?(\{[^\}]+\})?)(\S+\.(gif|jpg|jpeg|png))!/) do |m|
+      text = text.gsub(/!((\<|\=|\>)?(\([^\)]+\))?(\[[^\]]+\])?(\{[^\}]+\})?)(\S+\.(bmp|gif|jpg|jpeg|png))!/i) do |m|
         style = $1
         filename = $6
         rf = Regexp.new(Regexp.escape(filename),  Regexp::IGNORECASE)
index 6e1356beededea9f17071712fdbb5b7265519f5e..cbf5a54bc17c1370402a47897835ca44090fd391 100644 (file)
@@ -24,7 +24,8 @@ class ApplicationHelperTest < HelperTestCase
                       :repositories, :changesets, 
                       :trackers, :issue_statuses, :issues, :versions, :documents,
                       :wikis, :wiki_pages, :wiki_contents,
-                      :boards, :messages
+                      :boards, :messages,
+                      :attachments
 
   def setup
     super
@@ -70,6 +71,15 @@ class ApplicationHelperTest < HelperTestCase
     to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
   end
   
+  def test_attached_images
+    to_test = {
+      'Inline image: !logo.gif!' => 'Inline image: <img src="/attachments/download/3" title="This is a logo" alt="This is a logo" />',
+      'Inline image: !logo.GIF!' => 'Inline image: <img src="/attachments/download/3" title="This is a logo" alt="This is a logo" />'
+    }
+    attachments = Attachment.find(:all)
+    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>',