motiro 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/README +1 -1
  2. data/app/controllers/wiki_controller.rb +14 -1
  3. data/app/core/version.rb +1 -1
  4. data/app/core/wiki_reporter.rb +4 -17
  5. data/app/helpers/application_helper.rb +33 -0
  6. data/app/helpers/report_helper.rb +39 -0
  7. data/app/helpers/report_helper.rb.rej +46 -0
  8. data/app/helpers/wiki_helper.rb +1 -1
  9. data/app/models/change.rb +12 -41
  10. data/app/models/chunk.rb +56 -0
  11. data/app/models/page.rb +17 -0
  12. data/app/models/revision.rb +31 -0
  13. data/app/reporters/events_reporter.rb +0 -2
  14. data/app/views/report/show.rhtml +2 -2
  15. data/app/views/wiki/diff.rhtml +4 -0
  16. data/app/views/wiki/history.rhtml +32 -21
  17. data/app/views/wiki/history.rhtml.rej +63 -0
  18. data/config/motiro.yml +1 -1
  19. data/config/routes.rb +3 -0
  20. data/db/motirodb.sqlite.initial +0 -0
  21. data/db/translation/pt-BR.rb +6 -1
  22. data/db/translation/pt-BR.rb.rej +26 -0
  23. data/lib/diff_chunk_builder.rb +98 -0
  24. data/lib/tasks/packaging.rake +2 -1
  25. data/public/stylesheets/motiro.css +49 -18
  26. data/public/stylesheets/motiro.css.rej +37 -0
  27. data/public/wiki/history/OtherPage-en-us.xml +40 -0
  28. data/test/fixtures/pages.yml +1 -1
  29. data/test/fixtures/revisions.yml +15 -4
  30. data/test/functional/report_features_test.rb +7 -1
  31. data/test/functional/root_controller_test.rb +1 -1
  32. data/test/functional/wiki_controller_test.rb +44 -4
  33. data/test/unit/change_test.rb +29 -56
  34. data/test/unit/diff_chunk_builder_test.rb +269 -0
  35. data/test/unit/page_test.rb +46 -0
  36. data/test/unit/revision_test.rb +160 -0
  37. data/test/unit/wiki_reporter_test.rb +2 -1
  38. metadata +301 -283
  39. data/app/models/diff_table_builder.rb +0 -285
  40. data/test/unit/diff_table_builder_test.rb +0 -602
