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:
- 9358 Bytes
1 | require File.expand_path(File.dirname(__FILE__) + '/../test_helper') |
2 | |
3 | class PageTest < ActiveSupport::TestCase |
4 | fixtures :webs, :pages, :revisions, :system |
5 | |
6 | def setup |
7 | @page = pages(:first_page) |
8 | end |
9 | |
10 | |
11 | def test_lock |
12 | assert !@page.locked?(Time.local(2004, 4, 4, 16, 50)) |
13 | |
14 | @page.lock(Time.local(2004, 4, 4, 16, 30), "DavidHeinemeierHansson") |
15 | |
16 | assert @page.locked?(Time.local(2004, 4, 4, 16, 50)) |
17 | assert !@page.locked?(Time.local(2004, 4, 4, 17, 1)) |
18 | |
19 | @page.unlock |
20 | |
21 | assert !@page.locked?(Time.local(2004, 4, 4, 16, 50)) |
22 | end |
23 | |
24 | def test_lock_duration |
25 | @page.lock(Time.local(2004, 4, 4, 16, 30), "DavidHeinemeierHansson") |
26 | |
27 | assert_equal 15, @page.lock_duration(Time.local(2004, 4, 4, 16, 45)) |
28 | end |
29 | |
30 | def test_plain_name |
31 | assert_equal "First Page", @page.plain_name |
32 | end |
33 | |
34 | def test_revise |
35 | @page.revise('HisWay would be MyWay in kinda lame', @page.name, Time.local(2004, 4, 4, 16, 52), |
36 | 'MarianneSyhler', x_test_renderer) |
37 | @page.reload |
38 | |
39 | assert_equal 2, @page.revisions.length, 'Should have two revisions' |
40 | assert_equal 'MarianneSyhler', @page.current_revision.author.to_s, |
41 | 'Mary should be the author now' |
42 | assert_equal 'DavidHeinemeierHansson', @page.revisions.first.author.to_s, |
43 | 'David was the first author' |
44 | end |
45 | |
46 | def test_revise_continous_revision |
47 | @page.revise('HisWay would be MyWay in kinda lame', @page.name, Time.local(2004, 4, 4, 16, 55), |
48 | 'MarianneSyhler', x_test_renderer) |
49 | @page.reload |
50 | assert_equal 2, @page.revisions.length |
51 | assert_equal 'HisWay would be MyWay in kinda lame', @page.content |
52 | |
53 | # consecutive revision by the same author within 30 minutes doesn't create a new revision |
54 | @page.revise('HisWay would be MyWay in kinda update', @page.name, Time.local(2004, 4, 4, 16, 57), |
55 | 'MarianneSyhler', x_test_renderer) |
56 | @page.reload |
57 | assert_equal 2, @page.revisions.length |
58 | assert_equal 'HisWay would be MyWay in kinda update', @page.content |
59 | assert_equal Time.local(2004, 4, 4, 16, 57), @page.revised_at |
60 | |
61 | # but consecutive revision by another author results in a new revision |
62 | @page.revise('HisWay would be MyWay in the house', @page.name, Time.local(2004, 4, 4, 16, 58), |
63 | 'DavidHeinemeierHansson', x_test_renderer) |
64 | @page.reload |
65 | assert_equal 3, @page.revisions.length |
66 | assert_equal 'HisWay would be MyWay in the house', @page.content |
67 | |
68 | # consecutive update after 30 minutes since the last one also creates a new revision, |
69 | # even when it is by the same author |
70 | @page.revise('HisWay would be MyWay in my way', @page.name, Time.local(2004, 4, 4, 17, 30), |
71 | 'DavidHeinemeierHansson', x_test_renderer) |
72 | @page.reload |
73 | assert_equal 4, @page.revisions.length |
74 | end |
75 | |
76 | def test_change_name |
77 | @page.revise('HisWay would be MyWay in my way', 'SecondPage', Time.local(2004, 4, 5, 17, 56), |
78 | 'MarianneSyhler', x_test_renderer) |
79 | @page.reload |
80 | |
81 | assert_equal "Second Page", @page.plain_name |
82 | assert_equal 2, @page.revisions.length, 'Should have two revisions' |
83 | assert_equal 'MarianneSyhler', @page.current_revision.author.to_s, |
84 | 'Marianne should be the author now' |
85 | assert_equal 'DavidHeinemeierHansson', @page.revisions.first.author.to_s, |
86 | 'David was the first author' |
87 | end |
88 | |
89 | def test_revise_content_unchanged |
90 | last_revision_before = @page.current_revision |
91 | revisions_number_before = @page.revisions.size |
92 | |
93 | assert_raises(Instiki::ValidationError) { |
94 | @page.revise(@page.current_revision.content, @page.name, Time.now, 'AlexeyVerkhovsky', x_test_renderer) |
95 | } |
96 | |
97 | assert_equal last_revision_before, @page.current_revision(true) |
98 | assert_equal revisions_number_before, @page.revisions.size |
99 | end |
100 | |
101 | def test_revise_changes_references_from_wanted_to_linked_for_new_pages |
102 | web = Web.find(1) |
103 | new_page = Page.new(:web => web, :name => 'NewPage') |
104 | new_page.revise('Reference to WantedPage, and to WantedPage2', 'NewPage', Time.now, 'AlexeyVerkhovsky', |
105 | x_test_renderer) |
106 | |
107 | references = new_page.wiki_references(true) |
108 | assert_equal 2, references.size |
109 | assert_equal 'WantedPage', references[0].referenced_name |
110 | assert_equal WikiReference::WANTED_PAGE, references[0].link_type |
111 | assert_equal 'WantedPage2', references[1].referenced_name |
112 | assert_equal WikiReference::WANTED_PAGE, references[1].link_type |
113 | |
114 | wanted_page = Page.new(:web => web, :name => 'WantedPage') |
115 | wanted_page.revise('And here it is!', 'WantedPage', Time.now, 'AlexeyVerkhovsky', x_test_renderer) |
116 | |
117 | # link type stored for NewPage -> WantedPage reference should change from WANTED to LINKED |
118 | # reference NewPage -> WantedPage2 should remain the same |
119 | references = new_page.wiki_references(true) |
120 | assert_equal 2, references.size |
121 | assert_equal 'WantedPage', references[0].referenced_name |
122 | assert_equal WikiReference::LINKED_PAGE, references[0].link_type |
123 | assert_equal 'WantedPage2', references[1].referenced_name |
124 | assert_equal WikiReference::WANTED_PAGE, references[1].link_type |
125 | end |
126 | |
127 | def test_revise_changes_references_from_wanted_to_linked_for_redirected_pages |
128 | web = Web.find(1) |
129 | new_page = Page.new(:web => web, :name => 'NewPage') |
130 | new_page.revise("Reference to H\xC3\xA1ppyPage, and to WantedPage2", 'NewPage', Time.local(2004, 4, 5, 17, 56), 'AlexeyVerkhovsky', |
131 | x_test_renderer) |
132 | |
133 | references = new_page.wiki_references(true) |
134 | assert_equal 2, references.size |
135 | p = ''.respond_to?(:force_encoding) ? "H\u00E1ppyPage" : "H\303\241ppyPage" |
136 | assert_equal p, references[0].referenced_name |
137 | assert_equal WikiReference::WANTED_PAGE, references[0].link_type |
138 | assert_equal 'WantedPage2', references[1].referenced_name |
139 | assert_equal WikiReference::WANTED_PAGE, references[1].link_type |
140 | wanted_pages = web.select.wanted_pages |
141 | assert_equal ["HisWay", p, "OverThere", "WantedPage2"], wanted_pages |
142 | |
143 | my_page = Page.new(:web => web, :name => 'MyPage') |
144 | my_page.revise("[[!redirects H\xC3\xA1ppyPage]]\nAnd here it is!", 'MyPage', Time.now, 'AlexeyVerkhovsky', x_test_renderer) |
145 | my_references = my_page.wiki_references(true) |
146 | assert_equal 1, my_references.size |
147 | assert_equal p, my_references[0].referenced_name |
148 | assert_equal WikiReference::REDIRECTED_PAGE, my_references[0].link_type |
149 | wanted_pages = web.select.wanted_pages |
150 | assert_equal ["HisWay", "OverThere", "WantedPage2"], wanted_pages |
151 | |
152 | # link type stored for NewPage -> HappyPage reference should change from WANTED to LINKED |
153 | # reference NewPage -> WantedPage2 should remain the same |
154 | references = new_page.wiki_references #(true) |
155 | s = ''.respond_to?(:force_encoding) ? "Reference to <a class='existingWikiWord' href='\.\./show/MyPage'>H\u00E1ppy Page</a>" : |
156 | "Reference to <a class='existingWikiWord' href='\.\./show/MyPage'>H\303\241ppy Page</a>" |
157 | assert_match( s, |
158 | x_test_renderer(new_page.revisions.last).display_content(true) ) |
159 | assert_equal 2, references.size |
160 | assert_equal p, references[0].referenced_name |
161 | # Doesn't work, since picking up the change in wiki_references requires a database query. |
162 | # assert_equal WikiReference::LINKED_PAGE, references[0].link_type |
163 | assert_equal 'WantedPage2', references[1].referenced_name |
164 | assert_equal WikiReference::WANTED_PAGE, references[1].link_type |
165 | wanted_pages = web.select.wanted_pages |
166 | assert_equal ["HisWay", "OverThere", "WantedPage2"], wanted_pages |
167 | |
168 | new_page.revise("Reference to H\xC3\xA1ppyPage and to WantedPage2.pdf and [[foo.pdf]]", 'NewPage', Time.now, 'AlexeyVerkhovsky', |
169 | x_test_renderer) |
170 | references = new_page.wiki_references(true) |
171 | s = ''.respond_to?(:force_encoding) ? "<p>Reference to <a class='existingWikiWord' href='\.\./show/MyPage'>H\u00E1ppy Page</a>" : |
172 | "<p>Reference to <a class='existingWikiWord' href='\.\./show/MyPage'>H\303\241ppy Page</a>" |
173 | assert_equal( s + |
174 | " and to <span class='newWikiWord'>Wanted Page2<a href='../show/WantedPage2'>?</a></span>.pdf " + |
175 | "and <span class='newWikiWord'>foo.pdf<a href='../show/foo.pdf'>?</a></span></p>", |
176 | x_test_renderer(new_page.revisions.last).display_content(true) ) |
177 | assert_equal 3, references.size |
178 | # now it works. |
179 | assert_equal p, references[0].referenced_name |
180 | assert_equal WikiReference::LINKED_PAGE, references[0].link_type |
181 | assert_equal 'WantedPage2', references[1].referenced_name |
182 | assert_equal WikiReference::WANTED_PAGE, references[1].link_type |
183 | assert_equal 'foo.pdf', references[2].referenced_name |
184 | assert_equal WikiReference::WANTED_PAGE, references[1].link_type |
185 | wanted_pages = web.select.wanted_pages |
186 | assert_equal ["HisWay", "OverThere", "WantedPage2"], wanted_pages |
187 | end |
188 | |
189 | def test_rollback |
190 | @page.revise("spot two", @page.name, Time.now, "David", x_test_renderer) |
191 | @page.revise("spot three", @page.name, Time.now + 2000, "David", x_test_renderer) |
192 | assert_equal 3, @page.revisions(true).length, "Should have three revisions" |
193 | @page.current_revision(true) |
194 | @page.rollback(0, Time.now, '127.0.0.1', x_test_renderer) |
195 | assert_equal "HisWay would be MyWay $\\sin(x)\\begin{svg}<svg/>\\end{svg}\\includegraphics[width=3em]{foo}$ in kinda ThatWay in HisWay though MyWay \\\\OverThere -- see SmartEngine in that SmartEngineGUI", @page.current_revision(true).content |
196 | end |
197 | end |