##// END OF EJS Templates
scm: git: add test of showing non ASCII contents of non ASCII path in functional test....
Toshi MARUYAMA -
r5577:6eb8b5fb4a4a
parent child
Show More
@@ -28,8 +28,12 class RepositoriesGitControllerTest < ActionController::TestCase
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
32
32 def setup
33 def setup
34 @ruby19_non_utf8_pass =
35 (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8')
36
33 @controller = RepositoriesController.new
37 @controller = RepositoriesController.new
34 @request = ActionController::TestRequest.new
38 @request = ActionController::TestRequest.new
35 @response = ActionController::TestResponse.new
39 @response = ActionController::TestResponse.new
@@ -40,6 +44,10 class RepositoriesGitControllerTest < ActionController::TestCase
40 :path_encoding => 'ISO-8859-1'
44 :path_encoding => 'ISO-8859-1'
41 )
45 )
42 assert @repository
46 assert @repository
47 @char_1 = CHAR_1_HEX.dup
48 if @char_1.respond_to?(:force_encoding)
49 @char_1.force_encoding('UTF-8')
50 end
43 end
51 end
44
52
45 if File.directory?(REPOSITORY_PATH)
53 if File.directory?(REPOSITORY_PATH)
@@ -144,6 +152,26 class RepositoriesGitControllerTest < ActionController::TestCase
144 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
152 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
145 end
153 end
146
154
155 def test_entry_show_latin_1
156 if @ruby19_non_utf8_pass
157 puts_ruby19_non_utf8_pass()
158 else
159 with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
160 ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
161 get :entry, :id => PRJ_ID,
162 :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1
163 assert_response :success
164 assert_template 'entry'
165 assert_tag :tag => 'th',
166 :content => '1',
167 :attributes => { :class => 'line-num' },
168 :sibling => { :tag => 'td',
169 :content => /test-#{@char_1}.txt/ }
170 end
171 end
172 end
173 end
174
147 def test_entry_download
175 def test_entry_download
148 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'],
176 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'],
149 :format => 'raw'
177 :format => 'raw'
@@ -250,6 +278,14 class RepositoriesGitControllerTest < ActionController::TestCase
250 assert_error_tag :content => /was not found/
278 assert_error_tag :content => /was not found/
251 end
279 end
252 end
280 end
281
282 private
283
284 def puts_ruby19_non_utf8_pass
285 puts "TODO: This test fails in Ruby 1.9 " +
286 "and Encoding.default_external is not UTF-8. " +
287 "Current value is '#{Encoding.default_external.to_s}'"
288 end
253 else
289 else
254 puts "Git test repository NOT FOUND. Skipping functional tests !!!"
290 puts "Git test repository NOT FOUND. Skipping functional tests !!!"
255 def test_fake; assert true end
291 def test_fake; assert true end
General Comments 0
You need to be logged in to leave comments. Login now