##// 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 28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
29 29 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
30 30 PRJ_ID = 3
31 CHAR_1_HEX = "\xc3\x9c"
31 32
32 33 def setup
34 @ruby19_non_utf8_pass =
35 (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8')
36
33 37 @controller = RepositoriesController.new
34 38 @request = ActionController::TestRequest.new
35 39 @response = ActionController::TestResponse.new
@@ -40,6 +44,10 class RepositoriesGitControllerTest < ActionController::TestCase
40 44 :path_encoding => 'ISO-8859-1'
41 45 )
42 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 51 end
44 52
45 53 if File.directory?(REPOSITORY_PATH)
@@ -144,6 +152,26 class RepositoriesGitControllerTest < ActionController::TestCase
144 152 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
145 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 175 def test_entry_download
148 176 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'],
149 177 :format => 'raw'
@@ -250,6 +278,14 class RepositoriesGitControllerTest < ActionController::TestCase
250 278 assert_error_tag :content => /was not found/
251 279 end
252 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 289 else
254 290 puts "Git test repository NOT FOUND. Skipping functional tests !!!"
255 291 def test_fake; assert true end
General Comments 0
You need to be logged in to leave comments. Login now