@@ -0,0 +1,269 @@
1
+ # Motiro - A project tracking tool
2
+ # Copyright (C) 2006-2007 Thiago Arrais
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+
18
+ require File.dirname(__FILE__) + '/../test_helper'
19
+ require 'diff_chunk_builder'
20
+
21
+ class DiffChunkBuilderTest < Test::Unit::TestCase
22
+
23
+ def setup
24
+ @builder = DiffChunkBuilder.new
25
+ end
26
+
27
+ def test_addition_only
28
+ @builder.push_addition 'I have added this'
29
+
30
+ chunks = @builder.get_chunks
31
+
32
+ assert_equal 1, chunks.size
33
+ assert !chunks.first.unchanged?
34
+ assert_equal :addition, chunks.first.action
35
+ assert_equal 1, chunks.first.lines.size
36
+ line = chunks.first.lines.first
37
+ assert_nil line.original_position
38
+ assert_nil line.original_text
39
+ assert_equal 1, line.modified_position
40
+ assert_equal 'I have added this', line.modified_text
41
+ end
42
+
43
+ def test_deletion_only
44
+ @builder.push_deletion 'I have removed this'
45
+
46
+ chunks = @builder.get_chunks
47
+
48
+ assert_equal 1, chunks.size
49
+ assert !chunks.first.unchanged?
50
+ assert_equal :deletion, chunks.first.action
51
+ assert_equal 1, chunks.first.lines.size
52
+ line = chunks.first.lines.first
53
+ assert_equal 1, line.original_position
54
+ assert_equal 'I have removed this', line.original_text
55
+ assert_nil line.modified_position
56
+ assert_nil line.modified_text
57
+ end
58
+
59
+ def test_matches_alterning_addition_and_deletion
60
+ @builder.push_deletion 'I have removed this'
61
+ @builder.push_addition 'I have added this'
62
+
63
+ chunks = @builder.get_chunks
64
+
65
+ assert_equal 1, chunks.size
66
+ assert !chunks.first.unchanged?
67
+ assert_equal :modification, chunks.first.action
68
+ assert_equal 1, chunks.first.lines.size
69
+ line = chunks.first.lines.first
70
+ assert_equal 1, line.original_position
71
+ assert_equal 1, line.original_position
72
+ assert_equal 'I have removed this', line.original_text
73
+ assert_equal 1, line.modified_position
74
+ assert_equal 'I have added this', line.modified_text
75
+ end
76
+
77
+ def test_multiline_modification
78
+ @builder.push_deletion 'This is the first old line'
79
+ @builder.push_deletion 'This is the second old line'
80
+ @builder.push_addition 'This is the first new line'
81
+ @builder.push_addition 'This is the second new line'
82
+
83
+ chunks = @builder.get_chunks
84
+
85
+ assert_equal 1, chunks.size
86
+ assert_equal :modification, chunks.first.action
87
+ lines = chunks.first.lines
88
+ assert_equal 2, lines.size
89
+ assert_equal 1, lines.first.original_position
90
+ assert_equal 'This is the first old line', lines.first.original_text
91
+ assert_equal 2, lines.last.original_position
92
+ assert_equal 'This is the second old line', lines.last.original_text
93
+ assert_equal 1, lines.first.modified_position
94
+ assert_equal 'This is the first new line', lines.first.modified_text
95
+ assert_equal 2, lines.last.modified_position
96
+ assert_equal 'This is the second new line', lines.last.modified_text
97
+ end
98
+
99
+ def test_more_adds_than_deletes
100
+ @builder.push_deletion 'This is the first old line'
101
+ @builder.push_addition 'This is the first new line'
102
+ @builder.push_addition 'This is the second new line'
103
+ @builder.push_unchanged 'This line remains the same'
104
+
105
+ chunks = @builder.get_chunks
106
+
107
+ assert_equal 2, chunks.size
108
+ assert_equal :modification, chunks.first.action
109
+ assert_equal :unchanged, chunks.last.action
110
+ assert chunks.last.unchanged?
111
+ lines = chunks.first.lines
112
+ assert_equal 2, lines.size
113
+ assert_equal 1, lines.first.original_position
114
+ assert_equal 'This is the first old line', lines.first.original_text
115
+ assert_nil lines.last.original_position
116
+ assert_nil lines.last.original_text
117
+ assert_equal 1, lines.first.modified_position
118
+ assert_equal 'This is the first new line', lines.first.modified_text
119
+ assert_equal 2, lines.last.modified_position
120
+ assert_equal 'This is the second new line', lines.last.modified_text
121
+ assert_equal 2, chunks.last.lines.first.original_position
122
+ assert_equal 'This line remains the same', chunks.last.lines.first.original_text
123
+ assert_equal 3, chunks.last.lines.first.modified_position
124
+ assert_equal 'This line remains the same', chunks.last.lines.first.modified_text
125
+ end
126
+
127
+ def test_less_adds_than_deletes
128
+ @builder.push_deletion 'This is the first old line'
129
+ @builder.push_deletion 'This is the second old line'
130
+ @builder.push_addition 'This is the first new line'
131
+ @builder.push_unchanged 'This line remains the same'
132
+
133
+ chunks = @builder.get_chunks
134
+
135
+ assert_equal 2, chunks.size
136
+ assert_equal :modification, chunks.first.action
137
+ assert_equal :unchanged, chunks.last.action
138
+ assert chunks.last.unchanged?
139
+ lines = chunks.first.lines
140
+ assert_equal 2, lines.size
141
+ assert_equal 1, lines.first.original_position
142
+ assert_equal 'This is the first old line', lines.first.original_text
143
+ assert_equal 2, lines.last.original_position
144
+ assert_equal 'This is the second old line', lines.last.original_text
145
+ assert_equal 1, lines.first.modified_position
146
+ assert_equal 'This is the first new line', lines.first.modified_text
147
+ assert_nil lines.last.modified_position
148
+ assert_nil lines.last.modified_text
149
+ assert_equal 3, chunks.last.lines.first.original_position
150
+ assert_equal 'This line remains the same', chunks.last.lines.first.original_text
151
+ assert_equal 2, chunks.last.lines.first.modified_position
152
+ assert_equal 'This line remains the same', chunks.last.lines.first.modified_text
153
+ end
154
+
155
+ def test_some_code_kept_some_modified
156
+ @builder.start_line 6
157
+
158
+ @builder.push_unchanged 'div.channel-title {'
159
+ @builder.push_deletion ' font: normal 8pt Verdana,sans-serif;'
160
+ @builder.push_addition ' font: bold 10pt Verdana,sans-serif;'
161
+ @builder.push_unchanged ' margin:0 0 0 0;'
162
+
163
+ chunks = @builder.get_chunks
164
+
165
+ assert_equal 3, chunks.size
166
+ assert chunks[0].unchanged?
167
+ assert_equal :modification, chunks[1].action
168
+ assert chunks[2].unchanged?
169
+ chunks.each { |c| assert_equal 1, c.lines.size }
170
+ assert_equal 6, chunks[0].lines.first.original_position
171
+ assert_equal 'div.channel-title {', chunks[0].lines.first.original_text
172
+ assert_equal 7, chunks[1].lines.first.original_position
173
+ assert_equal ' font: normal 8pt Verdana,sans-serif;', chunks[1].lines.first.original_text
174
+ assert_equal 8, chunks[2].lines.first.original_position
175
+ assert_equal ' margin:0 0 0 0;', chunks[2].lines.first.original_text
176
+ assert_equal 6, chunks[0].lines.first.modified_position
177
+ assert_equal 'div.channel-title {', chunks[0].lines.first.modified_text
178
+ assert_equal 7, chunks[1].lines.first.modified_position
179
+ assert_equal ' font: bold 10pt Verdana,sans-serif;', chunks[1].lines.first.modified_text
180
+ assert_equal 8, chunks[2].lines.first.modified_position
181
+ assert_equal ' margin:0 0 0 0;', chunks[2].lines.first.modified_text
182
+ end
183
+
184
+ def test_esparse_changes
185
+ @builder.start_line 6
186
+
187
+ @builder.push_unchanged 'div.channel-title {'
188
+ @builder.push_deletion ' margin:0;'
189
+ @builder.push_deletion ' font: normal 8pt Verdana,sans-serif;'
190
+ @builder.push_addition ' font: bold 10pt Verdana,sans-serif;'
191
+
192
+ @builder.start_line 13
193
+
194
+ @builder.push_addition ' padding: 0 8px 0 8px;'
195
+ @builder.push_unchanged '}'
196
+
197
+ chunks = @builder.get_chunks
198
+
199
+ assert_equal 5, chunks.size
200
+ assert chunks[0].unchanged?
201
+ assert_equal :modification, chunks[1].action
202
+ assert chunks[2].separator?
203
+ assert_equal :addition, chunks[3].action
204
+ assert chunks[4].unchanged?
205
+ assert_equal 1, chunks[0].lines.size
206
+ assert_equal 2, chunks[1].lines.size
207
+ assert_equal 4, chunks[2].num_lines
208
+ assert_equal 1, chunks[3].lines.size
209
+ assert_equal 6, chunks[0].lines.first.original_position
210
+ assert_equal 7, chunks[1].lines.first.original_position
211
+ assert_equal 8, chunks[1].lines.last.original_position
212
+ assert_nil chunks[3].lines.first.original_position
213
+ assert_equal 13, chunks[4].lines.first.original_position
214
+ assert_equal 'div.channel-title {', chunks[0].lines.first.original_text
215
+ assert_equal ' margin:0;', chunks[1].lines.first.original_text
216
+ assert_equal ' font: normal 8pt Verdana,sans-serif;', chunks[1].lines.last.original_text
217
+ assert_nil chunks[3].lines.first.original_text
218
+ assert_equal '}', chunks[4].lines.first.original_text
219
+
220
+ assert_equal 6, chunks[0].lines.first.modified_position
221
+ assert_equal 7, chunks[1].lines.first.modified_position
222
+ assert_nil chunks[1].lines.last.modified_position
223
+ assert_equal 13, chunks[3].lines.first.modified_position
224
+ assert_equal 14, chunks[4].lines.first.modified_position
225
+ assert_equal 'div.channel-title {', chunks[0].lines.first.modified_text
226
+ assert_equal ' font: bold 10pt Verdana,sans-serif;', chunks[1].lines.first.modified_text
227
+ assert_nil chunks[1].lines.last.modified_text
228
+ assert_equal ' padding: 0 8px 0 8px;', chunks[3].lines.first.modified_text
229
+ assert_equal '}', chunks[4].lines.first.modified_text
230
+ end
231
+
232
+ def test_unmatching_line_numbers
233
+ @builder.start_line(6, 6)
234
+
235
+ @builder.push_unchanged 'div.channel-title {'
236
+ @builder.push_deletion ' font: normal 8pt Verdana,sans-serif;'
237
+ @builder.push_addition ' font: bold 10pt Verdana,sans-serif;'
238
+ @builder.push_addition ' margin:0 0 0 0;'
239
+
240
+ @builder.start_line(13, 14)
241
+
242
+ @builder.push_unchanged 'div.channel-body-outer {'
243
+ @builder.push_deletion ' padding: 0 9px 0 9px;'
244
+ @builder.push_addition ' padding: 0 8px 0 8px;'
245
+ @builder.push_unchanged '}'
246
+
247
+ chunks = @builder.get_chunks
248
+
249
+ assert_equal 6, chunks.size
250
+ assert_equal 6, chunks[0].lines.first.original_position
251
+ assert_equal 7, chunks[1].lines.first.original_position
252
+ assert_nil chunks[1].lines.last.original_position
253
+ assert_equal 13, chunks[3].lines.first.original_position
254
+ assert_equal 14, chunks[4].lines.first.original_position
255
+ assert_equal 15, chunks[5].lines.first.original_position
256
+
257
+ assert_equal 6, chunks[0].lines.first.modified_position
258
+ assert_equal 7, chunks[1].lines.first.modified_position
259
+ assert_equal 8, chunks[1].lines.last.modified_position
260
+ assert_equal 14, chunks[3].lines.first.modified_position
261
+ assert_equal 15, chunks[4].lines.first.modified_position
262
+ assert_equal 16, chunks[5].lines.first.modified_position
263
+ end
264
+
265
+ #TODO unch unch del
266
+ #TODO unch add add unch
267
+ #TODO escape html and blank line in view/helper code
268
+
269
+ end
@@ -277,6 +277,52 @@ class PageTest < Test::Unit::TestCase
277
277
  assert_equal 2, page.revisions[1].position
