Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 344
- Log:
Massive changeset which brings the old, ROOL customised Instiki
version up to date, but without any ROOL customisations in this
latest checked-in version (which is 0.19.1). This is deliberate,
so that it's easy to see the changes made for the ROOL version
in a subsequent changeset. The 'app/views/shared' directory is not
part of Instiki but is kept to maintain the change history with
updated ROOL customisations, some of which involve the same files
in that same directory.
- Author:
- rool
- Date:
- Sat Mar 19 19:52:13 +0000 2011
- Size:
- 3902 Bytes
- Properties:
- Property svn:executable is set
1 | #!/usr/bin/env ruby |
2 | |
3 | require File.expand_path(File.dirname(__FILE__) + '/../test_helper') |
4 | require 'xhtmldiff' |
5 | |
6 | class DiffTest < Test::Unit::TestCase |
7 | |
8 | def setup |
9 | |
10 | end |
11 | |
12 | def diff(a,b) |
13 | diff_doc = REXML::Document.new |
14 | div = REXML::Element.new('div', nil, {:respect_whitespace =>:all}) |
15 | div.attributes['class'] = 'xhtmldiff_wrapper' |
16 | diff_doc << div |
17 | hd = XHTMLDiff.new(div) |
18 | parsed_a = REXML::HashableElementDelegator.new( |
19 | REXML::XPath.first(REXML::Document.new("<div>"+a+"</div>"), '/div')) |
20 | parsed_b = REXML::HashableElementDelegator.new( |
21 | REXML::XPath.first(REXML::Document.new("<div>"+b+"</div>"), '/div')) |
22 | Diff::LCS.traverse_balanced(parsed_a, parsed_b, hd) |
23 | diffs = '' |
24 | diff_doc.write(diffs, -1, true, true) |
25 | diffs.gsub(/\A<div class='xhtmldiff_wrapper'>(.*)<\/div>\Z/m, '\1') |
26 | end |
27 | |
28 | def test_html_diff_simple |
29 | a = 'this was the original string' |
30 | b = 'this is the new string' |
31 | assert_equal("<span> this<del class='diffmod'> was</del><ins class='diffmod'> is</ins> the" + |
32 | "<del class='diffmod'> original</del><ins class='diffmod'> new</ins> string</span>", |
33 | diff(a, b)) |
34 | end |
35 | |
36 | def test_html_diff_with_multiple_paragraphs |
37 | a = "<p>this was the original string</p>" |
38 | b = "<p>this is</p>\n<p> the new string</p>\n<p>around the world</p>" |
39 | assert_equal( |
40 | "<p><span> this<del class='diffmod'> was</del><ins class='diffmod'> is</ins>" + |
41 | "<del class='diffdel'> the</del><del class='diffdel'> original</del><del class='diffdel'> string</del></span></p>" + |
42 | "<ins class='diffins'>\n</ins><ins class='diffins'><p> the new string</p></ins>" + |
43 | "<ins class='diffins'>\n</ins><ins class='diffins'><p>around the world</p></ins>", |
44 | diff(a, b)) |
45 | end |
46 | |
47 | def test_html_diff_deleting_a_paragraph |
48 | a = "<p>this is a paragraph</p>\n<p>this is a second paragraph</p>\n<p>this is a third paragraph</p>" |
49 | b = "<p>this is a paragraph</p>\n<p>this is a third paragraph</p>" |
50 | assert_equal( |
51 | "<p>this is a paragraph</p>\n<del class='diffdel'><p>this is a second paragraph</p></del>" + |
52 | "<del class='diffdel'>\n</del><p>this is a third paragraph</p>", |
53 | diff(a, b)) |
54 | end |
55 | |
56 | def test_split_paragraph_into_two |
57 | a = "<p>foo bar</p>" |
58 | b = "<p>foo</p><p>bar</p>" |
59 | assert_equal( |
60 | "<p><span> foo<del class='diffdel'> bar</del></span></p>" + |
61 | "<ins class='diffins'><p>bar</p></ins>", |
62 | diff(a,b)) |
63 | end |
64 | |
65 | def test_join_two_paragraphs_into_one |
66 | a = "<p>foo</p><p>bar</p>" |
67 | b = "<p>foo bar</p>" |
68 | assert_equal( |
69 | "<p><span> foo<ins class='diffins'> bar</ins></span></p>" + |
70 | "<del class='diffdel'><p>bar</p></del>", |
71 | diff(a,b)) |
72 | end |
73 | |
74 | def test_add_inline_element |
75 | a = "<p>foo bar</p>" |
76 | b = "<p>foo <b>bar</b></p>" |
77 | assert_equal( |
78 | "<p><span> foo<del class='diffdel'> bar</del></span>" + |
79 | "<ins class='diffins'><b>bar</b></ins></p>", |
80 | diff(a,b)) |
81 | end |
82 | |
83 | def test_html_diff_with_tags |
84 | a = "" |
85 | b = "<div>foo</div>" |
86 | assert_equal "<ins class='diffins'><div>foo</div></ins>", diff(a, b) |
87 | end |
88 | |
89 | def test_diff_for_tag_change |
90 | a = "<a>x</a>" |
91 | b = "<b>x</b>" |
92 | assert_equal "<del class='diffmod'><a>x</a></del><ins class='diffmod'><b>x</b></ins>", diff(a, b) |
93 | end |
94 | |
95 | def test_diff_for_tag_change_II |
96 | a = "<ul>\n<li>x</li>\n<li>y</li>\n</ul>" |
97 | b = "<ol>\n<li>x</li>\n<li>y</li>\n</ol>" |
98 | assert_equal "<del class='diffmod'><ul>\n<li>x</li>\n<li>y</li>\n</ul>" + |
99 | "</del><ins class='diffmod'><ol>\n<li>x</li>\n<li>y</li>\n</ol></ins>", diff(a, b) |
100 | end |
101 | |
102 | # FIXME this test fails (ticket #67, http://dev.instiki.org/ticket/67) |
103 | def test_html_diff_preserves_endlines_in_pre |
104 | a = "<pre>a\nb\nc\n</pre>" |
105 | b = "<pre>a\n</pre>" |
106 | assert_equal( |
107 | "<pre><span> a\n<del class='diffdel'>b\nc\n</del></span></pre>", |
108 | diff(a, b)) |
109 | end |
110 | |
111 | end |