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