278
278
  end
279
279
 
280
+ def test_converts_to_headline
281
+ page = revise_brand_new_page(:title => 'My page',
282
+ :kind => 'common',
283
+ :text => "This is my page and it is written \n" +
284
+ "in English, German and \n" +
285
+ "Portuguese\n\n" +
286
+ "--- de ------\n\n" +
287
+ "Dieses ist meine Seite und es ist \n" +
288
+ "auf Englisch, Deutsch und Portugiese \n " +
289
+ "geschrieben\n\n" +
290
+ "--- pt-br ------\n\n" +
291
+ "Esta é minha página e está escrita \n" +
292
+ "em inglês, alemão e português")
293
+ headline = page.to_headline
294
+ assert_equal page.last_editor.login, headline.author
295
+ assert_equal page.modified_at, headline.happened_at
296
+ assert_equal "My page\n\n" +
297
+ "This is my page and it is written \n" +
298
+ "in English, German and \n" +
299
+ "Portuguese\n\n" +
300
+ "--- de ---\n\n" +
301
+ "My page\n\n" +
302
+ "Dieses ist meine Seite und es ist \n" +
303
+ "auf Englisch, Deutsch und Portugiese \n " +
304
+ "geschrieben\n\n" +
305
+ "--- pt-br ---\n\n" +
306
+ "My page\n\n" +
307
+ "Esta é minha página e está escrita \n" +
308
+ "em inglês, alemão e português", headline[:description]
309
+ end
310
+
311
+ def test_event_page_uses_planned_date_as_headline_date
312
+ event_date = Date.new(2007, 7, 1)
313
+ event = revise_brand_new_page(:title => 'My event',
314
+ :kind => 'event',
315
+ :happens_at => event_date,
316
+ :text => "Let's get together and feel alright")
317
+ assert_equal event_date.to_t, event.to_headline.happened_at
318
+ end
319
+
320
+ def test_pages_without_editor_or_modification_time_are_reported_as_modified_by_someone_at_some_time
321
+ headline = Page.new(:name => 'VeryOldPage', :kind => 'common').to_headline
322
+ assert_equal DEFAULT_AUTHOR, headline.author
323
+ assert_equal DEFAULT_TIME, headline.happened_at
324
+ end
325
+
280
326
  private
