##// END OF EJS Templates
scm: mercurial: use constant for project id in functional test....
Toshi MARUYAMA -
r5081:d5ee82cea91e
parent child
Show More
@@ -27,6 +27,7 class RepositoriesMercurialControllerTest < ActionController::TestCase
27 27 # No '..' in the repository path
28 28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
29 29 CHAR_1_HEX = "\xc3\x9c"
30 PRJ_ID = 3
30 31
31 32 ruby19_non_utf8_pass = (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8')
32 33
@@ -36,7 +37,7 class RepositoriesMercurialControllerTest < ActionController::TestCase
36 37 @response = ActionController::TestResponse.new
37 38 User.current = nil
38 39 @repository = Repository::Mercurial.create(
39 :project => Project.find(3),
40 :project => Project.find(PRJ_ID),
40 41 :url => REPOSITORY_PATH,
41 42 :path_encoding => 'ISO-8859-1'
42 43 )
@@ -63,7 +64,7 class RepositoriesMercurialControllerTest < ActionController::TestCase
63 64 def test_show_root
64 65 @repository.fetch_changesets
65 66 @repository.reload
66 get :show, :id => 3
67 get :show, :id => PRJ_ID
67 68 assert_response :success
68 69 assert_template 'show'
69 70 assert_not_nil assigns(:entries)
@@ -78,7 +79,7 class RepositoriesMercurialControllerTest < ActionController::TestCase
78 79 def test_show_directory
79 80 @repository.fetch_changesets
80 81 @repository.reload
81 get :show, :id => 3, :path => ['images']
82 get :show, :id => PRJ_ID, :path => ['images']
82 83 assert_response :success
83 84 assert_template 'show'
84 85 assert_not_nil assigns(:entries)
@@ -95,7 +96,7 class RepositoriesMercurialControllerTest < ActionController::TestCase
95 96 @repository.fetch_changesets
96 97 @repository.reload
97 98 [0, '0', '0885933ad4f6'].each do |r1|
98 get :show, :id => 3, :path => ['images'], :rev => r1
99 get :show, :id => PRJ_ID, :path => ['images'], :rev => r1
99 100 assert_response :success
100 101 assert_template 'show'
101 102 assert_not_nil assigns(:entries)
@@ -109,7 +110,7 class RepositoriesMercurialControllerTest < ActionController::TestCase
109 110 @repository.fetch_changesets
110 111 @repository.reload
111 112 [13, '13', '3a330eb32958'].each do |r1|
112 get :show, :id => 3, :path => ['sql_escape', 'percent%dir'], :rev => r1
113 get :show, :id => PRJ_ID, :path => ['sql_escape', 'percent%dir'], :rev => r1
113 114 assert_response :success
114 115 assert_template 'show'
115 116
@@ -126,7 +127,7 class RepositoriesMercurialControllerTest < ActionController::TestCase
126 127 @repository.fetch_changesets
127 128 @repository.reload
128 129 [21, '21', 'adf805632193'].each do |r1|
129 get :show, :id => 3, :path => ['latin-1-dir'], :rev => r1
130 get :show, :id => PRJ_ID, :path => ['latin-1-dir'], :rev => r1
130 131 assert_response :success
131 132 assert_template 'show'
132 133
@@ -152,7 +153,7 class RepositoriesMercurialControllerTest < ActionController::TestCase
152 153 'test_branch.latin-1',
153 154 'test-branch-00',
154 155 ].each do |bra|
155 get :show, :id => 3, :rev => bra
156 get :show, :id => PRJ_ID, :rev => bra
156 157 assert_response :success
157 158 assert_template 'show'
158 159 assert_not_nil assigns(:entries)
@@ -170,7 +171,7 class RepositoriesMercurialControllerTest < ActionController::TestCase
170 171 'tag_test.00',
171 172 'tag-init-revision'
172 173 ].each do |tag|
173 get :show, :id => 3, :rev => tag
174 get :show, :id => PRJ_ID, :rev => tag
174 175 assert_response :success
175 176 assert_template 'show'
176 177 assert_not_nil assigns(:entries)
@@ -181,14 +182,14 class RepositoriesMercurialControllerTest < ActionController::TestCase
181 182 end
182 183
183 184 def test_changes
184 get :changes, :id => 3, :path => ['images', 'edit.png']
185 get :changes, :id => PRJ_ID, :path => ['images', 'edit.png']
185 186 assert_response :success
186 187 assert_template 'changes'
187 188 assert_tag :tag => 'h2', :content => 'edit.png'
188 189 end
189 190
190 191 def test_entry_show
191 get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb']
192 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
192 193 assert_response :success
193 194 assert_template 'entry'
194 195 # Line 10
@@ -200,25 +201,26 class RepositoriesMercurialControllerTest < ActionController::TestCase
200 201
201 202 def test_entry_show_latin_1
202 203 [21, '21', 'adf805632193'].each do |r1|
203 get :entry, :id => 3, :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
204 get :entry, :id => PRJ_ID, :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
204 205 assert_response :success
205 206 assert_template 'entry'
206 207 assert_tag :tag => 'th',
207 208 :content => '1',
208 209 :attributes => { :class => 'line-num' },
209 :sibling => { :tag => 'td', :content => /Mercurial is a distributed version control system/ }
210 :sibling => { :tag => 'td',
211 :content => /Mercurial is a distributed version control system/ }
210 212 end
211 213 end
212 214
213 215 def test_entry_download
214 get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
216 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
215 217 assert_response :success
216 218 # File content
217 219 assert @response.body.include?('WITHOUT ANY WARRANTY')
218 220 end
219 221
220 222 def test_directory_entry
221 get :entry, :id => 3, :path => ['sources']
223 get :entry, :id => PRJ_ID, :path => ['sources']
222 224 assert_response :success
223 225 assert_template 'show'
224 226 assert_not_nil assigns(:entry)
@@ -228,13 +230,11 class RepositoriesMercurialControllerTest < ActionController::TestCase
228 230 def test_diff
229 231 @repository.fetch_changesets
230 232 @repository.reload
231
232 233 [4, '4', 'def6d2f1254a'].each do |r1|
233 234 # Full diff of changeset 4
234 get :diff, :id => 3, :rev => r1
235 get :diff, :id => PRJ_ID, :rev => r1
235 236 assert_response :success
236 237 assert_template 'diff'
237
238 238 if @diff_c_support
239 239 # Line 22 removed
240 240 assert_tag :tag => 'th',
@@ -250,10 +250,9 class RepositoriesMercurialControllerTest < ActionController::TestCase
250 250 def test_diff_two_revs
251 251 @repository.fetch_changesets
252 252 @repository.reload
253
254 253 [2, '400bb8672109', '400', 400].each do |r1|
255 254 [4, 'def6d2f1254a'].each do |r2|
256 get :diff, :id => 3, :rev => r1,
255 get :diff, :id => PRJ_ID, :rev => r1,
257 256 :rev_to => r2
258 257 assert_response :success
259 258 assert_template 'diff'
@@ -267,7 +266,7 class RepositoriesMercurialControllerTest < ActionController::TestCase
267 266
268 267 def test_diff_latin_1
269 268 [21, 'adf805632193'].each do |r1|
270 get :diff, :id => 3, :rev => r1
269 get :diff, :id => PRJ_ID, :rev => r1
271 270 assert_response :success
272 271 assert_template 'diff'
273 272 assert_tag :tag => 'th',
@@ -279,7 +278,7 class RepositoriesMercurialControllerTest < ActionController::TestCase
279 278 end
280 279
281 280 def test_annotate
282 get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb']
281 get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
283 282 assert_response :success
284 283 assert_template 'annotate'
285 284 # Line 23, revision 4:def6d2f1254a
@@ -311,7 +310,7 class RepositoriesMercurialControllerTest < ActionController::TestCase
311 310 @repository.fetch_changesets
312 311 @repository.reload
313 312 [2, '400bb8672109', '400', 400].each do |r1|
314 get :annotate, :id => 3, :rev => r1, :path => ['sources', 'watchers_controller.rb']
313 get :annotate, :id => PRJ_ID, :rev => r1, :path => ['sources', 'watchers_controller.rb']
315 314 assert_response :success
316 315 assert_template 'annotate'
317 316 assert_tag :tag => 'h2', :content => /@ 2:400bb8672109/
@@ -320,7 +319,7 class RepositoriesMercurialControllerTest < ActionController::TestCase
320 319
321 320 def test_annotate_latin_1
322 321 [21, '21', 'adf805632193'].each do |r1|
323 get :annotate, :id => 3, :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
322 get :annotate, :id => PRJ_ID, :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
324 323 assert_response :success
325 324 assert_template 'annotate'
326 325 assert_tag :tag => 'th',
@@ -345,7 +344,8 class RepositoriesMercurialControllerTest < ActionController::TestCase
345 344 assert_tag :tag => 'th',
346 345 :content => '1',
347 346 :attributes => { :class => 'line-num' },
348 :sibling => { :tag => 'td', :content => /Mercurial is a distributed version control system/ }
347 :sibling => { :tag => 'td',
348 :content => /Mercurial is a distributed version control system/ }
349 349
350 350 end
351 351 end
@@ -354,7 +354,7 class RepositoriesMercurialControllerTest < ActionController::TestCase
354 354 @repository.fetch_changesets
355 355 @repository.reload
356 356 ['', ' ', nil].each do |r|
357 get :revision, :id => 3, :rev => r
357 get :revision, :id => PRJ_ID, :rev => r
358 358 assert_response 404
359 359 assert_error_tag :content => /was not found/
360 360 end
General Comments 0
You need to be logged in to leave comments. Login now