From 6eb8b5fb4a4a7d09adabe97fe79be7f4ec811f11 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Sun, 8 May 2011 02:04:11 +0000 Subject: [PATCH] scm: git: add test of showing non ASCII contents of non ASCII path in functional test. TODO: this test fails in Ruby 1.9 and Encoding.default_external is not UTF-8. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5697 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- .../functional/repositories_git_controller_test.rb | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/functional/repositories_git_controller_test.rb b/test/functional/repositories_git_controller_test.rb index a87d8883..c4904f2b 100644 --- a/test/functional/repositories_git_controller_test.rb +++ b/test/functional/repositories_git_controller_test.rb @@ -28,8 +28,12 @@ class RepositoriesGitControllerTest < ActionController::TestCase REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository' REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? PRJ_ID = 3 + CHAR_1_HEX = "\xc3\x9c" def setup + @ruby19_non_utf8_pass = + (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8') + @controller = RepositoriesController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @@ -40,6 +44,10 @@ class RepositoriesGitControllerTest < ActionController::TestCase :path_encoding => 'ISO-8859-1' ) assert @repository + @char_1 = CHAR_1_HEX.dup + if @char_1.respond_to?(:force_encoding) + @char_1.force_encoding('UTF-8') + end end if File.directory?(REPOSITORY_PATH) @@ -144,6 +152,26 @@ class RepositoriesGitControllerTest < ActionController::TestCase :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } end + def test_entry_show_latin_1 + if @ruby19_non_utf8_pass + puts_ruby19_non_utf8_pass() + else + with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do + ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| + get :entry, :id => PRJ_ID, + :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 + assert_response :success + assert_template 'entry' + assert_tag :tag => 'th', + :content => '1', + :attributes => { :class => 'line-num' }, + :sibling => { :tag => 'td', + :content => /test-#{@char_1}.txt/ } + end + end + end + end + def test_entry_download get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :format => 'raw' @@ -250,6 +278,14 @@ class RepositoriesGitControllerTest < ActionController::TestCase assert_error_tag :content => /was not found/ end end + + private + + def puts_ruby19_non_utf8_pass + puts "TODO: This test fails in Ruby 1.9 " + + "and Encoding.default_external is not UTF-8. " + + "Current value is '#{Encoding.default_external.to_s}'" + end else puts "Git test repository NOT FOUND. Skipping functional tests !!!" def test_fake; assert true end -- 2.11.0