281
327
 
282
328
  def create_page_with_one_revision
@@ -34,5 +34,165 @@ class RevisionTest < Test::Unit::TestCase
34
34
 
35
35
  assert_equal rev.page.revisions, rev.revisions
36
36
  end
37
+
38
+ def test_diffs_one_line_modification
39
+ fst_rev = pages('changed_page').revisions[0]
40
+ snd_rev = pages('changed_page').revisions[1]
41
+
42
+ change_chunks = fst_rev.diff(2)
43
+ assert_equal 1, change_chunks.size
44
+ chunk = change_chunks.first
45
+ assert !chunk.unchanged?
46
+ assert_equal :modification, chunk.action
47
+ assert_equal 1, chunk.lines.size
48
+ line = chunk.lines.first
49
+ assert_equal 1, line.original_position
50
+ assert_equal fst_rev.text, line.original_text
51
+ assert_equal 1, line.modified_position
52
+ assert_equal snd_rev.text, line.modified_text
53
+ end
54
+
55
+ def test_diffs_all_two_lines_modified
56
+ page = revise_brand_new_page(:title => 'A good page',
57
+ :text => "This is the first line\n" +
58
+ "And this is the second one")
59
+ page.revise(bob, now, :title => 'A good page',
60
+ :text => "This is the modified first line\n" +
61
+ "And this is the modified second line")
62
+
63
+ chunks = page.revisions[0].diff(2)
64
+ assert_equal 1, chunks.size
65
+ chunk = chunks.first
66
+ assert_equal :modification, chunk.action
67
+ assert_equal 2, chunk.lines.size
68
+ assert_equal 'This is the first line', chunk.lines.first.original_text
69
+ assert_equal 'This is the modified first line', chunk.lines.first.modified_text
70
+ assert_equal 2, chunk.lines.last.original_position
71
+ assert_equal 'And this is the second one', chunk.lines.last.original_text
72
+ assert_equal 2, chunk.lines.last.modified_position
73
+ assert_equal 'And this is the modified second line', chunk.lines.last.modified_text
74
+ end
75
+
76
+ def test_diffs_with_one_line_unchanged_in_the_middle
77
+ page = revise_brand_new_page(:title => 'A good page',
78
+ :text => "This is the first line\n" +
79
+ "This line will not be changed\n" +
80
+ "And this is the third one")
81
+ page.revise(bob, now, :title => 'A good page',
82
+ :text => "This is the modified first line\n" +
83
+ "This line will not be changed\n" +
84
+ "And this is another modification")
85
+
86
+ chunks = page.revisions[0].diff(2)
87
+ assert_equal 3, chunks.size
88
+ assert !chunks[0].unchanged?
89
+ assert_equal :modification, chunks[0].action
90
+ assert chunks[1].unchanged?
91
+ assert_equal :unchanged, chunks[1].action
92
+ assert !chunks[2].unchanged?
93
+ assert_equal :modification, chunks[2].action
94
+ assert_equal 1, chunks[0].lines.size
95
+ assert_equal 1, chunks[1].lines.size
96
+ assert_equal 1, chunks[2].lines.size
97
+ assert_equal 'This is the first line', chunks[0].lines.first.original_text
98
+ assert_equal 'This is the modified first line', chunks[0].lines.first.modified_text
99
+ assert_equal 'This line will not be changed', chunks[1].lines.first.original_text
100
+ assert_equal 'And this is the third one', chunks[2].lines.first.original_text
101
+ assert_equal 'And this is another modification', chunks[2].lines.first.modified_text
102
+ end
103
+
104
+ def test_diffs_right_unbalanced_modification
105
+ page = revise_brand_new_page(:title => 'A good page',
106
+ :text => "This is the first line\n" +
107
+ "This line will not be changed\n" +
108
+ "And this is the last one")
109
+ page.revise(bob, now, :title => 'A good page',
110
+ :text => "This is the modified first line,\n" +
111
+ "But I also inserted a new one\n" +
112
+ "This line will not be changed\n" +
113
+ "And this is the last one")
114
+ chunks = page.revisions[0].diff(2)
115
+ assert_equal 2, chunks.size
116
+ assert !chunks.first.unchanged?
117
+ assert chunks.last.unchanged?
118
+ assert_equal 2, chunks.first.lines.size
119
+ assert_equal 'This is the first line', chunks.first.lines.first.original_text
120
+ assert_equal 'This is the modified first line,', chunks.first.lines.first.modified_text
121
+ assert_nil chunks.first.lines.last.original_position
122
+ assert_nil chunks.first.lines.last.original_text
123
+ assert_equal 2, chunks.first.lines.last.modified_position
124
+ assert_equal 'But I also inserted a new one', chunks.first.lines.last.modified_text
125
+ assert_equal 2, chunks.last.lines.first.original_position
126
+ assert_equal 3, chunks.last.lines.first.modified_position
127
+ assert_equal 'This line will not be changed', chunks.last.lines.first.original_text
128
+ end
129
+
130
+ def test_diffs_left_unbalanced_modification
131
+ page = revise_brand_new_page(:title => 'A good page',
132
+ :text => "This is the first line\n" +
133
+ "This line will be removed\n" +
134
+ "And this one won't be changed")
135
+ page.revise(bob, now, :title => 'A good page',
136
+ :text => "This is the modified first line\n" +
137
+ "And this one won't be changed")
138
+ chunks = page.revisions[0].diff(2)
139
+ assert_equal 2, chunks.size
140
+ assert_equal 2, chunks.first.lines.size
141
+ assert_equal 'This is the first line', chunks.first.lines.first.original_text
142
+ assert_equal 'This is the modified first line', chunks.first.lines.first.modified_text
143
+ assert_equal 'This line will be removed', chunks.first.lines.last.original_text
144
+ assert_nil chunks.first.lines.last.modified_text
145
+ assert_equal 'And this one won\'t be changed', chunks.last.lines.first.original_text
146
+ end
147
+
148
+ def test_diffs_addition_only_chunk
149
+ page = revise_brand_new_page(:title => 'A good page',
150
+ :text => "This is the first line\n" +
151
+ "And this is the second one")
152
+ page.revise(bob, now, :title => 'A good page',
153
+ :text => "This is the first line\n" +
154
+ "And this is the second one\n" +
155
+ "But it is not the last\n" +
156
+ "Because someone added other two")
157
+
158
+ chunks = page.revisions[0].diff(2)
159
+ assert_equal 2, chunks.size
160
+ assert chunks.first.unchanged?
161
+ assert !chunks.last.unchanged?
162
+ assert_equal :addition, chunks.last.action
163
+ assert_equal 2, chunks.first.lines.size
164
+ assert_equal 2, chunks.first.lines.last.original_position
165
+ assert_equal 2, chunks.first.lines.last.modified_position
166
+ assert_equal 2, chunks.last.lines.size
167
+ assert_nil chunks.last.lines.first.original_position
168
+ assert_nil chunks.last.lines.first.original_text
169
+ assert_equal 3, chunks.last.lines.first.modified_position
170
+ assert_equal 'But it is not the last', chunks.last.lines.first.modified_text
171
+ end
172
+
173
+ def test_diffs_removal_only_chunk
174
+ page = revise_brand_new_page(:title => 'A good page',
175
+ :text => "This is the first line\n" +
176
+ "This is the second line\n" +
177
+ "And this is the last one")
178
+ page.revise(bob, now, :title => 'A good page',
179
+ :text => "This is the first line\n" +
180
+ "And this is the last one")
181
+
182
+ chunks = page.revisions[0].diff(2)
183
+ assert_equal 3, chunks.size
184
+ assert chunks[0].unchanged?
185
+ assert !chunks[1].unchanged?
186
+ assert chunks[2].unchanged?
187
+ chunk = chunks[1]
188
+ assert_equal :removal, chunk.action
189
+ assert_equal 1, chunk.lines.size
190
+ assert_equal 2, chunk.lines.first.original_position
191
+ assert_equal 'This is the second line', chunk.lines.first.original_text
192
+ assert_nil chunk.lines.first.modified_position
193
+ assert_nil chunk.lines.first.modified_text
194
+ assert_equal 3, chunks[2].lines.first.original_position
195
+ assert_equal 2, chunks[2].lines.first.modified_position
196
+ end
37
197
 
38
198
  end
@@ -83,6 +83,7 @@ class WikiReporterTest < Test::Unit::TestCase
83
83
  page_provider.should_receive(:find).
84
84
  zero_or_more_times.
85
85
  and_return([Page.new(:name => 'EventPage').revise(bob, now,
86
+ :kind => 'event',
86
87
  :happens_at => planned_date,
87
88
  :title => 'Event page')])
88
89
  hl = EventsReporter.new(:page_provider => page_provider).headlines[0]
@@ -90,7 +91,7 @@ class WikiReporterTest < Test::Unit::TestCase
90
91
  end
91
92
  end
92
93
 
93
- def test_provides_includes_page_text_in_headline_description
94
+ def test_includes_page_text_in_headline_description
94
95
  FlexMock.use do |page_provider|
95
96
  page_provider.should_receive(:find).
96
97
  zero_or_more_times.