##// END OF EJS Templates
scm: mercurial: add missing "assert" changesets size at functional test....
Toshi MARUYAMA -
r6103:7f9f295b4e35
parent child
Show More
@@ -1,439 +1,439
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
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
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19 require 'repositories_controller'
19 require 'repositories_controller'
20
20
21 # Re-raise errors caught by the controller.
21 # Re-raise errors caught by the controller.
22 class RepositoriesController; def rescue_action(e) raise e end; end
22 class RepositoriesController; def rescue_action(e) raise e end; end
23
23
24 class RepositoriesMercurialControllerTest < ActionController::TestCase
24 class RepositoriesMercurialControllerTest < ActionController::TestCase
25 fixtures :projects, :users, :roles, :members, :member_roles,
25 fixtures :projects, :users, :roles, :members, :member_roles,
26 :repositories, :enabled_modules
26 :repositories, :enabled_modules
27
27
28 REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s
28 REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s
29 CHAR_1_HEX = "\xc3\x9c"
29 CHAR_1_HEX = "\xc3\x9c"
30 PRJ_ID = 3
30 PRJ_ID = 3
31
31
32 ruby19_non_utf8_pass =
32 ruby19_non_utf8_pass =
33 (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8')
33 (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8')
34
34
35 def setup
35 def setup
36 @controller = RepositoriesController.new
36 @controller = RepositoriesController.new
37 @request = ActionController::TestRequest.new
37 @request = ActionController::TestRequest.new
38 @response = ActionController::TestResponse.new
38 @response = ActionController::TestResponse.new
39 User.current = nil
39 User.current = nil
40 @repository = Repository::Mercurial.create(
40 @repository = Repository::Mercurial.create(
41 :project => Project.find(PRJ_ID),
41 :project => Project.find(PRJ_ID),
42 :url => REPOSITORY_PATH,
42 :url => REPOSITORY_PATH,
43 :path_encoding => 'ISO-8859-1'
43 :path_encoding => 'ISO-8859-1'
44 )
44 )
45 assert @repository
45 assert @repository
46 @diff_c_support = true
46 @diff_c_support = true
47 @char_1 = CHAR_1_HEX.dup
47 @char_1 = CHAR_1_HEX.dup
48 @tag_char_1 = "tag-#{CHAR_1_HEX}-00"
48 @tag_char_1 = "tag-#{CHAR_1_HEX}-00"
49 @branch_char_0 = "branch-#{CHAR_1_HEX}-00"
49 @branch_char_0 = "branch-#{CHAR_1_HEX}-00"
50 @branch_char_1 = "branch-#{CHAR_1_HEX}-01"
50 @branch_char_1 = "branch-#{CHAR_1_HEX}-01"
51 if @char_1.respond_to?(:force_encoding)
51 if @char_1.respond_to?(:force_encoding)
52 @char_1.force_encoding('UTF-8')
52 @char_1.force_encoding('UTF-8')
53 @tag_char_1.force_encoding('UTF-8')
53 @tag_char_1.force_encoding('UTF-8')
54 @branch_char_0.force_encoding('UTF-8')
54 @branch_char_0.force_encoding('UTF-8')
55 @branch_char_1.force_encoding('UTF-8')
55 @branch_char_1.force_encoding('UTF-8')
56 end
56 end
57 end
57 end
58
58
59 if ruby19_non_utf8_pass
59 if ruby19_non_utf8_pass
60 puts "TODO: Mercurial functional test fails in Ruby 1.9 " +
60 puts "TODO: Mercurial functional test fails in Ruby 1.9 " +
61 "and Encoding.default_external is not UTF-8. " +
61 "and Encoding.default_external is not UTF-8. " +
62 "Current value is '#{Encoding.default_external.to_s}'"
62 "Current value is '#{Encoding.default_external.to_s}'"
63 def test_fake; assert true end
63 def test_fake; assert true end
64 elsif File.directory?(REPOSITORY_PATH)
64 elsif File.directory?(REPOSITORY_PATH)
65 def test_show_root
65 def test_show_root
66 @repository.fetch_changesets
66 @repository.fetch_changesets
67 @repository.reload
67 @repository.reload
68 get :show, :id => PRJ_ID
68 get :show, :id => PRJ_ID
69 assert_response :success
69 assert_response :success
70 assert_template 'show'
70 assert_template 'show'
71 assert_not_nil assigns(:entries)
71 assert_not_nil assigns(:entries)
72 assert_equal 4, assigns(:entries).size
72 assert_equal 4, assigns(:entries).size
73 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
73 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
74 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
74 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
75 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
75 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
76 assert_not_nil assigns(:changesets)
76 assert_not_nil assigns(:changesets)
77 assigns(:changesets).size > 0
77 assert assigns(:changesets).size > 0
78 end
78 end
79
79
80 def test_show_directory
80 def test_show_directory
81 @repository.fetch_changesets
81 @repository.fetch_changesets
82 @repository.reload
82 @repository.reload
83 get :show, :id => PRJ_ID, :path => ['images']
83 get :show, :id => PRJ_ID, :path => ['images']
84 assert_response :success
84 assert_response :success
85 assert_template 'show'
85 assert_template 'show'
86 assert_not_nil assigns(:entries)
86 assert_not_nil assigns(:entries)
87 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
87 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
88 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
88 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
89 assert_not_nil entry
89 assert_not_nil entry
90 assert_equal 'file', entry.kind
90 assert_equal 'file', entry.kind
91 assert_equal 'images/edit.png', entry.path
91 assert_equal 'images/edit.png', entry.path
92 assert_not_nil assigns(:changesets)
92 assert_not_nil assigns(:changesets)
93 assigns(:changesets).size > 0
93 assert assigns(:changesets).size > 0
94 end
94 end
95
95
96 def test_show_at_given_revision
96 def test_show_at_given_revision
97 @repository.fetch_changesets
97 @repository.fetch_changesets
98 @repository.reload
98 @repository.reload
99 [0, '0', '0885933ad4f6'].each do |r1|
99 [0, '0', '0885933ad4f6'].each do |r1|
100 get :show, :id => PRJ_ID, :path => ['images'], :rev => r1
100 get :show, :id => PRJ_ID, :path => ['images'], :rev => r1
101 assert_response :success
101 assert_response :success
102 assert_template 'show'
102 assert_template 'show'
103 assert_not_nil assigns(:entries)
103 assert_not_nil assigns(:entries)
104 assert_equal ['delete.png'], assigns(:entries).collect(&:name)
104 assert_equal ['delete.png'], assigns(:entries).collect(&:name)
105 assert_not_nil assigns(:changesets)
105 assert_not_nil assigns(:changesets)
106 assigns(:changesets).size > 0
106 assert assigns(:changesets).size > 0
107 end
107 end
108 end
108 end
109
109
110 def test_show_directory_sql_escape_percent
110 def test_show_directory_sql_escape_percent
111 @repository.fetch_changesets
111 @repository.fetch_changesets
112 @repository.reload
112 @repository.reload
113 [13, '13', '3a330eb32958'].each do |r1|
113 [13, '13', '3a330eb32958'].each do |r1|
114 get :show, :id => PRJ_ID, :path => ['sql_escape', 'percent%dir'],
114 get :show, :id => PRJ_ID, :path => ['sql_escape', 'percent%dir'],
115 :rev => r1
115 :rev => r1
116 assert_response :success
116 assert_response :success
117 assert_template 'show'
117 assert_template 'show'
118
118
119 assert_not_nil assigns(:entries)
119 assert_not_nil assigns(:entries)
120 assert_equal ['percent%file1.txt', 'percentfile1.txt'],
120 assert_equal ['percent%file1.txt', 'percentfile1.txt'],
121 assigns(:entries).collect(&:name)
121 assigns(:entries).collect(&:name)
122 changesets = assigns(:changesets)
122 changesets = assigns(:changesets)
123 assert_not_nil changesets
123 assert_not_nil changesets
124 assigns(:changesets).size > 0
124 assert assigns(:changesets).size > 0
125 assert_equal %w(13 11 10 9), changesets.collect(&:revision)
125 assert_equal %w(13 11 10 9), changesets.collect(&:revision)
126 end
126 end
127 end
127 end
128
128
129 def test_show_directory_latin_1_path
129 def test_show_directory_latin_1_path
130 @repository.fetch_changesets
130 @repository.fetch_changesets
131 @repository.reload
131 @repository.reload
132 [21, '21', 'adf805632193'].each do |r1|
132 [21, '21', 'adf805632193'].each do |r1|
133 get :show, :id => PRJ_ID, :path => ['latin-1-dir'], :rev => r1
133 get :show, :id => PRJ_ID, :path => ['latin-1-dir'], :rev => r1
134 assert_response :success
134 assert_response :success
135 assert_template 'show'
135 assert_template 'show'
136
136
137 assert_not_nil assigns(:entries)
137 assert_not_nil assigns(:entries)
138 assert_equal ["make-latin-1-file.rb",
138 assert_equal ["make-latin-1-file.rb",
139 "test-#{@char_1}-1.txt",
139 "test-#{@char_1}-1.txt",
140 "test-#{@char_1}-2.txt",
140 "test-#{@char_1}-2.txt",
141 "test-#{@char_1}.txt"], assigns(:entries).collect(&:name)
141 "test-#{@char_1}.txt"], assigns(:entries).collect(&:name)
142 changesets = assigns(:changesets)
142 changesets = assigns(:changesets)
143 assert_not_nil changesets
143 assert_not_nil changesets
144 assert_equal %w(21 20 19 18 17), changesets.collect(&:revision)
144 assert_equal %w(21 20 19 18 17), changesets.collect(&:revision)
145 end
145 end
146 end
146 end
147
147
148 def test_show_branch
148 def test_show_branch
149 @repository.fetch_changesets
149 @repository.fetch_changesets
150 @repository.reload
150 @repository.reload
151 [
151 [
152 'default',
152 'default',
153 @branch_char_1,
153 @branch_char_1,
154 'branch (1)[2]&,%.-3_4',
154 'branch (1)[2]&,%.-3_4',
155 @branch_char_0,
155 @branch_char_0,
156 'test_branch.latin-1',
156 'test_branch.latin-1',
157 'test-branch-00',
157 'test-branch-00',
158 ].each do |bra|
158 ].each do |bra|
159 get :show, :id => PRJ_ID, :rev => bra
159 get :show, :id => PRJ_ID, :rev => bra
160 assert_response :success
160 assert_response :success
161 assert_template 'show'
161 assert_template 'show'
162 assert_not_nil assigns(:entries)
162 assert_not_nil assigns(:entries)
163 assert assigns(:entries).size > 0
163 assert assigns(:entries).size > 0
164 assert_not_nil assigns(:changesets)
164 assert_not_nil assigns(:changesets)
165 assigns(:changesets).size > 0
165 assert assigns(:changesets).size > 0
166 end
166 end
167 end
167 end
168
168
169 def test_show_tag
169 def test_show_tag
170 @repository.fetch_changesets
170 @repository.fetch_changesets
171 @repository.reload
171 @repository.reload
172 [
172 [
173 @tag_char_1,
173 @tag_char_1,
174 'tag_test.00',
174 'tag_test.00',
175 'tag-init-revision'
175 'tag-init-revision'
176 ].each do |tag|
176 ].each do |tag|
177 get :show, :id => PRJ_ID, :rev => tag
177 get :show, :id => PRJ_ID, :rev => tag
178 assert_response :success
178 assert_response :success
179 assert_template 'show'
179 assert_template 'show'
180 assert_not_nil assigns(:entries)
180 assert_not_nil assigns(:entries)
181 assert assigns(:entries).size > 0
181 assert assigns(:entries).size > 0
182 assert_not_nil assigns(:changesets)
182 assert_not_nil assigns(:changesets)
183 assigns(:changesets).size > 0
183 assert assigns(:changesets).size > 0
184 end
184 end
185 end
185 end
186
186
187 def test_changes
187 def test_changes
188 get :changes, :id => PRJ_ID, :path => ['images', 'edit.png']
188 get :changes, :id => PRJ_ID, :path => ['images', 'edit.png']
189 assert_response :success
189 assert_response :success
190 assert_template 'changes'
190 assert_template 'changes'
191 assert_tag :tag => 'h2', :content => 'edit.png'
191 assert_tag :tag => 'h2', :content => 'edit.png'
192 end
192 end
193
193
194 def test_entry_show
194 def test_entry_show
195 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
195 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
196 assert_response :success
196 assert_response :success
197 assert_template 'entry'
197 assert_template 'entry'
198 # Line 10
198 # Line 10
199 assert_tag :tag => 'th',
199 assert_tag :tag => 'th',
200 :content => '10',
200 :content => '10',
201 :attributes => { :class => 'line-num' },
201 :attributes => { :class => 'line-num' },
202 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
202 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
203 end
203 end
204
204
205 def test_entry_show_latin_1_path
205 def test_entry_show_latin_1_path
206 [21, '21', 'adf805632193'].each do |r1|
206 [21, '21', 'adf805632193'].each do |r1|
207 get :entry, :id => PRJ_ID,
207 get :entry, :id => PRJ_ID,
208 :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
208 :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
209 assert_response :success
209 assert_response :success
210 assert_template 'entry'
210 assert_template 'entry'
211 assert_tag :tag => 'th',
211 assert_tag :tag => 'th',
212 :content => '1',
212 :content => '1',
213 :attributes => { :class => 'line-num' },
213 :attributes => { :class => 'line-num' },
214 :sibling => { :tag => 'td',
214 :sibling => { :tag => 'td',
215 :content => /Mercurial is a distributed version control system/ }
215 :content => /Mercurial is a distributed version control system/ }
216 end
216 end
217 end
217 end
218
218
219 def test_entry_show_latin_1_contents
219 def test_entry_show_latin_1_contents
220 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
220 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
221 [27, '27', '7bbf4c738e71'].each do |r1|
221 [27, '27', '7bbf4c738e71'].each do |r1|
222 get :entry, :id => PRJ_ID,
222 get :entry, :id => PRJ_ID,
223 :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1
223 :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1
224 assert_response :success
224 assert_response :success
225 assert_template 'entry'
225 assert_template 'entry'
226 assert_tag :tag => 'th',
226 assert_tag :tag => 'th',
227 :content => '1',
227 :content => '1',
228 :attributes => { :class => 'line-num' },
228 :attributes => { :class => 'line-num' },
229 :sibling => { :tag => 'td',
229 :sibling => { :tag => 'td',
230 :content => /test-#{@char_1}.txt/ }
230 :content => /test-#{@char_1}.txt/ }
231 end
231 end
232 end
232 end
233 end
233 end
234
234
235 def test_entry_download
235 def test_entry_download
236 get :entry, :id => PRJ_ID,
236 get :entry, :id => PRJ_ID,
237 :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
237 :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
238 assert_response :success
238 assert_response :success
239 # File content
239 # File content
240 assert @response.body.include?('WITHOUT ANY WARRANTY')
240 assert @response.body.include?('WITHOUT ANY WARRANTY')
241 end
241 end
242
242
243 def test_entry_binary_force_download
243 def test_entry_binary_force_download
244 get :entry, :id => PRJ_ID, :rev => 1, :path => ['images', 'edit.png']
244 get :entry, :id => PRJ_ID, :rev => 1, :path => ['images', 'edit.png']
245 assert_response :success
245 assert_response :success
246 assert_equal 'image/png', @response.content_type
246 assert_equal 'image/png', @response.content_type
247 end
247 end
248
248
249 def test_directory_entry
249 def test_directory_entry
250 get :entry, :id => PRJ_ID, :path => ['sources']
250 get :entry, :id => PRJ_ID, :path => ['sources']
251 assert_response :success
251 assert_response :success
252 assert_template 'show'
252 assert_template 'show'
253 assert_not_nil assigns(:entry)
253 assert_not_nil assigns(:entry)
254 assert_equal 'sources', assigns(:entry).name
254 assert_equal 'sources', assigns(:entry).name
255 end
255 end
256
256
257 def test_diff
257 def test_diff
258 @repository.fetch_changesets
258 @repository.fetch_changesets
259 @repository.reload
259 @repository.reload
260 [4, '4', 'def6d2f1254a'].each do |r1|
260 [4, '4', 'def6d2f1254a'].each do |r1|
261 # Full diff of changeset 4
261 # Full diff of changeset 4
262 ['inline', 'sbs'].each do |dt|
262 ['inline', 'sbs'].each do |dt|
263 get :diff, :id => PRJ_ID, :rev => r1, :type => dt
263 get :diff, :id => PRJ_ID, :rev => r1, :type => dt
264 assert_response :success
264 assert_response :success
265 assert_template 'diff'
265 assert_template 'diff'
266 if @diff_c_support
266 if @diff_c_support
267 # Line 22 removed
267 # Line 22 removed
268 assert_tag :tag => 'th',
268 assert_tag :tag => 'th',
269 :content => '22',
269 :content => '22',
270 :sibling => { :tag => 'td',
270 :sibling => { :tag => 'td',
271 :attributes => { :class => /diff_out/ },
271 :attributes => { :class => /diff_out/ },
272 :content => /def remove/ }
272 :content => /def remove/ }
273 assert_tag :tag => 'h2', :content => /4:def6d2f1254a/
273 assert_tag :tag => 'h2', :content => /4:def6d2f1254a/
274 end
274 end
275 end
275 end
276 end
276 end
277 end
277 end
278
278
279 def test_diff_two_revs
279 def test_diff_two_revs
280 @repository.fetch_changesets
280 @repository.fetch_changesets
281 @repository.reload
281 @repository.reload
282 [2, '400bb8672109', '400', 400].each do |r1|
282 [2, '400bb8672109', '400', 400].each do |r1|
283 [4, 'def6d2f1254a'].each do |r2|
283 [4, 'def6d2f1254a'].each do |r2|
284 ['inline', 'sbs'].each do |dt|
284 ['inline', 'sbs'].each do |dt|
285 get :diff,
285 get :diff,
286 :id => PRJ_ID,
286 :id => PRJ_ID,
287 :rev => r1,
287 :rev => r1,
288 :rev_to => r2,
288 :rev_to => r2,
289 :type => dt
289 :type => dt
290 assert_response :success
290 assert_response :success
291 assert_template 'diff'
291 assert_template 'diff'
292 diff = assigns(:diff)
292 diff = assigns(:diff)
293 assert_not_nil diff
293 assert_not_nil diff
294 assert_tag :tag => 'h2',
294 assert_tag :tag => 'h2',
295 :content => /4:def6d2f1254a 2:400bb8672109/
295 :content => /4:def6d2f1254a 2:400bb8672109/
296 end
296 end
297 end
297 end
298 end
298 end
299 end
299 end
300
300
301 def test_diff_latin_1_path
301 def test_diff_latin_1_path
302 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
302 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
303 [21, 'adf805632193'].each do |r1|
303 [21, 'adf805632193'].each do |r1|
304 ['inline', 'sbs'].each do |dt|
304 ['inline', 'sbs'].each do |dt|
305 get :diff, :id => PRJ_ID, :rev => r1, :type => dt
305 get :diff, :id => PRJ_ID, :rev => r1, :type => dt
306 assert_response :success
306 assert_response :success
307 assert_template 'diff'
307 assert_template 'diff'
308 assert_tag :tag => 'thead',
308 assert_tag :tag => 'thead',
309 :descendant => {
309 :descendant => {
310 :tag => 'th',
310 :tag => 'th',
311 :attributes => { :class => 'filename' } ,
311 :attributes => { :class => 'filename' } ,
312 :content => /latin-1-dir\/test-#{@char_1}-2.txt/ ,
312 :content => /latin-1-dir\/test-#{@char_1}-2.txt/ ,
313 },
313 },
314 :sibling => {
314 :sibling => {
315 :tag => 'tbody',
315 :tag => 'tbody',
316 :descendant => {
316 :descendant => {
317 :tag => 'td',
317 :tag => 'td',
318 :attributes => { :class => /diff_in/ },
318 :attributes => { :class => /diff_in/ },
319 :content => /It is written in Python/
319 :content => /It is written in Python/
320 }
320 }
321 }
321 }
322 end
322 end
323 end
323 end
324 end
324 end
325 end
325 end
326
326
327 def test_annotate
327 def test_annotate
328 get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
328 get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
329 assert_response :success
329 assert_response :success
330 assert_template 'annotate'
330 assert_template 'annotate'
331 # Line 23, revision 4:def6d2f1254a
331 # Line 23, revision 4:def6d2f1254a
332 assert_tag :tag => 'th',
332 assert_tag :tag => 'th',
333 :content => '23',
333 :content => '23',
334 :attributes => { :class => 'line-num' },
334 :attributes => { :class => 'line-num' },
335 :sibling =>
335 :sibling =>
336 {
336 {
337 :tag => 'td',
337 :tag => 'td',
338 :attributes => { :class => 'revision' },
338 :attributes => { :class => 'revision' },
339 :child => { :tag => 'a', :content => '4:def6d2f1254a' }
339 :child => { :tag => 'a', :content => '4:def6d2f1254a' }
340 }
340 }
341 assert_tag :tag => 'th',
341 assert_tag :tag => 'th',
342 :content => '23',
342 :content => '23',
343 :attributes => { :class => 'line-num' },
343 :attributes => { :class => 'line-num' },
344 :sibling =>
344 :sibling =>
345 {
345 {
346 :tag => 'td' ,
346 :tag => 'td' ,
347 :content => 'jsmith' ,
347 :content => 'jsmith' ,
348 :attributes => { :class => 'author' },
348 :attributes => { :class => 'author' },
349 }
349 }
350 assert_tag :tag => 'th',
350 assert_tag :tag => 'th',
351 :content => '23',
351 :content => '23',
352 :attributes => { :class => 'line-num' },
352 :attributes => { :class => 'line-num' },
353 :sibling => { :tag => 'td', :content => /watcher =/ }
353 :sibling => { :tag => 'td', :content => /watcher =/ }
354 end
354 end
355
355
356 def test_annotate_not_in_tip
356 def test_annotate_not_in_tip
357 @repository.fetch_changesets
357 @repository.fetch_changesets
358 @repository.reload
358 @repository.reload
359 assert @repository.changesets.size > 0
359 assert @repository.changesets.size > 0
360
360
361 get :annotate, :id => PRJ_ID,
361 get :annotate, :id => PRJ_ID,
362 :path => ['sources', 'welcome_controller.rb']
362 :path => ['sources', 'welcome_controller.rb']
363 assert_response 404
363 assert_response 404
364 assert_error_tag :content => /was not found/
364 assert_error_tag :content => /was not found/
365 end
365 end
366
366
367 def test_annotate_at_given_revision
367 def test_annotate_at_given_revision
368 @repository.fetch_changesets
368 @repository.fetch_changesets
369 @repository.reload
369 @repository.reload
370 [2, '400bb8672109', '400', 400].each do |r1|
370 [2, '400bb8672109', '400', 400].each do |r1|
371 get :annotate, :id => PRJ_ID, :rev => r1,
371 get :annotate, :id => PRJ_ID, :rev => r1,
372 :path => ['sources', 'watchers_controller.rb']
372 :path => ['sources', 'watchers_controller.rb']
373 assert_response :success
373 assert_response :success
374 assert_template 'annotate'
374 assert_template 'annotate'
375 assert_tag :tag => 'h2', :content => /@ 2:400bb8672109/
375 assert_tag :tag => 'h2', :content => /@ 2:400bb8672109/
376 end
376 end
377 end
377 end
378
378
379 def test_annotate_latin_1_path
379 def test_annotate_latin_1_path
380 [21, '21', 'adf805632193'].each do |r1|
380 [21, '21', 'adf805632193'].each do |r1|
381 get :annotate, :id => PRJ_ID,
381 get :annotate, :id => PRJ_ID,
382 :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
382 :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
383 assert_response :success
383 assert_response :success
384 assert_template 'annotate'
384 assert_template 'annotate'
385 assert_tag :tag => 'th',
385 assert_tag :tag => 'th',
386 :content => '1',
386 :content => '1',
387 :attributes => { :class => 'line-num' },
387 :attributes => { :class => 'line-num' },
388 :sibling =>
388 :sibling =>
389 {
389 {
390 :tag => 'td',
390 :tag => 'td',
391 :attributes => { :class => 'revision' },
391 :attributes => { :class => 'revision' },
392 :child => { :tag => 'a', :content => '20:709858aafd1b' }
392 :child => { :tag => 'a', :content => '20:709858aafd1b' }
393 }
393 }
394 assert_tag :tag => 'th',
394 assert_tag :tag => 'th',
395 :content => '1',
395 :content => '1',
396 :attributes => { :class => 'line-num' },
396 :attributes => { :class => 'line-num' },
397 :sibling =>
397 :sibling =>
398 {
398 {
399 :tag => 'td' ,
399 :tag => 'td' ,
400 :content => 'jsmith' ,
400 :content => 'jsmith' ,
401 :attributes => { :class => 'author' },
401 :attributes => { :class => 'author' },
402 }
402 }
403 assert_tag :tag => 'th',
403 assert_tag :tag => 'th',
404 :content => '1',
404 :content => '1',
405 :attributes => { :class => 'line-num' },
405 :attributes => { :class => 'line-num' },
406 :sibling => { :tag => 'td',
406 :sibling => { :tag => 'td',
407 :content => /Mercurial is a distributed version control system/ }
407 :content => /Mercurial is a distributed version control system/ }
408
408
409 end
409 end
410 end
410 end
411
411
412 def test_annotate_latin_1_contents
412 def test_annotate_latin_1_contents
413 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
413 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
414 [27, '7bbf4c738e71'].each do |r1|
414 [27, '7bbf4c738e71'].each do |r1|
415 get :annotate, :id => PRJ_ID,
415 get :annotate, :id => PRJ_ID,
416 :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1
416 :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1
417 assert_tag :tag => 'th',
417 assert_tag :tag => 'th',
418 :content => '1',
418 :content => '1',
419 :attributes => { :class => 'line-num' },
419 :attributes => { :class => 'line-num' },
420 :sibling => { :tag => 'td',
420 :sibling => { :tag => 'td',
421 :content => /test-#{@char_1}.txt/ }
421 :content => /test-#{@char_1}.txt/ }
422 end
422 end
423 end
423 end
424 end
424 end
425
425
426 def test_empty_revision
426 def test_empty_revision
427 @repository.fetch_changesets
427 @repository.fetch_changesets
428 @repository.reload
428 @repository.reload
429 ['', ' ', nil].each do |r|
429 ['', ' ', nil].each do |r|
430 get :revision, :id => PRJ_ID, :rev => r
430 get :revision, :id => PRJ_ID, :rev => r
431 assert_response 404
431 assert_response 404
432 assert_error_tag :content => /was not found/
432 assert_error_tag :content => /was not found/
433 end
433 end
434 end
434 end
435 else
435 else
436 puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!"
436 puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!"
437 def test_fake; assert true end
437 def test_fake; assert true end
438 end
438 end
439 end
439 end
General Comments 0
You need to be logged in to leave comments. Login now