]> source.dussan.org Git - redmine.git/commitdiff
Backported r11157 and r11158 from trunk (#12801).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 20 Jan 2013 16:59:42 +0000 (16:59 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 20 Jan 2013 16:59:42 +0000 (16:59 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.2-stable@11231 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
test/fixtures/wiki_content_versions.yml
test/functional/wiki_controller_test.rb

index 9e61070aad9c26a322cdea1426be1f32844e61b0..41fc2a44f4cd328b13d122f4fde583ee95e9f3c5 100644 (file)
@@ -597,8 +597,9 @@ module ApplicationHelper
 
   def parse_inline_attachments(text, project, obj, attr, only_path, options)
     # when using an image link, try to use an attachment, if possible
-    if options[:attachments] || (obj && obj.respond_to?(:attachments))
-      attachments = options[:attachments] || obj.attachments
+    attachments = options[:attachments] || []
+    attachments += obj.attachments if obj.respond_to?(:attachments)
+    if attachments.present?
       text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
         filename, ext, alt, alttext = $1.downcase, $2, $3, $4
         # search for the picture in attachments
index e7c0d4832a370a96e1fa44eb1ea1896696bb64bc..d3a614ac9cdf85472a7dadc4ba2cbc4d2563fab4 100644 (file)
@@ -99,4 +99,18 @@ wiki_content_versions_006:
   version: 3
   author_id: 1
   comments: 
+wiki_content_versions_007: 
+  data: |-
+    h1. Page with an inline image
+    
+    This is an inline image:
+    
+    !logo.gif!
+  updated_on: 2007-03-08 00:18:07 +01:00
+  page_id: 4
+  wiki_content_id: 4
+  id: 7
+  version: 1
+  author_id: 1
+  comments: 
   
index 3673c7622833df126efaaff5d23070e3d6eff0ad..916330fa0992169c227ec62e4fd0dd2de918fe98 100644 (file)
@@ -75,6 +75,19 @@ class WikiControllerTest < ActionController::TestCase
     assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation', :text => /Current version/
   end
 
+  def test_show_old_version_with_attachments
+    page = WikiPage.find(4)
+    assert page.attachments.any?
+    content = page.content
+    content.text = "update"
+    content.save!
+
+    get :show, :project_id => 'ecookbook', :id => page.title, :version => '1'
+    assert_kind_of WikiContent::Version, assigns(:content)
+    assert_response :success
+    assert_template 'show'
+  end
+
   def test_show_old_version_without_permission_should_be_denied
     Role.anonymous.remove_permission! :view_wiki_edits