Fixed that wiki diff may produce html (#11209).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9895 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-06-26 16:57:09 +00:00
parent 7f6ac407ef
commit 6529035ee1
2 changed files with 16 additions and 7 deletions

View File

@ -50,16 +50,17 @@ module Redmine
words_add += 1 words_add += 1
else else
del_at = pos unless del_at del_at = pos unless del_at
deleted << ' ' + h(change[2]) deleted << ' ' unless deleted.empty?
deleted << h(change[2])
words_del += 1 words_del += 1
end end
end end
if add_at if add_at
words[add_at] = '<span class="diff_in">' + words[add_at] words[add_at] = '<span class="diff_in">'.html_safe + words[add_at]
words[add_to] = words[add_to] + '</span>' words[add_to] = words[add_to] + '</span>'.html_safe
end end
if del_at if del_at
words.insert del_at - del_off + dels + words_add, '<span class="diff_out">' + deleted + '</span>' words.insert del_at - del_off + dels + words_add, '<span class="diff_out">'.html_safe + deleted + '</span>'.html_safe
dels += 1 dels += 1
del_off += words_del del_off += words_del
words_del = 0 words_del = 0

View File

@ -495,11 +495,19 @@ class WikiControllerTest < ActionController::TestCase
end end
def test_diff def test_diff
get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => 2, :version_from => 1 content = WikiPage.find(1).content
assert_difference 'WikiContent::Version.count', 2 do
content.text = "Line removed\nThis is a sample text for testing diffs"
content.save!
content.text = "This is a sample text for testing diffs\nLine added"
content.save!
end
get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => content.version, :version_from => (content.version - 1)
assert_response :success assert_response :success
assert_template 'diff' assert_template 'diff'
assert_tag :tag => 'span', :attributes => { :class => 'diff_in'}, assert_select 'span.diff_out', :text => 'Line removed'
:content => /updated/ assert_select 'span.diff_in', :text => 'Line added'
end end
def test_annotate def test_annotate