##// END OF EJS Templates
scm: mercurial: code clean up functional test....
Toshi MARUYAMA -
r5566:ab6b848304c8
parent child
Show More
@@ -1,373 +1,379
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, :repositories, :enabled_modules
25 fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules
26
26
27 # No '..' in the repository path
27 # No '..' in the repository path
28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') +
29 '/tmp/test/mercurial_repository'
29 CHAR_1_HEX = "\xc3\x9c"
30 CHAR_1_HEX = "\xc3\x9c"
30 PRJ_ID = 3
31 PRJ_ID = 3
31
32
32 ruby19_non_utf8_pass = (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8')
33 ruby19_non_utf8_pass =
34 (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8')
33
35
34 def setup
36 def setup
35 @controller = RepositoriesController.new
37 @controller = RepositoriesController.new
36 @request = ActionController::TestRequest.new
38 @request = ActionController::TestRequest.new
37 @response = ActionController::TestResponse.new
39 @response = ActionController::TestResponse.new
38 User.current = nil
40 User.current = nil
39 @repository = Repository::Mercurial.create(
41 @repository = Repository::Mercurial.create(
40 :project => Project.find(PRJ_ID),
42 :project => Project.find(PRJ_ID),
41 :url => REPOSITORY_PATH,
43 :url => REPOSITORY_PATH,
42 :path_encoding => 'ISO-8859-1'
44 :path_encoding => 'ISO-8859-1'
43 )
45 )
44 assert @repository
46 assert @repository
45 @diff_c_support = true
47 @diff_c_support = true
46 @char_1 = CHAR_1_HEX.dup
48 @char_1 = CHAR_1_HEX.dup
47 @tag_char_1 = "tag-#{CHAR_1_HEX}-00"
49 @tag_char_1 = "tag-#{CHAR_1_HEX}-00"
48 @branch_char_0 = "branch-#{CHAR_1_HEX}-00"
50 @branch_char_0 = "branch-#{CHAR_1_HEX}-00"
49 @branch_char_1 = "branch-#{CHAR_1_HEX}-01"
51 @branch_char_1 = "branch-#{CHAR_1_HEX}-01"
50 if @char_1.respond_to?(:force_encoding)
52 if @char_1.respond_to?(:force_encoding)
51 @char_1.force_encoding('UTF-8')
53 @char_1.force_encoding('UTF-8')
52 @tag_char_1.force_encoding('UTF-8')
54 @tag_char_1.force_encoding('UTF-8')
53 @branch_char_0.force_encoding('UTF-8')
55 @branch_char_0.force_encoding('UTF-8')
54 @branch_char_1.force_encoding('UTF-8')
56 @branch_char_1.force_encoding('UTF-8')
55 end
57 end
56 end
58 end
57
59
58 if ruby19_non_utf8_pass
60 if ruby19_non_utf8_pass
59 puts "TODO: Mercurial functional test fails in Ruby 1.9 " +
61 puts "TODO: Mercurial functional test fails in Ruby 1.9 " +
60 "and Encoding.default_external is not UTF-8. " +
62 "and Encoding.default_external is not UTF-8. " +
61 "Current value is '#{Encoding.default_external.to_s}'"
63 "Current value is '#{Encoding.default_external.to_s}'"
62 def test_fake; assert true end
64 def test_fake; assert true end
63 elsif File.directory?(REPOSITORY_PATH)
65 elsif File.directory?(REPOSITORY_PATH)
64 def test_show_root
66 def test_show_root
65 @repository.fetch_changesets
67 @repository.fetch_changesets
66 @repository.reload
68 @repository.reload
67 get :show, :id => PRJ_ID
69 get :show, :id => PRJ_ID
68 assert_response :success
70 assert_response :success
69 assert_template 'show'
71 assert_template 'show'
70 assert_not_nil assigns(:entries)
72 assert_not_nil assigns(:entries)
71 assert_equal 4, assigns(:entries).size
73 assert_equal 4, assigns(:entries).size
72 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
74 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
73 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
75 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
74 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
76 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
75 assert_not_nil assigns(:changesets)
77 assert_not_nil assigns(:changesets)
76 assigns(:changesets).size > 0
78 assigns(:changesets).size > 0
77 end
79 end
78
80
79 def test_show_directory
81 def test_show_directory
80 @repository.fetch_changesets
82 @repository.fetch_changesets
81 @repository.reload
83 @repository.reload
82 get :show, :id => PRJ_ID, :path => ['images']
84 get :show, :id => PRJ_ID, :path => ['images']
83 assert_response :success
85 assert_response :success
84 assert_template 'show'
86 assert_template 'show'
85 assert_not_nil assigns(:entries)
87 assert_not_nil assigns(:entries)
86 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
88 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
87 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
89 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
88 assert_not_nil entry
90 assert_not_nil entry
89 assert_equal 'file', entry.kind
91 assert_equal 'file', entry.kind
90 assert_equal 'images/edit.png', entry.path
92 assert_equal 'images/edit.png', entry.path
91 assert_not_nil assigns(:changesets)
93 assert_not_nil assigns(:changesets)
92 assigns(:changesets).size > 0
94 assigns(:changesets).size > 0
93 end
95 end
94
96
95 def test_show_at_given_revision
97 def test_show_at_given_revision
96 @repository.fetch_changesets
98 @repository.fetch_changesets
97 @repository.reload
99 @repository.reload
98 [0, '0', '0885933ad4f6'].each do |r1|
100 [0, '0', '0885933ad4f6'].each do |r1|
99 get :show, :id => PRJ_ID, :path => ['images'], :rev => r1
101 get :show, :id => PRJ_ID, :path => ['images'], :rev => r1
100 assert_response :success
102 assert_response :success
101 assert_template 'show'
103 assert_template 'show'
102 assert_not_nil assigns(:entries)
104 assert_not_nil assigns(:entries)
103 assert_equal ['delete.png'], assigns(:entries).collect(&:name)
105 assert_equal ['delete.png'], assigns(:entries).collect(&:name)
104 assert_not_nil assigns(:changesets)
106 assert_not_nil assigns(:changesets)
105 assigns(:changesets).size > 0
107 assigns(:changesets).size > 0
106 end
108 end
107 end
109 end
108
110
109 def test_show_directory_sql_escape_percent
111 def test_show_directory_sql_escape_percent
110 @repository.fetch_changesets
112 @repository.fetch_changesets
111 @repository.reload
113 @repository.reload
112 [13, '13', '3a330eb32958'].each do |r1|
114 [13, '13', '3a330eb32958'].each do |r1|
113 get :show, :id => PRJ_ID, :path => ['sql_escape', 'percent%dir'], :rev => r1
115 get :show, :id => PRJ_ID, :path => ['sql_escape', 'percent%dir'],
116 :rev => r1
114 assert_response :success
117 assert_response :success
115 assert_template 'show'
118 assert_template 'show'
116
119
117 assert_not_nil assigns(:entries)
120 assert_not_nil assigns(:entries)
118 assert_equal ['percent%file1.txt', 'percentfile1.txt'], assigns(:entries).collect(&:name)
121 assert_equal ['percent%file1.txt', 'percentfile1.txt'],
122 assigns(:entries).collect(&:name)
119 changesets = assigns(:changesets)
123 changesets = assigns(:changesets)
120 assert_not_nil changesets
124 assert_not_nil changesets
121 assigns(:changesets).size > 0
125 assigns(:changesets).size > 0
122 assert_equal %w(13 11 10 9), changesets.collect(&:revision)
126 assert_equal %w(13 11 10 9), changesets.collect(&:revision)
123 end
127 end
124 end
128 end
125
129
126 def test_show_directory_latin_1_path
130 def test_show_directory_latin_1_path
127 @repository.fetch_changesets
131 @repository.fetch_changesets
128 @repository.reload
132 @repository.reload
129 [21, '21', 'adf805632193'].each do |r1|
133 [21, '21', 'adf805632193'].each do |r1|
130 get :show, :id => PRJ_ID, :path => ['latin-1-dir'], :rev => r1
134 get :show, :id => PRJ_ID, :path => ['latin-1-dir'], :rev => r1
131 assert_response :success
135 assert_response :success
132 assert_template 'show'
136 assert_template 'show'
133
137
134 assert_not_nil assigns(:entries)
138 assert_not_nil assigns(:entries)
135 assert_equal ["make-latin-1-file.rb",
139 assert_equal ["make-latin-1-file.rb",
136 "test-#{@char_1}-1.txt",
140 "test-#{@char_1}-1.txt",
137 "test-#{@char_1}-2.txt",
141 "test-#{@char_1}-2.txt",
138 "test-#{@char_1}.txt"], assigns(:entries).collect(&:name)
142 "test-#{@char_1}.txt"], assigns(:entries).collect(&:name)
139 changesets = assigns(:changesets)
143 changesets = assigns(:changesets)
140 assert_not_nil changesets
144 assert_not_nil changesets
141 assert_equal %w(21 20 19 18 17), changesets.collect(&:revision)
145 assert_equal %w(21 20 19 18 17), changesets.collect(&:revision)
142 end
146 end
143 end
147 end
144
148
145 def test_show_branch
149 def test_show_branch
146 @repository.fetch_changesets
150 @repository.fetch_changesets
147 @repository.reload
151 @repository.reload
148 [
152 [
149 'default',
153 'default',
150 @branch_char_1,
154 @branch_char_1,
151 'branch (1)[2]&,%.-3_4',
155 'branch (1)[2]&,%.-3_4',
152 @branch_char_0,
156 @branch_char_0,
153 'test_branch.latin-1',
157 'test_branch.latin-1',
154 'test-branch-00',
158 'test-branch-00',
155 ].each do |bra|
159 ].each do |bra|
156 get :show, :id => PRJ_ID, :rev => bra
160 get :show, :id => PRJ_ID, :rev => bra
157 assert_response :success
161 assert_response :success
158 assert_template 'show'
162 assert_template 'show'
159 assert_not_nil assigns(:entries)
163 assert_not_nil assigns(:entries)
160 assert assigns(:entries).size > 0
164 assert assigns(:entries).size > 0
161 assert_not_nil assigns(:changesets)
165 assert_not_nil assigns(:changesets)
162 assigns(:changesets).size > 0
166 assigns(:changesets).size > 0
163 end
167 end
164 end
168 end
165
169
166 def test_show_tag
170 def test_show_tag
167 @repository.fetch_changesets
171 @repository.fetch_changesets
168 @repository.reload
172 @repository.reload
169 [
173 [
170 @tag_char_1,
174 @tag_char_1,
171 'tag_test.00',
175 'tag_test.00',
172 'tag-init-revision'
176 'tag-init-revision'
173 ].each do |tag|
177 ].each do |tag|
174 get :show, :id => PRJ_ID, :rev => tag
178 get :show, :id => PRJ_ID, :rev => tag
175 assert_response :success
179 assert_response :success
176 assert_template 'show'
180 assert_template 'show'
177 assert_not_nil assigns(:entries)
181 assert_not_nil assigns(:entries)
178 assert assigns(:entries).size > 0
182 assert assigns(:entries).size > 0
179 assert_not_nil assigns(:changesets)
183 assert_not_nil assigns(:changesets)
180 assigns(:changesets).size > 0
184 assigns(:changesets).size > 0
181 end
185 end
182 end
186 end
183
187
184 def test_changes
188 def test_changes
185 get :changes, :id => PRJ_ID, :path => ['images', 'edit.png']
189 get :changes, :id => PRJ_ID, :path => ['images', 'edit.png']
186 assert_response :success
190 assert_response :success
187 assert_template 'changes'
191 assert_template 'changes'
188 assert_tag :tag => 'h2', :content => 'edit.png'
192 assert_tag :tag => 'h2', :content => 'edit.png'
189 end
193 end
190
194
191 def test_entry_show
195 def test_entry_show
192 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
196 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
193 assert_response :success
197 assert_response :success
194 assert_template 'entry'
198 assert_template 'entry'
195 # Line 10
199 # Line 10
196 assert_tag :tag => 'th',
200 assert_tag :tag => 'th',
197 :content => '10',
201 :content => '10',
198 :attributes => { :class => 'line-num' },
202 :attributes => { :class => 'line-num' },
199 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
203 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
200 end
204 end
201
205
202 def test_entry_show_latin_1_path
206 def test_entry_show_latin_1_path
203 [21, '21', 'adf805632193'].each do |r1|
207 [21, '21', 'adf805632193'].each do |r1|
204 get :entry, :id => PRJ_ID,
208 get :entry, :id => PRJ_ID,
205 :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
209 :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
206 assert_response :success
210 assert_response :success
207 assert_template 'entry'
211 assert_template 'entry'
208 assert_tag :tag => 'th',
212 assert_tag :tag => 'th',
209 :content => '1',
213 :content => '1',
210 :attributes => { :class => 'line-num' },
214 :attributes => { :class => 'line-num' },
211 :sibling => { :tag => 'td',
215 :sibling => { :tag => 'td',
212 :content => /Mercurial is a distributed version control system/ }
216 :content => /Mercurial is a distributed version control system/ }
213 end
217 end
214 end
218 end
215
219
216 def test_entry_download
220 def test_entry_download
217 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
221 get :entry, :id => PRJ_ID,
222 :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
218 assert_response :success
223 assert_response :success
219 # File content
224 # File content
220 assert @response.body.include?('WITHOUT ANY WARRANTY')
225 assert @response.body.include?('WITHOUT ANY WARRANTY')
221 end
226 end
222
227
223 def test_entry_binary_force_download
228 def test_entry_binary_force_download
224 get :entry, :id => PRJ_ID, :rev => 1, :path => ['images', 'edit.png']
229 get :entry, :id => PRJ_ID, :rev => 1, :path => ['images', 'edit.png']
225 assert_response :success
230 assert_response :success
226 assert_equal 'image/png', @response.content_type
231 assert_equal 'image/png', @response.content_type
227 end
232 end
228
233
229 def test_directory_entry
234 def test_directory_entry
230 get :entry, :id => PRJ_ID, :path => ['sources']
235 get :entry, :id => PRJ_ID, :path => ['sources']
231 assert_response :success
236 assert_response :success
232 assert_template 'show'
237 assert_template 'show'
233 assert_not_nil assigns(:entry)
238 assert_not_nil assigns(:entry)
234 assert_equal 'sources', assigns(:entry).name
239 assert_equal 'sources', assigns(:entry).name
235 end
240 end
236
241
237 def test_diff
242 def test_diff
238 @repository.fetch_changesets
243 @repository.fetch_changesets
239 @repository.reload
244 @repository.reload
240 [4, '4', 'def6d2f1254a'].each do |r1|
245 [4, '4', 'def6d2f1254a'].each do |r1|
241 # Full diff of changeset 4
246 # Full diff of changeset 4
242 get :diff, :id => PRJ_ID, :rev => r1
247 get :diff, :id => PRJ_ID, :rev => r1
243 assert_response :success
248 assert_response :success
244 assert_template 'diff'
249 assert_template 'diff'
245 if @diff_c_support
250 if @diff_c_support
246 # Line 22 removed
251 # Line 22 removed
247 assert_tag :tag => 'th',
252 assert_tag :tag => 'th',
248 :content => '22',
253 :content => '22',
249 :sibling => { :tag => 'td',
254 :sibling => { :tag => 'td',
250 :attributes => { :class => /diff_out/ },
255 :attributes => { :class => /diff_out/ },
251 :content => /def remove/ }
256 :content => /def remove/ }
252 assert_tag :tag => 'h2', :content => /4:def6d2f1254a/
257 assert_tag :tag => 'h2', :content => /4:def6d2f1254a/
253 end
258 end
254 end
259 end
255 end
260 end
256
261
257 def test_diff_two_revs
262 def test_diff_two_revs
258 @repository.fetch_changesets
263 @repository.fetch_changesets
259 @repository.reload
264 @repository.reload
260 [2, '400bb8672109', '400', 400].each do |r1|
265 [2, '400bb8672109', '400', 400].each do |r1|
261 [4, 'def6d2f1254a'].each do |r2|
266 [4, 'def6d2f1254a'].each do |r2|
262 get :diff, :id => PRJ_ID, :rev => r1,
267 get :diff, :id => PRJ_ID, :rev => r1,
263 :rev_to => r2
268 :rev_to => r2
264 assert_response :success
269 assert_response :success
265 assert_template 'diff'
270 assert_template 'diff'
266
271
267 diff = assigns(:diff)
272 diff = assigns(:diff)
268 assert_not_nil diff
273 assert_not_nil diff
269 assert_tag :tag => 'h2', :content => /4:def6d2f1254a 2:400bb8672109/
274 assert_tag :tag => 'h2', :content => /4:def6d2f1254a 2:400bb8672109/
270 end
275 end
271 end
276 end
272 end
277 end
273
278
274 def test_diff_latin_1_path
279 def test_diff_latin_1_path
275 [21, 'adf805632193'].each do |r1|
280 [21, 'adf805632193'].each do |r1|
276 get :diff, :id => PRJ_ID, :rev => r1
281 get :diff, :id => PRJ_ID, :rev => r1
277 assert_response :success
282 assert_response :success
278 assert_template 'diff'
283 assert_template 'diff'
279 assert_tag :tag => 'th',
284 assert_tag :tag => 'th',
280 :content => '2',
285 :content => '2',
281 :sibling => {:tag => 'td',
286 :sibling => {:tag => 'td',
282 :attributes => { :class => /diff_in/ },
287 :attributes => { :class => /diff_in/ },
283 :content => /It is written in Python/ }
288 :content => /It is written in Python/ }
284 end
289 end
285 end
290 end
286
291
287 def test_annotate
292 def test_annotate
288 get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
293 get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
289 assert_response :success
294 assert_response :success
290 assert_template 'annotate'
295 assert_template 'annotate'
291 # Line 23, revision 4:def6d2f1254a
296 # Line 23, revision 4:def6d2f1254a
292 assert_tag :tag => 'th',
297 assert_tag :tag => 'th',
293 :content => '23',
298 :content => '23',
294 :attributes => { :class => 'line-num' },
299 :attributes => { :class => 'line-num' },
295 :sibling =>
300 :sibling =>
296 {
301 {
297 :tag => 'td',
302 :tag => 'td',
298 :attributes => { :class => 'revision' },
303 :attributes => { :class => 'revision' },
299 :child => { :tag => 'a', :content => '4:def6d2f1254a' }
304 :child => { :tag => 'a', :content => '4:def6d2f1254a' }
300 }
305 }
301 assert_tag :tag => 'th',
306 assert_tag :tag => 'th',
302 :content => '23',
307 :content => '23',
303 :attributes => { :class => 'line-num' },
308 :attributes => { :class => 'line-num' },
304 :sibling =>
309 :sibling =>
305 {
310 {
306 :tag => 'td' ,
311 :tag => 'td' ,
307 :content => 'jsmith' ,
312 :content => 'jsmith' ,
308 :attributes => { :class => 'author' },
313 :attributes => { :class => 'author' },
309 }
314 }
310 assert_tag :tag => 'th',
315 assert_tag :tag => 'th',
311 :content => '23',
316 :content => '23',
312 :attributes => { :class => 'line-num' },
317 :attributes => { :class => 'line-num' },
313 :sibling => { :tag => 'td', :content => /watcher =/ }
318 :sibling => { :tag => 'td', :content => /watcher =/ }
314 end
319 end
315
320
316 def test_annotate_at_given_revision
321 def test_annotate_at_given_revision
317 @repository.fetch_changesets
322 @repository.fetch_changesets
318 @repository.reload
323 @repository.reload
319 [2, '400bb8672109', '400', 400].each do |r1|
324 [2, '400bb8672109', '400', 400].each do |r1|
320 get :annotate, :id => PRJ_ID, :rev => r1, :path => ['sources', 'watchers_controller.rb']
325 get :annotate, :id => PRJ_ID, :rev => r1,
326 :path => ['sources', 'watchers_controller.rb']
321 assert_response :success
327 assert_response :success
322 assert_template 'annotate'
328 assert_template 'annotate'
323 assert_tag :tag => 'h2', :content => /@ 2:400bb8672109/
329 assert_tag :tag => 'h2', :content => /@ 2:400bb8672109/
324 end
330 end
325 end
331 end
326
332
327 def test_annotate_latin_1_path
333 def test_annotate_latin_1_path
328 [21, '21', 'adf805632193'].each do |r1|
334 [21, '21', 'adf805632193'].each do |r1|
329 get :annotate, :id => PRJ_ID,
335 get :annotate, :id => PRJ_ID,
330 :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
336 :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
331 assert_response :success
337 assert_response :success
332 assert_template 'annotate'
338 assert_template 'annotate'
333 assert_tag :tag => 'th',
339 assert_tag :tag => 'th',
334 :content => '1',
340 :content => '1',
335 :attributes => { :class => 'line-num' },
341 :attributes => { :class => 'line-num' },
336 :sibling =>
342 :sibling =>
337 {
343 {
338 :tag => 'td',
344 :tag => 'td',
339 :attributes => { :class => 'revision' },
345 :attributes => { :class => 'revision' },
340 :child => { :tag => 'a', :content => '20:709858aafd1b' }
346 :child => { :tag => 'a', :content => '20:709858aafd1b' }
341 }
347 }
342 assert_tag :tag => 'th',
348 assert_tag :tag => 'th',
343 :content => '1',
349 :content => '1',
344 :attributes => { :class => 'line-num' },
350 :attributes => { :class => 'line-num' },
345 :sibling =>
351 :sibling =>
346 {
352 {
347 :tag => 'td' ,
353 :tag => 'td' ,
348 :content => 'jsmith' ,
354 :content => 'jsmith' ,
349 :attributes => { :class => 'author' },
355 :attributes => { :class => 'author' },
350 }
356 }
351 assert_tag :tag => 'th',
357 assert_tag :tag => 'th',
352 :content => '1',
358 :content => '1',
353 :attributes => { :class => 'line-num' },
359 :attributes => { :class => 'line-num' },
354 :sibling => { :tag => 'td',
360 :sibling => { :tag => 'td',
355 :content => /Mercurial is a distributed version control system/ }
361 :content => /Mercurial is a distributed version control system/ }
356
362
357 end
363 end
358 end
364 end
359
365
360 def test_empty_revision
366 def test_empty_revision
361 @repository.fetch_changesets
367 @repository.fetch_changesets
362 @repository.reload
368 @repository.reload
363 ['', ' ', nil].each do |r|
369 ['', ' ', nil].each do |r|
364 get :revision, :id => PRJ_ID, :rev => r
370 get :revision, :id => PRJ_ID, :rev => r
365 assert_response 404
371 assert_response 404
366 assert_error_tag :content => /was not found/
372 assert_error_tag :content => /was not found/
367 end
373 end
368 end
374 end
369 else
375 else
370 puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!"
376 puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!"
371 def test_fake; assert true end
377 def test_fake; assert true end
372 end
378 end
373 end
379 end
General Comments 0
You need to be logged in to leave comments. Login now