##// END OF EJS Templates
scm: git: add missing "assert" changesets and entries size at functional test....
Toshi MARUYAMA -
r6102:c8ec7820db6b
parent child
Show More
@@ -1,395 +1,395
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 RepositoriesGitControllerTest < ActionController::TestCase
24 class RepositoriesGitControllerTest < 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/git_repository').to_s
28 REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
29 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
29 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
30 PRJ_ID = 3
30 PRJ_ID = 3
31 CHAR_1_HEX = "\xc3\x9c"
31 CHAR_1_HEX = "\xc3\x9c"
32
32
33 ## Git, Mercurial and CVS path encodings are binary.
33 ## Git, Mercurial and CVS path encodings are binary.
34 ## Subversion supports URL encoding for path.
34 ## Subversion supports URL encoding for path.
35 ## Redmine Mercurial adapter and extension use URL encoding.
35 ## Redmine Mercurial adapter and extension use URL encoding.
36 ## Git accepts only binary path in command line parameter.
36 ## Git accepts only binary path in command line parameter.
37 ## So, there is no way to use binary command line parameter in JRuby.
37 ## So, there is no way to use binary command line parameter in JRuby.
38 JRUBY_SKIP = (RUBY_PLATFORM == 'java')
38 JRUBY_SKIP = (RUBY_PLATFORM == 'java')
39 JRUBY_SKIP_STR = "TODO: This test fails in JRuby"
39 JRUBY_SKIP_STR = "TODO: This test fails in JRuby"
40
40
41 def setup
41 def setup
42 @ruby19_non_utf8_pass =
42 @ruby19_non_utf8_pass =
43 (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8')
43 (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8')
44
44
45 @controller = RepositoriesController.new
45 @controller = RepositoriesController.new
46 @request = ActionController::TestRequest.new
46 @request = ActionController::TestRequest.new
47 @response = ActionController::TestResponse.new
47 @response = ActionController::TestResponse.new
48 User.current = nil
48 User.current = nil
49 @repository = Repository::Git.create(
49 @repository = Repository::Git.create(
50 :project => Project.find(3),
50 :project => Project.find(3),
51 :url => REPOSITORY_PATH,
51 :url => REPOSITORY_PATH,
52 :path_encoding => 'ISO-8859-1'
52 :path_encoding => 'ISO-8859-1'
53 )
53 )
54 assert @repository
54 assert @repository
55 @char_1 = CHAR_1_HEX.dup
55 @char_1 = CHAR_1_HEX.dup
56 if @char_1.respond_to?(:force_encoding)
56 if @char_1.respond_to?(:force_encoding)
57 @char_1.force_encoding('UTF-8')
57 @char_1.force_encoding('UTF-8')
58 end
58 end
59
59
60 Setting.default_language = 'en'
60 Setting.default_language = 'en'
61 end
61 end
62
62
63 if File.directory?(REPOSITORY_PATH)
63 if File.directory?(REPOSITORY_PATH)
64 def test_browse_root
64 def test_browse_root
65 @repository.fetch_changesets
65 @repository.fetch_changesets
66 @repository.reload
66 @repository.reload
67 get :show, :id => PRJ_ID
67 get :show, :id => PRJ_ID
68 assert_response :success
68 assert_response :success
69 assert_template 'show'
69 assert_template 'show'
70 assert_not_nil assigns(:entries)
70 assert_not_nil assigns(:entries)
71 assert_equal 9, assigns(:entries).size
71 assert_equal 9, assigns(:entries).size
72 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
72 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
73 assert assigns(:entries).detect {|e| e.name == 'this_is_a_really_long_and_verbose_directory_name' && e.kind == 'dir'}
73 assert assigns(:entries).detect {|e| e.name == 'this_is_a_really_long_and_verbose_directory_name' && 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 assigns(:entries).detect {|e| e.name == 'copied_README' && e.kind == 'file'}
76 assert assigns(:entries).detect {|e| e.name == 'copied_README' && e.kind == 'file'}
77 assert assigns(:entries).detect {|e| e.name == 'new_file.txt' && e.kind == 'file'}
77 assert assigns(:entries).detect {|e| e.name == 'new_file.txt' && e.kind == 'file'}
78 assert assigns(:entries).detect {|e| e.name == 'renamed_test.txt' && e.kind == 'file'}
78 assert assigns(:entries).detect {|e| e.name == 'renamed_test.txt' && e.kind == 'file'}
79 assert assigns(:entries).detect {|e| e.name == 'filemane with spaces.txt' && e.kind == 'file'}
79 assert assigns(:entries).detect {|e| e.name == 'filemane with spaces.txt' && e.kind == 'file'}
80 assert assigns(:entries).detect {|e| e.name == ' filename with a leading space.txt ' && e.kind == 'file'}
80 assert assigns(:entries).detect {|e| e.name == ' filename with a leading space.txt ' && e.kind == 'file'}
81 assert_not_nil assigns(:changesets)
81 assert_not_nil assigns(:changesets)
82 assigns(:changesets).size > 0
82 assert assigns(:changesets).size > 0
83 end
83 end
84
84
85 def test_browse_branch
85 def test_browse_branch
86 @repository.fetch_changesets
86 @repository.fetch_changesets
87 @repository.reload
87 @repository.reload
88 get :show, :id => PRJ_ID, :rev => 'test_branch'
88 get :show, :id => PRJ_ID, :rev => 'test_branch'
89 assert_response :success
89 assert_response :success
90 assert_template 'show'
90 assert_template 'show'
91 assert_not_nil assigns(:entries)
91 assert_not_nil assigns(:entries)
92 assert_equal 4, assigns(:entries).size
92 assert_equal 4, assigns(:entries).size
93 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
93 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
94 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
94 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
95 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
95 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
96 assert assigns(:entries).detect {|e| e.name == 'test.txt' && e.kind == 'file'}
96 assert assigns(:entries).detect {|e| e.name == 'test.txt' && e.kind == 'file'}
97 assert_not_nil assigns(:changesets)
97 assert_not_nil assigns(:changesets)
98 assigns(:changesets).size > 0
98 assert assigns(:changesets).size > 0
99 end
99 end
100
100
101 def test_browse_tag
101 def test_browse_tag
102 @repository.fetch_changesets
102 @repository.fetch_changesets
103 @repository.reload
103 @repository.reload
104 [
104 [
105 "tag00.lightweight",
105 "tag00.lightweight",
106 "tag01.annotated",
106 "tag01.annotated",
107 ].each do |t1|
107 ].each do |t1|
108 get :show, :id => PRJ_ID, :rev => t1
108 get :show, :id => PRJ_ID, :rev => t1
109 assert_response :success
109 assert_response :success
110 assert_template 'show'
110 assert_template 'show'
111 assert_not_nil assigns(:entries)
111 assert_not_nil assigns(:entries)
112 assigns(:entries).size > 0
112 assert assigns(:entries).size > 0
113 assert_not_nil assigns(:changesets)
113 assert_not_nil assigns(:changesets)
114 assigns(:changesets).size > 0
114 assert assigns(:changesets).size > 0
115 end
115 end
116 end
116 end
117
117
118 def test_browse_directory
118 def test_browse_directory
119 @repository.fetch_changesets
119 @repository.fetch_changesets
120 @repository.reload
120 @repository.reload
121 get :show, :id => PRJ_ID, :path => ['images']
121 get :show, :id => PRJ_ID, :path => ['images']
122 assert_response :success
122 assert_response :success
123 assert_template 'show'
123 assert_template 'show'
124 assert_not_nil assigns(:entries)
124 assert_not_nil assigns(:entries)
125 assert_equal ['edit.png'], assigns(:entries).collect(&:name)
125 assert_equal ['edit.png'], assigns(:entries).collect(&:name)
126 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
126 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
127 assert_not_nil entry
127 assert_not_nil entry
128 assert_equal 'file', entry.kind
128 assert_equal 'file', entry.kind
129 assert_equal 'images/edit.png', entry.path
129 assert_equal 'images/edit.png', entry.path
130 assert_not_nil assigns(:changesets)
130 assert_not_nil assigns(:changesets)
131 assigns(:changesets).size > 0
131 assert assigns(:changesets).size > 0
132 end
132 end
133
133
134 def test_browse_at_given_revision
134 def test_browse_at_given_revision
135 @repository.fetch_changesets
135 @repository.fetch_changesets
136 @repository.reload
136 @repository.reload
137 get :show, :id => PRJ_ID, :path => ['images'],
137 get :show, :id => PRJ_ID, :path => ['images'],
138 :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518'
138 :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518'
139 assert_response :success
139 assert_response :success
140 assert_template 'show'
140 assert_template 'show'
141 assert_not_nil assigns(:entries)
141 assert_not_nil assigns(:entries)
142 assert_equal ['delete.png'], assigns(:entries).collect(&:name)
142 assert_equal ['delete.png'], assigns(:entries).collect(&:name)
143 assert_not_nil assigns(:changesets)
143 assert_not_nil assigns(:changesets)
144 assigns(:changesets).size > 0
144 assert assigns(:changesets).size > 0
145 end
145 end
146
146
147 def test_changes
147 def test_changes
148 get :changes, :id => PRJ_ID, :path => ['images', 'edit.png']
148 get :changes, :id => PRJ_ID, :path => ['images', 'edit.png']
149 assert_response :success
149 assert_response :success
150 assert_template 'changes'
150 assert_template 'changes'
151 assert_tag :tag => 'h2', :content => 'edit.png'
151 assert_tag :tag => 'h2', :content => 'edit.png'
152 end
152 end
153
153
154 def test_entry_show
154 def test_entry_show
155 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
155 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
156 assert_response :success
156 assert_response :success
157 assert_template 'entry'
157 assert_template 'entry'
158 # Line 19
158 # Line 19
159 assert_tag :tag => 'th',
159 assert_tag :tag => 'th',
160 :content => '11',
160 :content => '11',
161 :attributes => { :class => 'line-num' },
161 :attributes => { :class => 'line-num' },
162 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
162 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
163 end
163 end
164
164
165 def test_entry_show_latin_1
165 def test_entry_show_latin_1
166 if @ruby19_non_utf8_pass
166 if @ruby19_non_utf8_pass
167 puts_ruby19_non_utf8_pass()
167 puts_ruby19_non_utf8_pass()
168 elsif JRUBY_SKIP
168 elsif JRUBY_SKIP
169 puts JRUBY_SKIP_STR
169 puts JRUBY_SKIP_STR
170 else
170 else
171 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
171 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
172 ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
172 ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
173 get :entry, :id => PRJ_ID,
173 get :entry, :id => PRJ_ID,
174 :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1
174 :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1
175 assert_response :success
175 assert_response :success
176 assert_template 'entry'
176 assert_template 'entry'
177 assert_tag :tag => 'th',
177 assert_tag :tag => 'th',
178 :content => '1',
178 :content => '1',
179 :attributes => { :class => 'line-num' },
179 :attributes => { :class => 'line-num' },
180 :sibling => { :tag => 'td',
180 :sibling => { :tag => 'td',
181 :content => /test-#{@char_1}.txt/ }
181 :content => /test-#{@char_1}.txt/ }
182 end
182 end
183 end
183 end
184 end
184 end
185 end
185 end
186
186
187 def test_entry_download
187 def test_entry_download
188 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'],
188 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'],
189 :format => 'raw'
189 :format => 'raw'
190 assert_response :success
190 assert_response :success
191 # File content
191 # File content
192 assert @response.body.include?('WITHOUT ANY WARRANTY')
192 assert @response.body.include?('WITHOUT ANY WARRANTY')
193 end
193 end
194
194
195 def test_directory_entry
195 def test_directory_entry
196 get :entry, :id => PRJ_ID, :path => ['sources']
196 get :entry, :id => PRJ_ID, :path => ['sources']
197 assert_response :success
197 assert_response :success
198 assert_template 'show'
198 assert_template 'show'
199 assert_not_nil assigns(:entry)
199 assert_not_nil assigns(:entry)
200 assert_equal 'sources', assigns(:entry).name
200 assert_equal 'sources', assigns(:entry).name
201 end
201 end
202
202
203 def test_diff
203 def test_diff
204 @repository.fetch_changesets
204 @repository.fetch_changesets
205 @repository.reload
205 @repository.reload
206 # Full diff of changeset 2f9c0091
206 # Full diff of changeset 2f9c0091
207 ['inline', 'sbs'].each do |dt|
207 ['inline', 'sbs'].each do |dt|
208 get :diff,
208 get :diff,
209 :id => PRJ_ID,
209 :id => PRJ_ID,
210 :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
210 :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
211 :type => dt
211 :type => dt
212 assert_response :success
212 assert_response :success
213 assert_template 'diff'
213 assert_template 'diff'
214 # Line 22 removed
214 # Line 22 removed
215 assert_tag :tag => 'th',
215 assert_tag :tag => 'th',
216 :content => /22/,
216 :content => /22/,
217 :sibling => { :tag => 'td',
217 :sibling => { :tag => 'td',
218 :attributes => { :class => /diff_out/ },
218 :attributes => { :class => /diff_out/ },
219 :content => /def remove/ }
219 :content => /def remove/ }
220 assert_tag :tag => 'h2', :content => /2f9c0091/
220 assert_tag :tag => 'h2', :content => /2f9c0091/
221 end
221 end
222 end
222 end
223
223
224 def test_diff_truncated
224 def test_diff_truncated
225 @repository.fetch_changesets
225 @repository.fetch_changesets
226 @repository.reload
226 @repository.reload
227 Setting.diff_max_lines_displayed = 5
227 Setting.diff_max_lines_displayed = 5
228
228
229 # Truncated diff of changeset 2f9c0091
229 # Truncated diff of changeset 2f9c0091
230 with_cache do
230 with_cache do
231 get :diff, :id => PRJ_ID, :type => 'inline',
231 get :diff, :id => PRJ_ID, :type => 'inline',
232 :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
232 :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
233 assert_response :success
233 assert_response :success
234 assert @response.body.include?("... This diff was truncated")
234 assert @response.body.include?("... This diff was truncated")
235
235
236 Setting.default_language = 'fr'
236 Setting.default_language = 'fr'
237 get :diff, :id => PRJ_ID, :type => 'inline',
237 get :diff, :id => PRJ_ID, :type => 'inline',
238 :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
238 :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
239 assert_response :success
239 assert_response :success
240 assert ! @response.body.include?("... This diff was truncated")
240 assert ! @response.body.include?("... This diff was truncated")
241 assert @response.body.include?("... Ce diff")
241 assert @response.body.include?("... Ce diff")
242 end
242 end
243 end
243 end
244
244
245 def test_diff_two_revs
245 def test_diff_two_revs
246 @repository.fetch_changesets
246 @repository.fetch_changesets
247 @repository.reload
247 @repository.reload
248 ['inline', 'sbs'].each do |dt|
248 ['inline', 'sbs'].each do |dt|
249 get :diff,
249 get :diff,
250 :id => PRJ_ID,
250 :id => PRJ_ID,
251 :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
251 :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
252 :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
252 :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7',
253 :type => dt
253 :type => dt
254 assert_response :success
254 assert_response :success
255 assert_template 'diff'
255 assert_template 'diff'
256 diff = assigns(:diff)
256 diff = assigns(:diff)
257 assert_not_nil diff
257 assert_not_nil diff
258 assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/
258 assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/
259 end
259 end
260 end
260 end
261
261
262 def test_diff_latin_1
262 def test_diff_latin_1
263 if @ruby19_non_utf8_pass
263 if @ruby19_non_utf8_pass
264 puts_ruby19_non_utf8_pass()
264 puts_ruby19_non_utf8_pass()
265 else
265 else
266 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
266 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
267 ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
267 ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
268 ['inline', 'sbs'].each do |dt|
268 ['inline', 'sbs'].each do |dt|
269 get :diff, :id => PRJ_ID, :rev => r1, :type => dt
269 get :diff, :id => PRJ_ID, :rev => r1, :type => dt
270 assert_response :success
270 assert_response :success
271 assert_template 'diff'
271 assert_template 'diff'
272 assert_tag :tag => 'thead',
272 assert_tag :tag => 'thead',
273 :descendant => {
273 :descendant => {
274 :tag => 'th',
274 :tag => 'th',
275 :attributes => { :class => 'filename' } ,
275 :attributes => { :class => 'filename' } ,
276 :content => /latin-1-dir\/test-#{@char_1}.txt/ ,
276 :content => /latin-1-dir\/test-#{@char_1}.txt/ ,
277 },
277 },
278 :sibling => {
278 :sibling => {
279 :tag => 'tbody',
279 :tag => 'tbody',
280 :descendant => {
280 :descendant => {
281 :tag => 'td',
281 :tag => 'td',
282 :attributes => { :class => /diff_in/ },
282 :attributes => { :class => /diff_in/ },
283 :content => /test-#{@char_1}.txt/
283 :content => /test-#{@char_1}.txt/
284 }
284 }
285 }
285 }
286 end
286 end
287 end
287 end
288 end
288 end
289 end
289 end
290 end
290 end
291
291
292 def test_annotate
292 def test_annotate
293 get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
293 get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
294 assert_response :success
294 assert_response :success
295 assert_template 'annotate'
295 assert_template 'annotate'
296 # Line 24, changeset 2f9c0091
296 # Line 24, changeset 2f9c0091
297 assert_tag :tag => 'th', :content => '24',
297 assert_tag :tag => 'th', :content => '24',
298 :sibling => {
298 :sibling => {
299 :tag => 'td',
299 :tag => 'td',
300 :child => {
300 :child => {
301 :tag => 'a',
301 :tag => 'a',
302 :content => /2f9c0091/
302 :content => /2f9c0091/
303 }
303 }
304 }
304 }
305 assert_tag :tag => 'th', :content => '24',
305 assert_tag :tag => 'th', :content => '24',
306 :sibling => { :tag => 'td', :content => /jsmith/ }
306 :sibling => { :tag => 'td', :content => /jsmith/ }
307 assert_tag :tag => 'th', :content => '24',
307 assert_tag :tag => 'th', :content => '24',
308 :sibling => {
308 :sibling => {
309 :tag => 'td',
309 :tag => 'td',
310 :child => {
310 :child => {
311 :tag => 'a',
311 :tag => 'a',
312 :content => /2f9c0091/
312 :content => /2f9c0091/
313 }
313 }
314 }
314 }
315 assert_tag :tag => 'th', :content => '24',
315 assert_tag :tag => 'th', :content => '24',
316 :sibling => { :tag => 'td', :content => /watcher =/ }
316 :sibling => { :tag => 'td', :content => /watcher =/ }
317 end
317 end
318
318
319 def test_annotate_at_given_revision
319 def test_annotate_at_given_revision
320 @repository.fetch_changesets
320 @repository.fetch_changesets
321 @repository.reload
321 @repository.reload
322 get :annotate, :id => PRJ_ID, :rev => 'deff7',
322 get :annotate, :id => PRJ_ID, :rev => 'deff7',
323 :path => ['sources', 'watchers_controller.rb']
323 :path => ['sources', 'watchers_controller.rb']
324 assert_response :success
324 assert_response :success
325 assert_template 'annotate'
325 assert_template 'annotate'
326 assert_tag :tag => 'h2', :content => /@ deff712f/
326 assert_tag :tag => 'h2', :content => /@ deff712f/
327 end
327 end
328
328
329 def test_annotate_binary_file
329 def test_annotate_binary_file
330 get :annotate, :id => PRJ_ID, :path => ['images', 'edit.png']
330 get :annotate, :id => PRJ_ID, :path => ['images', 'edit.png']
331 assert_response 500
331 assert_response 500
332 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
332 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
333 :content => /cannot be annotated/
333 :content => /cannot be annotated/
334 end
334 end
335
335
336 def test_annotate_latin_1
336 def test_annotate_latin_1
337 if @ruby19_non_utf8_pass
337 if @ruby19_non_utf8_pass
338 puts_ruby19_non_utf8_pass()
338 puts_ruby19_non_utf8_pass()
339 elsif JRUBY_SKIP
339 elsif JRUBY_SKIP
340 puts JRUBY_SKIP_STR
340 puts JRUBY_SKIP_STR
341 else
341 else
342 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
342 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
343 ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
343 ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
344 get :annotate, :id => PRJ_ID,
344 get :annotate, :id => PRJ_ID,
345 :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1
345 :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1
346 assert_tag :tag => 'th',
346 assert_tag :tag => 'th',
347 :content => '1',
347 :content => '1',
348 :attributes => { :class => 'line-num' },
348 :attributes => { :class => 'line-num' },
349 :sibling => { :tag => 'td',
349 :sibling => { :tag => 'td',
350 :content => /test-#{@char_1}.txt/ }
350 :content => /test-#{@char_1}.txt/ }
351 end
351 end
352 end
352 end
353 end
353 end
354 end
354 end
355
355
356 def test_revision
356 def test_revision
357 @repository.fetch_changesets
357 @repository.fetch_changesets
358 @repository.reload
358 @repository.reload
359 ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r|
359 ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r|
360 get :revision, :id => PRJ_ID, :rev => r
360 get :revision, :id => PRJ_ID, :rev => r
361 assert_response :success
361 assert_response :success
362 assert_template 'revision'
362 assert_template 'revision'
363 end
363 end
364 end
364 end
365
365
366 def test_empty_revision
366 def test_empty_revision
367 @repository.fetch_changesets
367 @repository.fetch_changesets
368 @repository.reload
368 @repository.reload
369 ['', ' ', nil].each do |r|
369 ['', ' ', nil].each do |r|
370 get :revision, :id => PRJ_ID, :rev => r
370 get :revision, :id => PRJ_ID, :rev => r
371 assert_response 404
371 assert_response 404
372 assert_error_tag :content => /was not found/
372 assert_error_tag :content => /was not found/
373 end
373 end
374 end
374 end
375
375
376 private
376 private
377
377
378 def puts_ruby19_non_utf8_pass
378 def puts_ruby19_non_utf8_pass
379 puts "TODO: This test fails in Ruby 1.9 " +
379 puts "TODO: This test fails in Ruby 1.9 " +
380 "and Encoding.default_external is not UTF-8. " +
380 "and Encoding.default_external is not UTF-8. " +
381 "Current value is '#{Encoding.default_external.to_s}'"
381 "Current value is '#{Encoding.default_external.to_s}'"
382 end
382 end
383 else
383 else
384 puts "Git test repository NOT FOUND. Skipping functional tests !!!"
384 puts "Git test repository NOT FOUND. Skipping functional tests !!!"
385 def test_fake; assert true end
385 def test_fake; assert true end
386 end
386 end
387
387
388 private
388 private
389 def with_cache(&block)
389 def with_cache(&block)
390 before = ActionController::Base.perform_caching
390 before = ActionController::Base.perform_caching
391 ActionController::Base.perform_caching = true
391 ActionController::Base.perform_caching = true
392 block.call
392 block.call
393 ActionController::Base.perform_caching = before
393 ActionController::Base.perform_caching = before
394 end
394 end
395 end
395 end
General Comments 0
You need to be logged in to leave comments. Login now