@@ -50,16 +50,17 module Redmine | |||||
50 | words_add += 1 |
|
50 | words_add += 1 | |
51 | else |
|
51 | else | |
52 | del_at = pos unless del_at |
|
52 | del_at = pos unless del_at | |
53 |
deleted << ' ' |
|
53 | deleted << ' ' unless deleted.empty? | |
|
54 | deleted << h(change[2]) | |||
54 | words_del += 1 |
|
55 | words_del += 1 | |
55 | end |
|
56 | end | |
56 | end |
|
57 | end | |
57 | if add_at |
|
58 | if add_at | |
58 | words[add_at] = '<span class="diff_in">' + words[add_at] |
|
59 | words[add_at] = '<span class="diff_in">'.html_safe + words[add_at] | |
59 | words[add_to] = words[add_to] + '</span>' |
|
60 | words[add_to] = words[add_to] + '</span>'.html_safe | |
60 | end |
|
61 | end | |
61 | if del_at |
|
62 | if del_at | |
62 | words.insert del_at - del_off + dels + words_add, '<span class="diff_out">' + deleted + '</span>' |
|
63 | words.insert del_at - del_off + dels + words_add, '<span class="diff_out">'.html_safe + deleted + '</span>'.html_safe | |
63 | dels += 1 |
|
64 | dels += 1 | |
64 | del_off += words_del |
|
65 | del_off += words_del | |
65 | words_del = 0 |
|
66 | words_del = 0 |
@@ -495,11 +495,19 class WikiControllerTest < ActionController::TestCase | |||||
495 | end |
|
495 | end | |
496 |
|
496 | |||
497 | def test_diff |
|
497 | def test_diff | |
498 | get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => 2, :version_from => 1 |
|
498 | content = WikiPage.find(1).content | |
|
499 | assert_difference 'WikiContent::Version.count', 2 do | |||
|
500 | content.text = "Line removed\nThis is a sample text for testing diffs" | |||
|
501 | content.save! | |||
|
502 | content.text = "This is a sample text for testing diffs\nLine added" | |||
|
503 | content.save! | |||
|
504 | end | |||
|
505 | ||||
|
506 | get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => content.version, :version_from => (content.version - 1) | |||
499 | assert_response :success |
|
507 | assert_response :success | |
500 | assert_template 'diff' |
|
508 | assert_template 'diff' | |
501 | assert_tag :tag => 'span', :attributes => { :class => 'diff_in'}, |
|
509 | assert_select 'span.diff_out', :text => 'Line removed' | |
502 | :content => /updated/ |
|
510 | assert_select 'span.diff_in', :text => 'Line added' | |
503 | end |
|
511 | end | |
504 |
|
512 | |||
505 | def test_annotate |
|
513 | def test_annotate |
General Comments 0
You need to be logged in to leave comments.
Login now