summaryrefslogtreecommitdiffstats
path: root/test/functional/repositories_git_controller_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-10-22 17:37:16 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-10-22 17:37:16 +0000
commit2d1866d966d94c688f9cb87c5bf3f096dffac844 (patch)
tree7a733c1cc51448ab69b3f892285305dbfb0ae15e /test/functional/repositories_git_controller_test.rb
parenta6ec78a4dc658e3517ed682792016b6530458696 (diff)
downloadredmine-2d1866d966d94c688f9cb87c5bf3f096dffac844.tar.gz
redmine-2d1866d966d94c688f9cb87c5bf3f096dffac844.zip
Merged rails-4.1 branch (#14534).
git-svn-id: http://svn.redmine.org/redmine/trunk@13482 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/repositories_git_controller_test.rb')
-rw-r--r--test/functional/repositories_git_controller_test.rb43
1 files changed, 19 insertions, 24 deletions
diff --git a/test/functional/repositories_git_controller_test.rb b/test/functional/repositories_git_controller_test.rb
index 25467e585..e20adeab5 100644
--- a/test/functional/repositories_git_controller_test.rb
+++ b/test/functional/repositories_git_controller_test.rb
@@ -26,8 +26,8 @@ class RepositoriesGitControllerTest < ActionController::TestCase
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
PRJ_ID = 3
- CHAR_1_HEX = "\xc3\x9c"
- FELIX_HEX = "Felix Sch\xC3\xA4fer"
+ CHAR_1_HEX = "\xc3\x9c".force_encoding('UTF-8')
+ FELIX_HEX = "Felix Sch\xC3\xA4fer".force_encoding('UTF-8')
NUM_REV = 28
## Git, Mercurial and CVS path encodings are binary.
@@ -39,8 +39,7 @@ class RepositoriesGitControllerTest < ActionController::TestCase
JRUBY_SKIP_STR = "TODO: This test fails in JRuby"
def setup
- @ruby19_non_utf8_pass =
- (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8')
+ @ruby19_non_utf8_pass = Encoding.default_external.to_s != 'UTF-8'
User.current = nil
@project = Project.find(PRJ_ID)
@@ -50,12 +49,6 @@ class RepositoriesGitControllerTest < ActionController::TestCase
:path_encoding => 'ISO-8859-1'
)
assert @repository
- @char_1 = CHAR_1_HEX.dup
- @felix_utf8 = FELIX_HEX.dup
- if @char_1.respond_to?(:force_encoding)
- @char_1.force_encoding('UTF-8')
- @felix_utf8.force_encoding('UTF-8')
- end
end
def test_create_and_update
@@ -231,7 +224,7 @@ class RepositoriesGitControllerTest < ActionController::TestCase
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
get :entry, :id => PRJ_ID,
- :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
+ :path => repository_path_hash(['latin-1-dir', "test-#{CHAR_1_HEX}.txt"])[:param],
:rev => r1
assert_response :success
assert_template 'entry'
@@ -239,7 +232,7 @@ class RepositoriesGitControllerTest < ActionController::TestCase
:content => '1',
:attributes => { :class => 'line-num' },
:sibling => { :tag => 'td',
- :content => /test-#{@char_1}.txt/ }
+ :content => /test-#{CHAR_1_HEX}.txt/ }
end
end
end
@@ -419,14 +412,14 @@ class RepositoriesGitControllerTest < ActionController::TestCase
:descendant => {
:tag => 'th',
:attributes => { :class => 'filename' } ,
- :content => /latin-1-dir\/test-#{@char_1}.txt/ ,
+ :content => /latin-1-dir\/test-#{CHAR_1_HEX}.txt/ ,
},
:sibling => {
:tag => 'tbody',
:descendant => {
:tag => 'td',
:attributes => { :class => /diff_in/ },
- :content => /test-#{@char_1}.txt/
+ :content => /test-#{CHAR_1_HEX}.txt/
}
}
end
@@ -498,11 +491,13 @@ class RepositoriesGitControllerTest < ActionController::TestCase
end
def test_annotate_binary_file
- get :annotate, :id => PRJ_ID,
- :path => repository_path_hash(['images', 'edit.png'])[:param]
- assert_response 500
- assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
- :content => /cannot be annotated/
+ with_settings :default_language => 'en' do
+ get :annotate, :id => PRJ_ID,
+ :path => repository_path_hash(['images', 'edit.png'])[:param]
+ assert_response 500
+ assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
+ :content => /cannot be annotated/
+ end
end
def test_annotate_error_when_too_big
@@ -533,14 +528,14 @@ class RepositoriesGitControllerTest < ActionController::TestCase
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1|
get :annotate, :id => PRJ_ID,
- :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
+ :path => repository_path_hash(['latin-1-dir', "test-#{CHAR_1_HEX}.txt"])[:param],
:rev => r1
assert_select "th.line-num", :text => '1' do
assert_select "+ td.revision" do
assert_select "a", :text => '57ca437c'
assert_select "+ td.author", :text => "jsmith" do
assert_select "+ td",
- :text => "test-#{@char_1}.txt"
+ :text => "test-#{CHAR_1_HEX}.txt"
end
end
end
@@ -557,7 +552,7 @@ class RepositoriesGitControllerTest < ActionController::TestCase
assert_select "th.line-num", :text => '1' do
assert_select "+ td.revision" do
assert_select "a", :text => '83ca5fd5'
- assert_select "+ td.author", :text => @felix_utf8 do
+ assert_select "+ td.author", :text => FELIX_HEX do
assert_select "+ td",
:text => "And this is a file with a leading and trailing space..."
end
@@ -643,8 +638,8 @@ class RepositoriesGitControllerTest < ActionController::TestCase
private
def puts_ruby19_non_utf8_pass
- puts "TODO: This test fails in Ruby 1.9 " +
- "and Encoding.default_external is not UTF-8. " +
+ puts "TODO: This test fails " +
+ "when Encoding.default_external is not UTF-8. " +
"Current value is '#{Encoding.default_external.to_s}'"
end
else