motiro 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/app/controllers/wiki_controller.rb +14 -1
- data/app/core/version.rb +1 -1
- data/app/core/wiki_reporter.rb +4 -17
- data/app/helpers/application_helper.rb +33 -0
- data/app/helpers/report_helper.rb +39 -0
- data/app/helpers/report_helper.rb.rej +46 -0
- data/app/helpers/wiki_helper.rb +1 -1
- data/app/models/change.rb +12 -41
- data/app/models/chunk.rb +56 -0
- data/app/models/page.rb +17 -0
- data/app/models/revision.rb +31 -0
- data/app/reporters/events_reporter.rb +0 -2
- data/app/views/report/show.rhtml +2 -2
- data/app/views/wiki/diff.rhtml +4 -0
- data/app/views/wiki/history.rhtml +32 -21
- data/app/views/wiki/history.rhtml.rej +63 -0
- data/config/motiro.yml +1 -1
- data/config/routes.rb +3 -0
- data/db/motirodb.sqlite.initial +0 -0
- data/db/translation/pt-BR.rb +6 -1
- data/db/translation/pt-BR.rb.rej +26 -0
- data/lib/diff_chunk_builder.rb +98 -0
- data/lib/tasks/packaging.rake +2 -1
- data/public/stylesheets/motiro.css +49 -18
- data/public/stylesheets/motiro.css.rej +37 -0
- data/public/wiki/history/OtherPage-en-us.xml +40 -0
- data/test/fixtures/pages.yml +1 -1
- data/test/fixtures/revisions.yml +15 -4
- data/test/functional/report_features_test.rb +7 -1
- data/test/functional/root_controller_test.rb +1 -1
- data/test/functional/wiki_controller_test.rb +44 -4
- data/test/unit/change_test.rb +29 -56
- data/test/unit/diff_chunk_builder_test.rb +269 -0
- data/test/unit/page_test.rb +46 -0
- data/test/unit/revision_test.rb +160 -0
- data/test/unit/wiki_reporter_test.rb +2 -1
- metadata +301 -283
- data/app/models/diff_table_builder.rb +0 -285
- data/test/unit/diff_table_builder_test.rb +0 -602
@@ -1,602 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
-
require 'diff_table_builder'
|
3
|
-
|
4
|
-
class DiffTableBuilderTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@builder = DiffTableBuilder.new
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_renders_addition_only
|
11
|
-
@builder.push_addition 'I have added this'
|
12
|
-
|
13
|
-
expected_diff_table =
|
14
|
-
"<table class='diff 'cellspacing='0'>\n" +
|
15
|
-
" <tr style='background: #FFF'>\n" +
|
16
|
-
" <td class='line_number'> </td>\n" +
|
17
|
-
" <td class='left' " +
|
18
|
-
"style='border-width: 1px 1px 1px 1px;'> </td>\n" +
|
19
|
-
" <td class='right changed' " +
|
20
|
-
"style='border-width: 1px 1px 1px 0;'>" +
|
21
|
-
"<pre>I have added this</pre>" +
|
22
|
-
"</td>\n" +
|
23
|
-
" <td class='line_number'>1</td>\n" +
|
24
|
-
" </tr>\n" +
|
25
|
-
"</table>"
|
26
|
-
|
27
|
-
assert_equal expected_diff_table, @builder.render_diff_table
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_renders_deletion_only
|
31
|
-
@builder.push_deletion 'I have removed this'
|
32
|
-
|
33
|
-
expected_diff_table =
|
34
|
-
"<table class='diff 'cellspacing='0'>\n" +
|
35
|
-
" <tr style='background: #FFF'>\n" +
|
36
|
-
" <td class='line_number'>1</td>\n" +
|
37
|
-
" <td class='left changed' " +
|
38
|
-
"style='border-width: 1px 1px 1px 1px;'>" +
|
39
|
-
"<pre>I have removed this</pre>" +
|
40
|
-
"</td>\n" +
|
41
|
-
" <td class='right' " +
|
42
|
-
"style='border-width: 1px 1px 1px 0;'> </td>\n" +
|
43
|
-
" <td class='line_number'> </td>\n" +
|
44
|
-
" </tr>\n" +
|
45
|
-
"</table>"
|
46
|
-
|
47
|
-
assert_equal expected_diff_table, @builder.render_diff_table
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_matches_alterning_addition_and_deletion
|
51
|
-
@builder.push_deletion 'I have removed this'
|
52
|
-
@builder.push_addition 'I have added this'
|
53
|
-
|
54
|
-
expected_diff_table =
|
55
|
-
"<table class='diff 'cellspacing='0'>\n" +
|
56
|
-
" <tr style='background: #FFF'>\n" +
|
57
|
-
" <td class='line_number'>1</td>\n" +
|
58
|
-
" <td class='left changed' " +
|
59
|
-
"style='border-width: 1px 1px 1px 1px;'>" +
|
60
|
-
"<pre>I have removed this</pre>" +
|
61
|
-
"</td>\n" +
|
62
|
-
" <td class='right changed' " +
|
63
|
-
"style='border-width: 1px 1px 1px 0;'>" +
|
64
|
-
"<pre>I have added this</pre>" +
|
65
|
-
"</td>\n" +
|
66
|
-
" <td class='line_number'>1</td>\n" +
|
67
|
-
" </tr>\n" +
|
68
|
-
"</table>"
|
69
|
-
|
70
|
-
assert_equal expected_diff_table, @builder.render_diff_table
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_multiline_modification
|
74
|
-
@builder.push_deletion 'This is the first old line'
|
75
|
-
@builder.push_deletion 'This is the second old line'
|
76
|
-
@builder.push_addition 'This is the first new line'
|
77
|
-
@builder.push_addition 'This is the second new line'
|
78
|
-
|
79
|
-
expected_diff_table =
|
80
|
-
"<table class='diff 'cellspacing='0'>\n" +
|
81
|
-
" <tr style='background: #FFF'>\n" +
|
82
|
-
" <td class='line_number'>1</td>\n" +
|
83
|
-
" <td class='left changed' " +
|
84
|
-
"style='border-width: 1px 1px 0 1px;'>" +
|
85
|
-
"<pre>This is the first old line</pre>" +
|
86
|
-
"</td>\n" +
|
87
|
-
" <td class='right changed' " +
|
88
|
-
"style='border-width: 1px 1px 0 0;'>" +
|
89
|
-
"<pre>This is the first new line</pre>" +
|
90
|
-
"</td>\n" +
|
91
|
-
" <td class='line_number'>1</td>\n" +
|
92
|
-
" </tr>\n" +
|
93
|
-
" <tr style='background: #FFF'>\n" +
|
94
|
-
" <td class='line_number'>2</td>\n" +
|
95
|
-
" <td class='left changed' " +
|
96
|
-
"style='border-width: 0 1px 1px 1px;'>" +
|
97
|
-
"<pre>This is the second old line</pre>" +
|
98
|
-
"</td>\n" +
|
99
|
-
" <td class='right changed' " +
|
100
|
-
"style='border-width: 0 1px 1px 0;'>" +
|
101
|
-
"<pre>This is the second new line</pre>" +
|
102
|
-
"</td>\n" +
|
103
|
-
" <td class='line_number'>2</td>\n" +
|
104
|
-
" </tr>\n" +
|
105
|
-
"</table>"
|
106
|
-
|
107
|
-
assert_equal expected_diff_table, @builder.render_diff_table
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_more_adds_than_deletes
|
111
|
-
@builder.push_deletion 'This is the first old line'
|
112
|
-
@builder.push_addition 'This is the first new line'
|
113
|
-
@builder.push_addition 'This is the second new line'
|
114
|
-
@builder.push_unchanged 'This line remains the same'
|
115
|
-
|
116
|
-
expected_diff_table =
|
117
|
-
"<table class='diff 'cellspacing='0'>\n" +
|
118
|
-
" <tr style='background: #FFF'>\n" +
|
119
|
-
" <td class='line_number'>1</td>\n" +
|
120
|
-
" <td class='left changed' " +
|
121
|
-
"style='border-width: 1px 1px 1px 1px;'>" +
|
122
|
-
"<pre>This is the first old line</pre>" +
|
123
|
-
"</td>\n" +
|
124
|
-
" <td class='right changed' " +
|
125
|
-
"style='border-width: 1px 1px 0 0;'>" +
|
126
|
-
"<pre>This is the first new line</pre>" +
|
127
|
-
"</td>\n" +
|
128
|
-
" <td class='line_number'>1</td>\n" +
|
129
|
-
" </tr>\n" +
|
130
|
-
" <tr style='background: #FFF'>\n" +
|
131
|
-
" <td class='line_number'> </td>\n" +
|
132
|
-
" <td class='left' " +
|
133
|
-
"style='border-width: 0 1px 0 0;'> " +
|
134
|
-
"</td>\n" +
|
135
|
-
" <td class='right changed' " +
|
136
|
-
"style='border-width: 0 1px 1px 1px;'>" +
|
137
|
-
"<pre>This is the second new line</pre>" +
|
138
|
-
"</td>\n" +
|
139
|
-
" <td class='line_number'>2</td>\n" +
|
140
|
-
" </tr>\n" +
|
141
|
-
" <tr style='background: #FFF'>\n" +
|
142
|
-
" <td class='line_number'>2</td>\n" +
|
143
|
-
" <td class='left' style='border-width: 0 1px 0 0;'>" +
|
144
|
-
"<pre>This line remains the same</pre>" +
|
145
|
-
"</td>\n" +
|
146
|
-
" <td class='right' style='border-width: 0 0 0 0;'>" +
|
147
|
-
"<pre>This line remains the same</pre>" +
|
148
|
-
"</td>\n" +
|
149
|
-
" <td class='line_number'>3</td>\n" +
|
150
|
-
" </tr>\n" +
|
151
|
-
"</table>"
|
152
|
-
|
153
|
-
assert_equal expected_diff_table, @builder.render_diff_table
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_less_adds_than_deletes
|
157
|
-
@builder.push_deletion 'This is the first old line'
|
158
|
-
@builder.push_deletion 'This is the second old line'
|
159
|
-
@builder.push_addition 'This is the first new line'
|
160
|
-
@builder.push_unchanged 'This line remains the same'
|
161
|
-
|
162
|
-
expected_diff_table =
|
163
|
-
"<table class='diff 'cellspacing='0'>\n" +
|
164
|
-
" <tr style='background: #FFF'>\n" +
|
165
|
-
" <td class='line_number'>1</td>\n" +
|
166
|
-
" <td class='left changed' " +
|
167
|
-
"style='border-width: 1px 1px 0 1px;'>" +
|
168
|
-
"<pre>This is the first old line</pre>" +
|
169
|
-
"</td>\n" +
|
170
|
-
" <td class='right changed' " +
|
171
|
-
"style='border-width: 1px 1px 1px 0;'>" +
|
172
|
-
"<pre>This is the first new line</pre>" +
|
173
|
-
"</td>\n" +
|
174
|
-
" <td class='line_number'>1</td>\n" +
|
175
|
-
" </tr>\n" +
|
176
|
-
" <tr style='background: #FFF'>\n" +
|
177
|
-
" <td class='line_number'>2</td>\n" +
|
178
|
-
" <td class='left changed' " +
|
179
|
-
"style='border-width: 0 1px 1px 1px;'>" +
|
180
|
-
"<pre>This is the second old line</pre>" +
|
181
|
-
"</td>\n" +
|
182
|
-
" <td class='right' " +
|
183
|
-
"style='border-width: 0 0 0 1px;'> </td>\n" +
|
184
|
-
" <td class='line_number'> </td>\n" +
|
185
|
-
" </tr>\n" +
|
186
|
-
" <tr style='background: #FFF'>\n" +
|
187
|
-
" <td class='line_number'>3</td>\n" +
|
188
|
-
" <td class='left' style='border-width: 0 1px 0 0;'>" +
|
189
|
-
"<pre>This line remains the same</pre>" +
|
190
|
-
"</td>\n" +
|
191
|
-
" <td class='right' style='border-width: 0 0 0 0;'>" +
|
192
|
-
"<pre>This line remains the same</pre>" +
|
193
|
-
"</td>\n" +
|
194
|
-
" <td class='line_number'>2</td>\n" +
|
195
|
-
" </tr>\n" +
|
196
|
-
"</table>"
|
197
|
-
|
198
|
-
assert_equal expected_diff_table, @builder.render_diff_table
|
199
|
-
end
|
200
|
-
|
201
|
-
def test_some_code_kept
|
202
|
-
@builder.start_line 6
|
203
|
-
|
204
|
-
@builder.push_unchanged 'div.channel-title {'
|
205
|
-
@builder.push_deletion ' font: normal 8pt Verdana,sans-serif;'
|
206
|
-
@builder.push_addition ' font: bold 10pt Verdana,sans-serif;'
|
207
|
-
@builder.push_unchanged ' margin:0 0 0 0;'
|
208
|
-
|
209
|
-
expected_diff_table =
|
210
|
-
"<table class='diff 'cellspacing='0'>\n" +
|
211
|
-
" <tr style='background: #FFF'>\n" +
|
212
|
-
" <td class='line_number'>6</td>\n" +
|
213
|
-
" <td class='left' style='border-width: 0 1px 0 0;'>" +
|
214
|
-
"<pre>div.channel-title {</pre>" +
|
215
|
-
"</td>\n" +
|
216
|
-
" <td class='right' style='border-width: 0 0 0 0;'>" +
|
217
|
-
"<pre>div.channel-title {</pre>" +
|
218
|
-
"</td>\n" +
|
219
|
-
" <td class='line_number'>6</td>\n" +
|
220
|
-
" </tr>\n" +
|
221
|
-
" <tr style='background: #FFF'>\n" +
|
222
|
-
" <td class='line_number'>7</td>\n" +
|
223
|
-
" <td class='left changed' " +
|
224
|
-
"style='border-width: 1px 1px 1px 1px;'>" +
|
225
|
-
"<pre> font: normal 8pt Verdana,sans-serif;</pre>" +
|
226
|
-
"</td>\n" +
|
227
|
-
" <td class='right changed' " +
|
228
|
-
"style='border-width: 1px 1px 1px 0;'>" +
|
229
|
-
"<pre> font: bold 10pt Verdana,sans-serif;</pre>" +
|
230
|
-
"</td>\n" +
|
231
|
-
" <td class='line_number'>7</td>\n" +
|
232
|
-
" </tr>\n" +
|
233
|
-
" <tr style='background: #FFF'>\n" +
|
234
|
-
" <td class='line_number'>8</td>\n" +
|
235
|
-
" <td class='left' style='border-width: 0 1px 0 0;'>" +
|
236
|
-
"<pre> margin:0 0 0 0;</pre>" +
|
237
|
-
"</td>\n" +
|
238
|
-
" <td class='right' style='border-width: 0 0 0 0;'>" +
|
239
|
-
"<pre> margin:0 0 0 0;</pre>" +
|
240
|
-
"</td>\n" +
|
241
|
-
" <td class='line_number'>8</td>\n" +
|
242
|
-
" </tr>\n" +
|
243
|
-
"</table>"
|
244
|
-
|
245
|
-
assert_equal expected_diff_table, @builder.render_diff_table
|
246
|
-
end
|
247
|
-
|
248
|
-
def test_esparse_changes
|
249
|
-
@builder.start_line 6
|
250
|
-
|
251
|
-
@builder.push_unchanged 'div.channel-title {'
|
252
|
-
@builder.push_deletion ' font: normal 8pt Verdana,sans-serif;'
|
253
|
-
@builder.push_addition ' font: bold 10pt Verdana,sans-serif;'
|
254
|
-
@builder.push_unchanged ' margin:0 0 0 0;'
|
255
|
-
|
256
|
-
@builder.start_line 13
|
257
|
-
|
258
|
-
@builder.push_unchanged 'div.channel-body-outer {'
|
259
|
-
@builder.push_deletion ' padding: 0 9px 0 9px;'
|
260
|
-
@builder.push_addition ' padding: 0 8px 0 8px;'
|
261
|
-
@builder.push_unchanged '}'
|
262
|
-
|
263
|
-
expected_diff_table =
|
264
|
-
"<table class='diff 'cellspacing='0'>\n" +
|
265
|
-
" <tr style='background: #FFF'>\n" +
|
266
|
-
" <td class='line_number'>6</td>\n" +
|
267
|
-
" <td class='left' style='border-width: 0 1px 0 0;'>" +
|
268
|
-
"<pre>div.channel-title {</pre>" +
|
269
|
-
"</td>\n" +
|
270
|
-
" <td class='right' style='border-width: 0 0 0 0;'>" +
|
271
|
-
"<pre>div.channel-title {</pre>" +
|
272
|
-
"</td>\n" +
|
273
|
-
" <td class='line_number'>6</td>\n" +
|
274
|
-
" </tr>\n" +
|
275
|
-
" <tr style='background: #FFF'>\n" +
|
276
|
-
" <td class='line_number'>7</td>\n" +
|
277
|
-
" <td class='left changed' " +
|
278
|
-
"style='border-width: 1px 1px 1px 1px;'>" +
|
279
|
-
"<pre> font: normal 8pt Verdana,sans-serif;</pre>" +
|
280
|
-
"</td>\n" +
|
281
|
-
" <td class='right changed' " +
|
282
|
-
"style='border-width: 1px 1px 1px 0;'>" +
|
283
|
-
"<pre> font: bold 10pt Verdana,sans-serif;</pre>" +
|
284
|
-
"</td>\n" +
|
285
|
-
" <td class='line_number'>7</td>\n" +
|
286
|
-
" </tr>\n" +
|
287
|
-
" <tr style='background: #FFF'>\n" +
|
288
|
-
" <td class='line_number'>8</td>\n" +
|
289
|
-
" <td class='left' style='border-width: 0 1px 0 0;'>" +
|
290
|
-
"<pre> margin:0 0 0 0;</pre>" +
|
291
|
-
"</td>\n" +
|
292
|
-
" <td class='right' style='border-width: 0 0 0 0;'>" +
|
293
|
-
"<pre> margin:0 0 0 0;</pre>" +
|
294
|
-
"</td>\n" +
|
295
|
-
" <td class='line_number'>8</td>\n" +
|
296
|
-
" </tr>\n" +
|
297
|
-
" <tr>\n" +
|
298
|
-
" <td style='border:solid gray; " +
|
299
|
-
"border-width: 1px 0 1px 0;'> </td>\n" +
|
300
|
-
" <td style='border:solid gray; " +
|
301
|
-
"border-width: 1px 0 1px 0;'> </td>\n" +
|
302
|
-
" <td style='border:solid gray; " +
|
303
|
-
"border-width: 1px 0 1px 0;'> </td>\n" +
|
304
|
-
" <td style='border:solid gray; " +
|
305
|
-
"border-width: 1px 0 1px 0;'> </td>\n" +
|
306
|
-
" </tr>\n" +
|
307
|
-
" <tr style='background: #FFF'>\n" +
|
308
|
-
" <td class='line_number'>13</td>\n" +
|
309
|
-
" <td class='left' style='border-width: 0 1px 0 0;'>" +
|
310
|
-
"<pre>div.channel-body-outer {</pre>" +
|
311
|
-
"</td>\n" +
|
312
|
-
" <td class='right' style='border-width: 0 0 0 0;'>" +
|
313
|
-
"<pre>div.channel-body-outer {</pre>" +
|
314
|
-
"</td>\n" +
|
315
|
-
" <td class='line_number'>13</td>\n" +
|
316
|
-
" </tr>\n" +
|
317
|
-
" <tr style='background: #FFF'>\n" +
|
318
|
-
" <td class='line_number'>14</td>\n" +
|
319
|
-
" <td class='left changed' " +
|
320
|
-
"style='border-width: 1px 1px 1px 1px;'>" +
|
321
|
-
"<pre> padding: 0 9px 0 9px;</pre>" +
|
322
|
-
"</td>\n" +
|
323
|
-
" <td class='right changed' " +
|
324
|
-
"style='border-width: 1px 1px 1px 0;'>" +
|
325
|
-
"<pre> padding: 0 8px 0 8px;</pre>" +
|
326
|
-
"</td>\n" +
|
327
|
-
" <td class='line_number'>14</td>\n" +
|
328
|
-
" </tr>\n" +
|
329
|
-
" <tr style='background: #FFF'>\n" +
|
330
|
-
" <td class='line_number'>15</td>\n" +
|
331
|
-
" <td class='left' style='border-width: 0 1px 0 0;'>" +
|
332
|
-
"<pre>}</pre>" +
|
333
|
-
"</td>\n" +
|
334
|
-
" <td class='right' style='border-width: 0 0 0 0;'>" +
|
335
|
-
"<pre>}</pre>" +
|
336
|
-
"</td>\n" +
|
337
|
-
" <td class='line_number'>15</td>\n" +
|
338
|
-
" </tr>\n" +
|
339
|
-
"</table>"
|
340
|
-
|
341
|
-
assert_equal expected_diff_table, @builder.render_diff_table
|
342
|
-
end
|
343
|
-
|
344
|
-
def test_unmatching_line_numbers
|
345
|
-
@builder.start_line(6, 6)
|
346
|
-
|
347
|
-
@builder.push_unchanged 'div.channel-title {'
|
348
|
-
@builder.push_deletion ' font: normal 8pt Verdana,sans-serif;'
|
349
|
-
@builder.push_addition ' font: bold 10pt Verdana,sans-serif;'
|
350
|
-
@builder.push_addition ' margin:0 0 0 0;'
|
351
|
-
|
352
|
-
@builder.start_line(13, 14)
|
353
|
-
|
354
|
-
@builder.push_unchanged 'div.channel-body-outer {'
|
355
|
-
@builder.push_deletion ' padding: 0 9px 0 9px;'
|
356
|
-
@builder.push_addition ' padding: 0 8px 0 8px;'
|
357
|
-
@builder.push_unchanged '}'
|
358
|
-
|
359
|
-
expected_diff_table =
|
360
|
-
"<table class='diff 'cellspacing='0'>\n" +
|
361
|
-
" <tr style='background: #FFF'>\n" +
|
362
|
-
" <td class='line_number'>6</td>\n" +
|
363
|
-
" <td class='left' style='border-width: 0 1px 0 0;'>" +
|
364
|
-
"<pre>div.channel-title {</pre>" +
|
365
|
-
"</td>\n" +
|
366
|
-
" <td class='right' style='border-width: 0 0 0 0;'>" +
|
367
|
-
"<pre>div.channel-title {</pre>" +
|
368
|
-
"</td>\n" +
|
369
|
-
" <td class='line_number'>6</td>\n" +
|
370
|
-
" </tr>\n" +
|
371
|
-
" <tr style='background: #FFF'>\n" +
|
372
|
-
" <td class='line_number'>7</td>\n" +
|
373
|
-
" <td class='left changed' " +
|
374
|
-
"style='border-width: 1px 1px 1px 1px;'>" +
|
375
|
-
"<pre> font: normal 8pt Verdana,sans-serif;</pre>" +
|
376
|
-
"</td>\n" +
|
377
|
-
" <td class='right changed' " +
|
378
|
-
"style='border-width: 1px 1px 0 0;'>" +
|
379
|
-
"<pre> font: bold 10pt Verdana,sans-serif;</pre>" +
|
380
|
-
"</td>\n" +
|
381
|
-
" <td class='line_number'>7</td>\n" +
|
382
|
-
" </tr>\n" +
|
383
|
-
" <tr style='background: #FFF'>\n" +
|
384
|
-
" <td class='line_number'> </td>\n" +
|
385
|
-
" <td class='left' style='border-width: 0 1px 0 0;'> " +
|
386
|
-
"</td>\n" +
|
387
|
-
" <td class='right changed' " +
|
388
|
-
"style='border-width: 0 1px 1px 1px;'>" +
|
389
|
-
"<pre> margin:0 0 0 0;</pre>" +
|
390
|
-
"</td>\n" +
|
391
|
-
" <td class='line_number'>8</td>\n" +
|
392
|
-
" </tr>\n" +
|
393
|
-
" <tr>\n" +
|
394
|
-
" <td style='border:solid gray; " +
|
395
|
-
"border-width: 1px 0 1px 0;'> </td>\n" +
|
396
|
-
" <td style='border:solid gray; " +
|
397
|
-
"border-width: 1px 0 1px 0;'> </td>\n" +
|
398
|
-
" <td style='border:solid gray; " +
|
399
|
-
"border-width: 1px 0 1px 0;'> </td>\n" +
|
400
|
-
" <td style='border:solid gray; " +
|
401
|
-
"border-width: 1px 0 1px 0;'> </td>\n" +
|
402
|
-
" </tr>\n" +
|
403
|
-
" <tr style='background: #FFF'>\n" +
|
404
|
-
" <td class='line_number'>13</td>\n" +
|
405
|
-
" <td class='left' style='border-width: 0 1px 0 0;'>" +
|
406
|
-
"<pre>div.channel-body-outer {</pre>" +
|
407
|
-
"</td>\n" +
|
408
|
-
" <td class='right' style='border-width: 0 0 0 0;'>" +
|
409
|
-
"<pre>div.channel-body-outer {</pre>" +
|
410
|
-
"</td>\n" +
|
411
|
-
" <td class='line_number'>14</td>\n" +
|
412
|
-
" </tr>\n" +
|
413
|
-
" <tr style='background: #FFF'>\n" +
|
414
|
-
" <td class='line_number'>14</td>\n" +
|
415
|
-
" <td class='left changed' " +
|
416
|
-
"style='border-width: 1px 1px 1px 1px;'>" +
|
417
|
-
"<pre> padding: 0 9px 0 9px;</pre>" +
|
418
|
-
"</td>\n" +
|
419
|
-
" <td class='right changed' " +
|
420
|
-
"style='border-width: 1px 1px 1px 0;'>" +
|
421
|
-
"<pre> padding: 0 8px 0 8px;</pre>" +
|
422
|
-
"</td>\n" +
|
423
|
-
" <td class='line_number'>15</td>\n" +
|
424
|
-
" </tr>\n" +
|
425
|
-
" <tr style='background: #FFF'>\n" +
|
426
|
-
" <td class='line_number'>15</td>\n" +
|
427
|
-
" <td class='left' style='border-width: 0 1px 0 0;'>" +
|
428
|
-
"<pre>}</pre>" +
|
429
|
-
"</td>\n" +
|
430
|
-
" <td class='right' style='border-width: 0 0 0 0;'>" +
|
431
|
-
"<pre>}</pre>" +
|
432
|
-
"</td>\n" +
|
433
|
-
" <td class='line_number'>16</td>\n" +
|
434
|
-
" </tr>\n" +
|
435
|
-
"</table>"
|
436
|
-
|
437
|
-
assert_equal expected_diff_table, @builder.render_diff_table
|
438
|
-
end
|
439
|
-
|
440
|
-
def test_escapes_html
|
441
|
-
@builder.push_unchanged ' <h1><%= h(@headline.title) -%></h1>'
|
442
|
-
expected_diff_table =
|
443
|
-
"<table class='diff 'cellspacing='0'>\n" +
|
444
|
-
" <tr style='background: #FFF'>\n" +
|
445
|
-
" <td class='line_number'>1</td>\n" +
|
446
|
-
" <td class='left' style='border-width: 0 1px 0 0;'>" +
|
447
|
-
"<pre> <h1><%= h(@headline.title) -%></h1></pre>" +
|
448
|
-
"</td>\n" +
|
449
|
-
" <td class='right' style='border-width: 0 0 0 0;'>" +
|
450
|
-
"<pre> <h1><%= h(@headline.title) -%></h1></pre>" +
|
451
|
-
"</td>\n" +
|
452
|
-
" <td class='line_number'>1</td>\n" +
|
453
|
-
" </tr>\n" +
|
454
|
-
"</table>"
|
455
|
-
|
456
|
-
assert_equal expected_diff_table, @builder.render_diff_table
|
457
|
-
end
|
458
|
-
|
459
|
-
def test_escapes_empty_lines
|
460
|
-
@builder.push_addition ''
|
461
|
-
@builder.push_addition ' def test_escapes_empty_lines'
|
462
|
-
expected_diff_table =
|
463
|
-
expected_diff_table =
|
464
|
-
"<table class='diff 'cellspacing='0'>\n" +
|
465
|
-
" <tr style='background: #FFF'>\n" +
|
466
|
-
" <td class='line_number'> </td>\n" +
|
467
|
-
" <td class='left' " +
|
468
|
-
"style='border-width: 1px 1px 1px 1px;'> </td>\n" +
|
469
|
-
" <td class='right changed' " +
|
470
|
-
"style='border-width: 1px 1px 0 0;'> </td>\n" +
|
471
|
-
" <td class='line_number'>1</td>\n" +
|
472
|
-
" </tr>\n" +
|
473
|
-
" <tr style='background: #FFF'>\n" +
|
474
|
-
" <td class='line_number'> </td>\n" +
|
475
|
-
" <td class='left' " +
|
476
|
-
"style='border-width: 0 1px 0 0;'> </td>\n" +
|
477
|
-
" <td class='right changed' " +
|
478
|
-
"style='border-width: 0 1px 1px 1px;'>" +
|
479
|
-
"<pre> def test_escapes_empty_lines</pre>" +
|
480
|
-
"</td>\n" +
|
481
|
-
" <td class='line_number'>2</td>\n" +
|
482
|
-
" </tr>\n" +
|
483
|
-
"</table>"
|
484
|
-
|
485
|
-
assert_equal expected_diff_table, @builder.render_diff_table
|
486
|
-
end
|
487
|
-
|
488
|
-
def test_inserts_break_between_addition_and_unchanged_starting_from_top
|
489
|
-
@builder.start_line(1, 1)
|
490
|
-
@builder.push_unchanged ""
|
491
|
-
@builder.push_addition "import java.io.IOException;"
|
492
|
-
@builder.start_line(51, 62)
|
493
|
-
@builder.push_unchanged "\t\t}"
|
494
|
-
|
495
|
-
expected_diff_table =
|
496
|
-
"<table class='diff 'cellspacing='0'>\n" +
|
497
|
-
" <tr style='background: #FFF'>\n" +
|
498
|
-
" <td class='line_number'>1</td>\n" +
|
499
|
-
" <td class='left' style='border-width: 0 1px 0 0;'> </td>\n" +
|
500
|
-
" <td class='right' style='border-width: 0 0 0 0;'> </td>\n" +
|
501
|
-
" <td class='line_number'>1</td>\n" +
|
502
|
-
" </tr>\n" +
|
503
|
-
" <tr style='background: #FFF'>\n" +
|
504
|
-
" <td class='line_number'> </td>\n" +
|
505
|
-
" <td class='left' style='border-width: 1px 1px 1px 1px;'> </td>\n" +
|
506
|
-
" <td class='right changed' style='border-width: 1px 1px 1px 0;'><pre>import java.io.IOException;</pre></td>\n" +
|
507
|
-
" <td class='line_number'>2</td>\n" +
|
508
|
-
" </tr>\n" +
|
509
|
-
" <tr>\n" +
|
510
|
-
" <td style='border:solid gray; border-width: 1px 0 1px 0;'> </td>\n" +
|
511
|
-
" <td style='border:solid gray; border-width: 1px 0 1px 0;'> </td>\n" +
|
512
|
-
" <td style='border:solid gray; border-width: 1px 0 1px 0;'> </td>\n" +
|
513
|
-
" <td style='border:solid gray; border-width: 1px 0 1px 0;'> </td>\n" +
|
514
|
-
" </tr>\n" +
|
515
|
-
" <tr style='background: #FFF'>\n" +
|
516
|
-
" <td class='line_number'>51</td>\n" +
|
517
|
-
" <td class='left' style='border-width: 0 1px 0 0;'><pre>\t\t}</pre></td>\n" +
|
518
|
-
" <td class='right' style='border-width: 0 0 0 0;'><pre>\t\t}</pre></td>\n" +
|
519
|
-
" <td class='line_number'>62</td>\n" +
|
520
|
-
" </tr>\n" +
|
521
|
-
"</table>"
|
522
|
-
|
523
|
-
assert_equal expected_diff_table, @builder.render_diff_table
|
524
|
-
end
|
525
|
-
|
526
|
-
def test_inserts_break_between_unchanged_and_addition_starting_from_top
|
527
|
-
@builder.start_line(1, 1)
|
528
|
-
@builder.push_addition "added line"
|
529
|
-
@builder.push_unchanged "old line number 1"
|
530
|
-
@builder.start_line(51, 62)
|
531
|
-
@builder.push_addition "new line 62"
|
532
|
-
|
533
|
-
expected_diff_table =
|
534
|
-
"<table class='diff 'cellspacing='0'>\n" +
|
535
|
-
" <tr style='background: #FFF'>\n" +
|
536
|
-
" <td class='line_number'> </td>\n" +
|
537
|
-
" <td class='left' style='border-width: 1px 1px 1px 1px;'> </td>\n" +
|
538
|
-
" <td class='right changed' style='border-width: 1px 1px 1px 0;'><pre>added line</pre></td>\n" +
|
539
|
-
" <td class='line_number'>1</td>\n" +
|
540
|
-
" </tr>\n" +
|
541
|
-
" <tr style='background: #FFF'>\n" +
|
542
|
-
" <td class='line_number'>1</td>\n" +
|
543
|
-
" <td class='left' style='border-width: 0 1px 0 0;'><pre>old line number 1</pre></td>\n" +
|
544
|
-
" <td class='right' style='border-width: 0 0 0 0;'><pre>old line number 1</pre></td>\n" +
|
545
|
-
" <td class='line_number'>2</td>\n" +
|
546
|
-
" </tr>\n" +
|
547
|
-
" <tr>\n" +
|
548
|
-
" <td style='border:solid gray; border-width: 1px 0 1px 0;'> </td>\n" +
|
549
|
-
" <td style='border:solid gray; border-width: 1px 0 1px 0;'> </td>\n" +
|
550
|
-
" <td style='border:solid gray; border-width: 1px 0 1px 0;'> </td>\n" +
|
551
|
-
" <td style='border:solid gray; border-width: 1px 0 1px 0;'> </td>\n" +
|
552
|
-
" </tr>\n" +
|
553
|
-
" <tr style='background: #FFF'>\n" +
|
554
|
-
" <td class='line_number'> </td>\n" +
|
555
|
-
" <td class='left' style='border-width: 1px 1px 1px 1px;'> </td>\n" +
|
556
|
-
" <td class='right changed' style='border-width: 1px 1px 1px 0;'><pre>new line 62</pre></td>\n" +
|
557
|
-
" <td class='line_number'>62</td>\n" +
|
558
|
-
" </tr>\n" +
|
559
|
-
"</table>"
|
560
|
-
|
561
|
-
assert_equal expected_diff_table, @builder.render_diff_table
|
562
|
-
end
|
563
|
-
|
564
|
-
def test_inserts_break_between_two_unchangeds_starting_from_top
|
565
|
-
@builder.start_line(1, 1)
|
566
|
-
@builder.push_addition "added line"
|
567
|
-
@builder.push_unchanged "old line number 1"
|
568
|
-
@builder.start_line(50, 56)
|
569
|
-
@builder.push_unchanged "\t\t"
|
570
|
-
|
571
|
-
expected_diff_table =
|
572
|
-
"<table class='diff 'cellspacing='0'>\n" +
|
573
|
-
" <tr style='background: #FFF'>\n" +
|
574
|
-
" <td class='line_number'> </td>\n" +
|
575
|
-
" <td class='left' style='border-width: 1px 1px 1px 1px;'> </td>\n" +
|
576
|
-
" <td class='right changed' style='border-width: 1px 1px 1px 0;'><pre>added line</pre></td>\n" +
|
577
|
-
" <td class='line_number'>1</td>\n" +
|
578
|
-
" </tr>\n" +
|
579
|
-
" <tr style='background: #FFF'>\n" +
|
580
|
-
" <td class='line_number'>1</td>\n" +
|
581
|
-
" <td class='left' style='border-width: 0 1px 0 0;'><pre>old line number 1</pre></td>\n" +
|
582
|
-
" <td class='right' style='border-width: 0 0 0 0;'><pre>old line number 1</pre></td>\n" +
|
583
|
-
" <td class='line_number'>2</td>\n" +
|
584
|
-
" </tr>\n" +
|
585
|
-
" <tr>\n" +
|
586
|
-
" <td style='border:solid gray; border-width: 1px 0 1px 0;'> </td>\n" +
|
587
|
-
" <td style='border:solid gray; border-width: 1px 0 1px 0;'> </td>\n" +
|
588
|
-
" <td style='border:solid gray; border-width: 1px 0 1px 0;'> </td>\n" +
|
589
|
-
" <td style='border:solid gray; border-width: 1px 0 1px 0;'> </td>\n" +
|
590
|
-
" </tr>\n" +
|
591
|
-
" <tr style='background: #FFF'>\n" +
|
592
|
-
" <td class='line_number'>50</td>\n" +
|
593
|
-
" <td class='left' style='border-width: 0 1px 0 0;'><pre>\t\t</pre></td>\n" +
|
594
|
-
" <td class='right' style='border-width: 0 0 0 0;'><pre>\t\t</pre></td>\n" +
|
595
|
-
" <td class='line_number'>56</td>\n" +
|
596
|
-
" </tr>\n" +
|
597
|
-
"</table>"
|
598
|
-
|
599
|
-
assert_equal expected_diff_table, @builder.render_diff_table
|
600
|
-
end
|
601
|
-
|
602
|
-
end
|