Patch by Yuichi HARADA. git-svn-id: http://svn.redmine.org/redmine/trunk@17991 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/4.1.0
@@ -143,8 +143,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
assert a.save | |||
assert_equal 'japanese-utf-8.txt', a.filename | |||
str_japanese = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e".force_encoding('UTF-8') | |||
get :show, :params => { | |||
:id => a.id | |||
} | |||
@@ -152,7 +150,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
assert_equal 'text/html', @response.content_type | |||
assert_select 'tr#L1' do | |||
assert_select 'th.line-num', :text => '1' | |||
assert_select 'td', :text => /#{str_japanese}/ | |||
assert_select 'td', :text => /日本語/ | |||
end | |||
end | |||
@@ -772,8 +772,8 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
def test_index_csv_big_5 | |||
with_settings :default_language => "zh-TW" do | |||
str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88".force_encoding('UTF-8') | |||
str_big5 = "\xa4@\xa4\xeb".force_encoding('Big5') | |||
str_utf8 = '一月' | |||
str_big5 = (+"\xa4@\xa4\xeb").force_encoding('Big5') | |||
issue = Issue.generate!(:subject => str_utf8) | |||
get :index, :params => { | |||
@@ -784,7 +784,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
assert_equal 'text/csv; header=present', @response.content_type | |||
lines = @response.body.chomp.split("\n") | |||
header = lines[0] | |||
status = "\xaa\xac\xbaA".force_encoding('Big5') | |||
status = (+"\xaa\xac\xbaA").force_encoding('Big5') | |||
assert_include status, header | |||
issue_line = lines.find {|l| l =~ /^#{issue.id},/} | |||
assert_include str_big5, issue_line | |||
@@ -793,7 +793,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
def test_index_csv_cannot_convert_should_be_replaced_big_5 | |||
with_settings :default_language => "zh-TW" do | |||
str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85".force_encoding('UTF-8') | |||
str_utf8 = '以内' | |||
issue = Issue.generate!(:subject => str_utf8) | |||
get :index, :params => { | |||
@@ -807,10 +807,10 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
lines = @response.body.chomp.split("\n") | |||
header = lines[0] | |||
issue_line = lines.find {|l| l =~ /^#{issue.id},/} | |||
s1 = "\xaa\xac\xbaA".force_encoding('Big5') # status | |||
s1 = (+"\xaa\xac\xbaA").force_encoding('Big5') # status | |||
assert header.include?(s1) | |||
s2 = issue_line.split(",")[2] | |||
s3 = "\xa5H?".force_encoding('Big5') # subject | |||
s3 = (+"\xa5H?").force_encoding('Big5') # subject | |||
assert_equal s3, s2 | |||
end | |||
end | |||
@@ -2345,10 +2345,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
end | |||
def test_export_to_pdf_with_utf8_u_fffd | |||
# U+FFFD | |||
s = "\xef\xbf\xbd" | |||
s.force_encoding('UTF-8') if s.respond_to?(:force_encoding) | |||
issue = Issue.generate!(:subject => s) | |||
issue = Issue.generate!(:subject => "�") | |||
["en", "zh", "zh-TW", "ja", "ko"].each do |lang| | |||
with_settings :default_language => lang do | |||
get :show, :params => { |
@@ -28,7 +28,6 @@ class RepositoriesBazaarControllerTest < Redmine::RepositoryControllerTest | |||
REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository').to_s | |||
REPOSITORY_PATH_TRUNK = File.join(REPOSITORY_PATH, "trunk") | |||
PRJ_ID = 3 | |||
CHAR_1_UTF8_HEX = "\xc3\x9c".dup.force_encoding('UTF-8') | |||
def setup | |||
super | |||
@@ -224,7 +223,7 @@ class RepositoriesBazaarControllerTest < Redmine::RepositoryControllerTest | |||
assert_select "th.line-num", :text => '1' do | |||
assert_select "+ td.revision" do | |||
assert_select "a", :text => '2' | |||
assert_select "+ td.author", :text => "test #{CHAR_1_UTF8_HEX}" do | |||
assert_select "+ td.author", :text => "test Ü" do | |||
assert_select "+ td", | |||
:text => "author non ASCII test" | |||
end |
@@ -112,8 +112,7 @@ class RepositoriesFilesystemControllerTest < Redmine::RepositoryControllerTest | |||
"when Encoding.default_external is not UTF-8. " + | |||
"Current value is '#{Encoding.default_external.to_s}'" | |||
else | |||
str_japanese = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e".force_encoding('UTF-8') | |||
assert_select 'tr#L3 td.line-code', :text => /#{str_japanese}/ | |||
assert_select 'tr#L3 td.line-code', :text => /日本語/ | |||
end | |||
end | |||
end |
@@ -28,8 +28,6 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest | |||
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".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. | |||
@@ -269,11 +267,11 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest | |||
get :entry, :params => { | |||
:id => PRJ_ID, | |||
:repository_id => @repository.id, | |||
:path => repository_path_hash(['latin-1-dir', "test-#{CHAR_1_HEX}.txt"])[:param], | |||
:path => repository_path_hash(['latin-1-dir', "test-Ü.txt"])[:param], | |||
:rev => r1 | |||
} | |||
assert_response :success | |||
assert_select 'tr#L1 td.line-code', :text => /test-#{CHAR_1_HEX}.txt/ | |||
assert_select 'tr#L1 td.line-code', :text => /test-Ü.txt/ | |||
end | |||
end | |||
end | |||
@@ -440,8 +438,8 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest | |||
} | |||
assert_response :success | |||
assert_select 'table' do | |||
assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{CHAR_1_HEX}.txt/ | |||
assert_select 'tbody td.diff_in', :text => /test-#{CHAR_1_HEX}.txt/ | |||
assert_select 'thead th.filename', :text => /latin-1-dir\/test-Ü.txt/ | |||
assert_select 'tbody td.diff_in', :text => /test-Ü.txt/ | |||
end | |||
end | |||
end | |||
@@ -568,7 +566,7 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest | |||
get :annotate, :params => { | |||
:id => PRJ_ID, | |||
:repository_id => @repository.id, | |||
:path => repository_path_hash(['latin-1-dir', "test-#{CHAR_1_HEX}.txt"])[:param], | |||
:path => repository_path_hash(['latin-1-dir', "test-Ü.txt"])[:param], | |||
:rev => r1 | |||
} | |||
assert_select "th.line-num", :text => '1' do | |||
@@ -576,7 +574,7 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest | |||
assert_select "a", :text => '57ca437c' | |||
assert_select "+ td.author", :text => "jsmith" do | |||
assert_select "+ td", | |||
:text => "test-#{CHAR_1_HEX}.txt" | |||
:text => "test-Ü.txt" | |||
end | |||
end | |||
end | |||
@@ -596,7 +594,7 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest | |||
assert_select "th.line-num", :text => '1' do | |||
assert_select "+ td.revision" do | |||
assert_select "a", :text => '83ca5fd5' | |||
assert_select "+ td.author", :text => FELIX_HEX do | |||
assert_select "+ td.author", :text => "Felix Schäfer" do | |||
assert_select "+ td", | |||
:text => "And this is a file with a leading and trailing space..." | |||
end |
@@ -26,7 +26,6 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest | |||
:repositories, :enabled_modules | |||
REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s | |||
CHAR_1_HEX = "\xc3\x9c" | |||
PRJ_ID = 3 | |||
NUM_REV = 34 | |||
@@ -43,10 +42,6 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest | |||
) | |||
assert @repository | |||
@diff_c_support = true | |||
@char_1 = CHAR_1_HEX.dup.force_encoding('UTF-8') | |||
@tag_char_1 = "tag-#{CHAR_1_HEX}-00".force_encoding('UTF-8') | |||
@branch_char_0 = "branch-#{CHAR_1_HEX}-00".force_encoding('UTF-8') | |||
@branch_char_1 = "branch-#{CHAR_1_HEX}-01".force_encoding('UTF-8') | |||
end | |||
if ruby19_non_utf8_pass | |||
@@ -186,9 +181,9 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest | |||
assert_select 'table.entries tbody' do | |||
assert_select 'tr', 4 | |||
assert_select 'tr.file td.filename a', :text => "make-latin-1-file.rb" | |||
assert_select 'tr.file td.filename a', :text => "test-#{@char_1}-1.txt" | |||
assert_select 'tr.file td.filename a', :text => "test-#{@char_1}-2.txt" | |||
assert_select 'tr.file td.filename a', :text => "test-#{@char_1}.txt" | |||
assert_select 'tr.file td.filename a', :text => "test-Ü-1.txt" | |||
assert_select 'tr.file td.filename a', :text => "test-Ü-2.txt" | |||
assert_select 'tr.file td.filename a', :text => "test-Ü.txt" | |||
end | |||
assert_select 'table.changesets tbody' do | |||
@@ -221,9 +216,9 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest | |||
assert_equal NUM_REV, @repository.changesets.count | |||
[ | |||
'default', | |||
@branch_char_1, | |||
'branch-Ü-01', | |||
'branch (1)[2]&,%.-3_4', | |||
@branch_char_0, | |||
'branch-Ü-00', | |||
'test_branch.latin-1', | |||
'test-branch-00', | |||
].each do |bra| | |||
@@ -245,7 +240,7 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest | |||
@project.reload | |||
assert_equal NUM_REV, @repository.changesets.count | |||
[ | |||
@tag_char_1, | |||
'tag-Ü-00', | |||
'tag_test.00', | |||
'tag-init-revision' | |||
].each do |tag| | |||
@@ -287,7 +282,7 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest | |||
get :entry, :params => { | |||
:id => PRJ_ID, | |||
:repository_id => @repository.id, | |||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param], | |||
:path => repository_path_hash(['latin-1-dir', "test-Ü-2.txt"])[:param], | |||
:rev => r1 | |||
} | |||
assert_response :success | |||
@@ -301,11 +296,11 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest | |||
get :entry, :params => { | |||
:id => PRJ_ID, | |||
:repository_id => @repository.id, | |||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], | |||
:path => repository_path_hash(['latin-1-dir', "test-Ü.txt"])[:param], | |||
:rev => r1 | |||
} | |||
assert_response :success | |||
assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/ | |||
assert_select 'tr#L1 td.line-code', :text => /test-Ü.txt/ | |||
end | |||
end | |||
end | |||
@@ -395,7 +390,7 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest | |||
} | |||
assert_response :success | |||
assert_select 'table' do | |||
assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{@char_1}-2.txt/ | |||
assert_select 'thead th.filename', :text => /latin-1-dir\/test-Ü-2.txt/ | |||
assert_select 'tbody td.diff_in', :text => /It is written in Python/ | |||
end | |||
end | |||
@@ -478,7 +473,7 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest | |||
get :annotate, :params => { | |||
:id => PRJ_ID, | |||
:repository_id => @repository.id, | |||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param], | |||
:path => repository_path_hash(['latin-1-dir', "test-Ü-2.txt"])[:param], | |||
:rev => r1 | |||
} | |||
assert_response :success | |||
@@ -500,10 +495,10 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest | |||
get :annotate, :params => { | |||
:id => PRJ_ID, | |||
:repository_id => @repository.id, | |||
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], | |||
:path => repository_path_hash(['latin-1-dir', "test-Ü.txt"])[:param], | |||
:rev => r1 | |||
} | |||
assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/ | |||
assert_select 'tr#L1 td.line-code', :text => /test-Ü.txt/ | |||
end | |||
end | |||
end |
@@ -260,10 +260,9 @@ class TimelogReportTest < Redmine::ControllerTest | |||
end | |||
def test_csv_big_5 | |||
str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88".force_encoding('UTF-8') | |||
str_big5 = "\xa4@\xa4\xeb".force_encoding('Big5') | |||
str_big5 = (+"\xa4@\xa4\xeb").force_encoding('Big5') | |||
user = User.find_by_id(3) | |||
user.firstname = str_utf8 | |||
user.firstname = "一月" | |||
user.lastname = "test-lastname" | |||
assert user.save | |||
comments = "test_csv_big_5" | |||
@@ -293,24 +292,22 @@ class TimelogReportTest < Redmine::ControllerTest | |||
assert_equal 'text/csv; header=present', @response.content_type | |||
lines = @response.body.chomp.split("\n") | |||
# Headers | |||
s1 = "\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp".force_encoding('Big5') | |||
s2 = "\xa4u\xae\xc9\xc1`\xadp".force_encoding('Big5') | |||
s1 = (+"\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5') | |||
s2 = (+"\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5') | |||
assert_equal s1, lines.first | |||
# Total row | |||
assert_equal "#{str_big5} #{user.lastname},7.30,7.30", lines[1] | |||
assert_equal "#{s2},7.30,7.30", lines[2] | |||
str_tw = "Chinese/Traditional (\xe7\xb9\x81\xe9\xab\x94\xe4\xb8\xad\xe6\x96\x87)".force_encoding('UTF-8') | |||
assert_equal str_tw, l(:general_lang_name) | |||
assert_equal 'Chinese/Traditional (繁體中文)', l(:general_lang_name) | |||
assert_equal 'Big5', l(:general_csv_encoding) | |||
assert_equal ',', l(:general_csv_separator) | |||
assert_equal '.', l(:general_csv_decimal_separator) | |||
end | |||
def test_csv_cannot_convert_should_be_replaced_big_5 | |||
str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85".force_encoding('UTF-8') | |||
user = User.find_by_id(3) | |||
user.firstname = str_utf8 | |||
user.firstname = "以内" | |||
user.lastname = "test-lastname" | |||
assert user.save | |||
comments = "test_replaced" | |||
@@ -340,10 +337,10 @@ class TimelogReportTest < Redmine::ControllerTest | |||
assert_equal 'text/csv; header=present', @response.content_type | |||
lines = @response.body.chomp.split("\n") | |||
# Headers | |||
s1 = "\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp".force_encoding('Big5') | |||
s1 = (+"\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp").force_encoding('Big5') | |||
assert_equal s1, lines.first | |||
# Total row | |||
s2 = "\xa5H?".force_encoding('Big5') | |||
s2 = (+"\xa5H?").force_encoding('Big5') | |||
assert_equal "#{s2} #{user.lastname},7.30,7.30", lines[1] | |||
end | |||
@@ -375,15 +372,14 @@ class TimelogReportTest < Redmine::ControllerTest | |||
assert_equal 'text/csv; header=present', @response.content_type | |||
lines = @response.body.chomp.split("\n") | |||
# Headers | |||
s1 = "Utilisateur;2011-11-11;Temps total".force_encoding('ISO-8859-1') | |||
s2 = "Temps total".force_encoding('ISO-8859-1') | |||
s1 = (+"Utilisateur;2011-11-11;Temps total").force_encoding('ISO-8859-1') | |||
s2 = (+"Temps total").force_encoding('ISO-8859-1') | |||
assert_equal s1, lines.first | |||
# Total row | |||
assert_equal "#{user.firstname} #{user.lastname};7,30;7,30", lines[1] | |||
assert_equal "#{s2};7,30;7,30", lines[2] | |||
str_fr = "French (Fran\xc3\xa7ais)".force_encoding('UTF-8') | |||
assert_equal str_fr, l(:general_lang_name) | |||
assert_equal 'French (Français)', l(:general_lang_name) | |||
assert_equal 'ISO-8859-1', l(:general_csv_encoding) | |||
assert_equal ';', l(:general_csv_separator) | |||
assert_equal ',', l(:general_csv_decimal_separator) |
@@ -37,7 +37,7 @@ class ApplicationHelperTest < Redmine::HelperTest | |||
def setup | |||
super | |||
set_tmp_attachments_directory | |||
@russian_test = "\xd1\x82\xd0\xb5\xd1\x81\xd1\x82".force_encoding('UTF-8') | |||
@russian_test = 'тест' | |||
end | |||
test "#link_to_if_authorized for authorized user should allow using the :controller and :action for the target link" do | |||
@@ -1792,7 +1792,7 @@ RAW | |||
end | |||
def test_truncate_single_line_non_ascii | |||
ja = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e".force_encoding('UTF-8') | |||
ja = '日本語' | |||
result = truncate_single_line_raw("#{ja}\n#{ja}\n#{ja}", 10) | |||
assert_equal "#{ja} #{ja}...", result | |||
assert !result.html_safe? |
@@ -112,7 +112,7 @@ class Redmine::ApiTest::AuthenticationTest < Redmine::ApiTest::Base | |||
end | |||
def test_invalid_utf8_credentials_should_not_trigger_an_error | |||
invalid_utf8 = "\x82".force_encoding('UTF-8') | |||
invalid_utf8 = "\x82" | |||
assert !invalid_utf8.valid_encoding? | |||
assert_nothing_raised do | |||
get '/users/current.xml', :headers => credentials(invalid_utf8, "foo") |
@@ -408,7 +408,7 @@ class AttachmentTest < ActiveSupport::TestCase | |||
end | |||
def test_latest_attach_should_not_error_with_string_with_invalid_encoding | |||
string = "width:50\xFE-Image.jpg".force_encoding('UTF-8') | |||
string = "width:50\xFE-Image.jpg" | |||
assert_equal false, string.valid_encoding? | |||
Attachment.latest_attach(Attachment.limit(2).to_a, string) |
@@ -448,8 +448,7 @@ class ChangesetTest < ActiveSupport::TestCase | |||
def test_comments_should_be_converted_to_utf8 | |||
proj = Project.find(3) | |||
# str = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt") | |||
str = "Texte encod\xe9 en ISO-8859-1.".force_encoding("ASCII-8BIT") | |||
str = (+"Texte encod\xe9 en ISO-8859-1.").force_encoding("ASCII-8BIT") | |||
r = Repository::Bazaar.create!( | |||
:project => proj, | |||
:url => '/tmp/test/bazaar', | |||
@@ -461,15 +460,12 @@ class ChangesetTest < ActiveSupport::TestCase | |||
:scmid => '12345', | |||
:comments => str) | |||
assert( c.save ) | |||
str_utf8 = "Texte encod\xc3\xa9 en ISO-8859-1.".force_encoding("UTF-8") | |||
assert_equal str_utf8, c.comments | |||
assert_equal 'Texte encodé en ISO-8859-1.', c.comments | |||
end | |||
def test_invalid_utf8_sequences_in_comments_should_be_replaced_latin1 | |||
proj = Project.find(3) | |||
# str = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt") | |||
str1 = "Texte encod\xe9 en ISO-8859-1.".force_encoding("UTF-8") | |||
str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".force_encoding("ASCII-8BIT") | |||
str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT") | |||
r = Repository::Bazaar.create!( | |||
:project => proj, | |||
:url => '/tmp/test/bazaar', | |||
@@ -479,7 +475,7 @@ class ChangesetTest < ActiveSupport::TestCase | |||
:committed_on => Time.now, | |||
:revision => '123', | |||
:scmid => '12345', | |||
:comments => str1, | |||
:comments => "Texte encod\xE9 en ISO-8859-1.", | |||
:committer => str2) | |||
assert( c.save ) | |||
assert_equal "Texte encod? en ISO-8859-1.", c.comments | |||
@@ -488,7 +484,7 @@ class ChangesetTest < ActiveSupport::TestCase | |||
def test_invalid_utf8_sequences_in_comments_should_be_replaced_ja_jis | |||
proj = Project.find(3) | |||
str = "test\xb5\xfetest\xb5\xfe".force_encoding('ASCII-8BIT') | |||
str = (+"test\xb5\xfetest\xb5\xfe").force_encoding('ASCII-8BIT') | |||
r = Repository::Bazaar.create!( | |||
:project => proj, | |||
:url => '/tmp/test/bazaar', | |||
@@ -504,8 +500,8 @@ class ChangesetTest < ActiveSupport::TestCase | |||
end | |||
def test_comments_should_be_converted_all_latin1_to_utf8 | |||
s1 = "\xC2\x80" | |||
s2 = "\xc3\x82\xc2\x80" | |||
s1 = +"\xC2\x80" | |||
s2 = +"\xc3\x82\xc2\x80" | |||
s4 = s2.dup | |||
s3 = s1.dup | |||
s1.force_encoding('ASCII-8BIT') | |||
@@ -530,8 +526,7 @@ class ChangesetTest < ActiveSupport::TestCase | |||
def test_invalid_utf8_sequences_in_paths_should_be_replaced | |||
proj = Project.find(3) | |||
str1 = "Texte encod\xe9 en ISO-8859-1".force_encoding("UTF-8") | |||
str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".force_encoding("ASCII-8BIT") | |||
str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT") | |||
r = Repository::Bazaar.create!( | |||
:project => proj, | |||
:url => '/tmp/test/bazaar', | |||
@@ -547,7 +542,7 @@ class ChangesetTest < ActiveSupport::TestCase | |||
ch = Change.new( | |||
:changeset => cs, | |||
:action => "A", | |||
:path => str1, | |||
:path => "Texte encod\xE9 en ISO-8859-1", | |||
:from_path => str2, | |||
:from_revision => "345") | |||
assert(ch.save) |
@@ -107,7 +107,7 @@ class CustomFieldTest < ActiveSupport::TestCase | |||
def test_possible_values_should_return_utf8_encoded_strings | |||
field = CustomField.new | |||
s = "Value".force_encoding('BINARY') | |||
s = (+"Value").force_encoding('BINARY') | |||
field.possible_values = s | |||
assert_equal [s], field.possible_values | |||
assert_equal 'UTF-8', field.possible_values.first.encoding.name |
@@ -58,10 +58,9 @@ class GroupTest < ActiveSupport::TestCase | |||
def test_blank_name_error_message_fr | |||
set_language_if_valid 'fr' | |||
str = "Nom doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8') | |||
g = Group.new | |||
assert !g.save | |||
assert_include str, g.errors.full_messages | |||
assert_include 'Nom doit être renseigné(e)', g.errors.full_messages | |||
end | |||
def test_group_roles_should_be_given_to_added_user |
@@ -23,8 +23,8 @@ class Redmine::CodesetUtilTest < ActiveSupport::TestCase | |||
def test_to_utf8_by_setting_from_latin1 | |||
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |||
s1 = "Texte encod\xc3\xa9".force_encoding("UTF-8") | |||
s2 = "Texte encod\xe9".force_encoding("ASCII-8BIT") | |||
s1 = 'Texte encodé' | |||
s2 = (+"Texte encod\xe9").force_encoding("ASCII-8BIT") | |||
s3 = s2.dup.force_encoding("UTF-8") | |||
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s2) | |||
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s3) | |||
@@ -33,8 +33,8 @@ class Redmine::CodesetUtilTest < ActiveSupport::TestCase | |||
def test_to_utf8_by_setting_from_euc_jp | |||
with_settings :repositories_encodings => 'UTF-8,EUC-JP' do | |||
s1 = "\xe3\x83\xac\xe3\x83\x83\xe3\x83\x89\xe3\x83\x9e\xe3\x82\xa4\xe3\x83\xb3".force_encoding("UTF-8") | |||
s2 = "\xa5\xec\xa5\xc3\xa5\xc9\xa5\xde\xa5\xa4\xa5\xf3".force_encoding("ASCII-8BIT") | |||
s1 = 'レッドマイン' | |||
s2 = (+"\xa5\xec\xa5\xc3\xa5\xc9\xa5\xde\xa5\xa4\xa5\xf3").force_encoding("ASCII-8BIT") | |||
s3 = s2.dup.force_encoding("UTF-8") | |||
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s2) | |||
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s3) | |||
@@ -43,8 +43,8 @@ class Redmine::CodesetUtilTest < ActiveSupport::TestCase | |||
def test_to_utf8_by_setting_should_be_converted_all_latin1 | |||
with_settings :repositories_encodings => 'ISO-8859-1' do | |||
s1 = "\xc3\x82\xc2\x80".force_encoding("UTF-8") | |||
s2 = "\xC2\x80".force_encoding("ASCII-8BIT") | |||
s1 = "Â\u0080" | |||
s2 = (+"\xC2\x80").force_encoding("ASCII-8BIT") | |||
s3 = s2.dup.force_encoding("UTF-8") | |||
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s2) | |||
assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s3) | |||
@@ -57,7 +57,7 @@ class Redmine::CodesetUtilTest < ActiveSupport::TestCase | |||
end | |||
def test_to_utf8_by_setting_returns_ascii_as_utf8 | |||
s1 = "ASCII".force_encoding("UTF-8") | |||
s1 = 'ASCII' | |||
s2 = s1.dup.force_encoding("ISO-8859-1") | |||
str1 = Redmine::CodesetUtil.to_utf8_by_setting(s1) | |||
str2 = Redmine::CodesetUtil.to_utf8_by_setting(s2) | |||
@@ -69,8 +69,7 @@ class Redmine::CodesetUtilTest < ActiveSupport::TestCase | |||
def test_to_utf8_by_setting_invalid_utf8_sequences_should_be_stripped | |||
with_settings :repositories_encodings => '' do | |||
# s1 = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt") | |||
s1 = "Texte encod\xe9 en ISO-8859-1.".force_encoding("ASCII-8BIT") | |||
s1 = (+"Texte encod\xe9 en ISO-8859-1.").force_encoding("ASCII-8BIT") | |||
str = Redmine::CodesetUtil.to_utf8_by_setting(s1) | |||
assert str.valid_encoding? | |||
assert_equal "UTF-8", str.encoding.to_s | |||
@@ -80,7 +79,7 @@ class Redmine::CodesetUtilTest < ActiveSupport::TestCase | |||
def test_to_utf8_by_setting_invalid_utf8_sequences_should_be_stripped_ja_jis | |||
with_settings :repositories_encodings => 'ISO-2022-JP' do | |||
s1 = "test\xb5\xfetest\xb5\xfe".force_encoding("ASCII-8BIT") | |||
s1 = (+"test\xb5\xfetest\xb5\xfe").force_encoding("ASCII-8BIT") | |||
str = Redmine::CodesetUtil.to_utf8_by_setting(s1) | |||
assert str.valid_encoding? | |||
assert_equal "UTF-8", str.encoding.to_s | |||
@@ -89,18 +88,18 @@ class Redmine::CodesetUtilTest < ActiveSupport::TestCase | |||
end | |||
test "#replace_invalid_utf8 should replace invalid utf8" do | |||
s1 = "\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1\xE3\x81\xFF".force_encoding("UTF-8") | |||
s1 = "こんにち\xE3\x81\xFF" | |||
s2 = Redmine::CodesetUtil.replace_invalid_utf8(s1) | |||
assert s2.valid_encoding? | |||
assert_equal "UTF-8", s2.encoding.to_s | |||
assert_equal "\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1??".force_encoding("UTF-8"), s2 | |||
assert_equal 'こんにち??', s2 | |||
end | |||
test "#to_utf8 should replace invalid non utf8" do | |||
s1 = "\xa4\xb3\xa4\xf3\xa4\xcb\xa4\xc1\xa4".force_encoding("EUC-JP") | |||
s1 = (+"\xa4\xb3\xa4\xf3\xa4\xcb\xa4\xc1\xa4").force_encoding("EUC-JP") | |||
s2 = Redmine::CodesetUtil.to_utf8(s1, "EUC-JP") | |||
assert s2.valid_encoding? | |||
assert_equal "UTF-8", s2.encoding.to_s | |||
assert_equal "\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1?".force_encoding("UTF-8"), s2 | |||
assert_equal 'こんにち?', s2 | |||
end | |||
end |
@@ -21,13 +21,12 @@ require File.expand_path('../../../../../test_helper', __FILE__) | |||
class CsvTest < ActiveSupport::TestCase | |||
include Redmine::I18n | |||
BOM = "\xEF\xBB\xBF".force_encoding('UTF-8') | |||
def test_should_include_bom_when_utf8_encoded | |||
with_locale 'sk' do | |||
string = Redmine::Export::CSV.generate {|csv| csv << %w(Foo Bar)} | |||
assert_equal 'UTF-8', string.encoding.name | |||
assert string.starts_with?(BOM) | |||
assert string.starts_with?("\xEF\xBB\xBF") | |||
end | |||
end | |||
@@ -29,16 +29,16 @@ class PdfTest < ActiveSupport::TestCase | |||
end | |||
def test_rdm_pdf_iconv_cannot_convert_ja_cp932 | |||
utf8_txt_1 = "\xe7\x8b\x80\xe6\x85\x8b" | |||
utf8_txt_2 = "\xe7\x8b\x80\xe6\x85\x8b\xe7\x8b\x80" | |||
utf8_txt_3 = "\xe7\x8b\x80\xe7\x8b\x80\xe6\x85\x8b\xe7\x8b\x80" | |||
utf8_txt_1 = '狀態' | |||
utf8_txt_2 = '狀態狀' | |||
utf8_txt_3 = '狀狀態狀' | |||
["CP932", "SJIS"].each do |encoding| | |||
txt_1 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(utf8_txt_1, encoding) | |||
txt_2 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(utf8_txt_2, encoding) | |||
txt_3 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(utf8_txt_3, encoding) | |||
assert_equal "?\x91\xd4".force_encoding("ASCII-8BIT"), txt_1 | |||
assert_equal "?\x91\xd4?".force_encoding("ASCII-8BIT"), txt_2 | |||
assert_equal "??\x91\xd4?".force_encoding("ASCII-8BIT"), txt_3 | |||
assert_equal (+"?\x91\xd4").force_encoding("ASCII-8BIT"), txt_1 | |||
assert_equal (+"?\x91\xd4?").force_encoding("ASCII-8BIT"), txt_2 | |||
assert_equal (+"??\x91\xd4?").force_encoding("ASCII-8BIT"), txt_3 | |||
assert_equal "ASCII-8BIT", txt_1.encoding.to_s | |||
assert_equal "ASCII-8BIT", txt_2.encoding.to_s | |||
assert_equal "ASCII-8BIT", txt_3.encoding.to_s | |||
@@ -46,8 +46,8 @@ class PdfTest < ActiveSupport::TestCase | |||
end | |||
def test_rdm_pdf_iconv_invalid_utf8_should_be_replaced_en | |||
str1 = "Texte encod\xe9 en ISO-8859-1".force_encoding("UTF-8") | |||
str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".force_encoding("ASCII-8BIT") | |||
str1 = "Texte encod\xE9 en ISO-8859-1" | |||
str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT") | |||
txt_1 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str1, 'UTF-8') | |||
txt_2 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str2, 'UTF-8') | |||
assert_equal "ASCII-8BIT", txt_1.encoding.to_s | |||
@@ -57,8 +57,8 @@ class PdfTest < ActiveSupport::TestCase | |||
end | |||
def test_rdm_pdf_iconv_invalid_utf8_should_be_replaced_ja | |||
str1 = "Texte encod\xe9 en ISO-8859-1".force_encoding("UTF-8") | |||
str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".force_encoding("ASCII-8BIT") | |||
str1 = "Texte encod\xE9 en ISO-8859-1" | |||
str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT") | |||
encoding = ( RUBY_PLATFORM == 'java' ? "SJIS" : "CP932" ) | |||
txt_1 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str1, encoding) | |||
txt_2 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str2, encoding) | |||
@@ -72,7 +72,7 @@ class PdfTest < ActiveSupport::TestCase | |||
["CP932", "SJIS"].each do |encoding| | |||
set_fixtures_attachments_directory | |||
str2 = "\x83e\x83X\x83g".force_encoding("ASCII-8BIT") | |||
str2 = (+"\x83e\x83X\x83g").force_encoding("ASCII-8BIT") | |||
a1 = Attachment.find(17) | |||
a2 = Attachment.find(19) |
@@ -165,8 +165,7 @@ class Redmine::I18nTest < ActiveSupport::TestCase | |||
set_language_if_valid 'bs' | |||
assert_equal "KM -1000,20", number_to_currency(-1000.2) | |||
set_language_if_valid 'de' | |||
euro_sign = "\xe2\x82\xac".force_encoding('UTF-8') | |||
assert_equal "-1000,20 #{euro_sign}", number_to_currency(-1000.2) | |||
assert_equal '-1000,20 €', number_to_currency(-1000.2) | |||
end | |||
def test_lu_should_not_error_when_user_language_is_an_empty_string | |||
@@ -191,8 +190,7 @@ class Redmine::I18nTest < ActiveSupport::TestCase | |||
assert_nil options.detect {|option| option.size != 2} | |||
assert_nil options.detect {|option| !option.first.is_a?(String) || !option.last.is_a?(String)} | |||
assert_include ["English", "en"], options | |||
ja = "Japanese (\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e)".force_encoding('UTF-8') | |||
assert_include [ja, "ja"], options | |||
assert_include ['Japanese (日本語)', "ja"], options | |||
end | |||
def test_languages_options_should_return_strings_with_utf8_encoding | |||
@@ -243,21 +241,18 @@ class Redmine::I18nTest < ActiveSupport::TestCase | |||
def test_utf8 | |||
set_language_if_valid 'ja' | |||
str_ja_yes = "\xe3\x81\xaf\xe3\x81\x84".force_encoding('UTF-8') | |||
i18n_ja_yes = l(:general_text_Yes) | |||
assert_equal str_ja_yes, i18n_ja_yes | |||
assert_equal 'はい', i18n_ja_yes | |||
assert_equal "UTF-8", i18n_ja_yes.encoding.to_s | |||
end | |||
def test_traditional_chinese_locale | |||
set_language_if_valid 'zh-TW' | |||
str_tw = "Chinese/Traditional (\xE7\xB9\x81\xE9\xAB\x94\xE4\xB8\xAD\xE6\x96\x87)".force_encoding('UTF-8') | |||
assert_equal str_tw, l(:general_lang_name) | |||
assert_equal 'Chinese/Traditional (繁體中文)', l(:general_lang_name) | |||
end | |||
def test_french_locale | |||
set_language_if_valid 'fr' | |||
str_fr = "French (Fran\xc3\xa7ais)".force_encoding('UTF-8') | |||
assert_equal str_fr, l(:general_lang_name) | |||
assert_equal 'French (Français)', l(:general_lang_name) | |||
end | |||
end |
@@ -22,9 +22,6 @@ require File.expand_path('../../../../../../test_helper', __FILE__) | |||
class GitAdapterTest < ActiveSupport::TestCase | |||
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s | |||
FELIX_HEX = "Felix Sch\xC3\xA4fer" | |||
CHAR_1_HEX = "\xc3\x9c" | |||
## Git, Mercurial and CVS path encodings are binary. | |||
## Subversion supports URL encoding for path. | |||
## Redmine Mercurial adapter and extension use URL encoding. | |||
@@ -60,8 +57,8 @@ class GitAdapterTest < ActiveSupport::TestCase | |||
'ISO-8859-1' | |||
) | |||
assert @adapter | |||
@char_1 = CHAR_1_HEX.dup.force_encoding('UTF-8') | |||
@str_felix_hex = FELIX_HEX.dup.force_encoding('ASCII-8BIT') | |||
@char_1 = 'Ü' | |||
@str_felix_hex = (+"Felix Sch\xC3\xA4fer").force_encoding('ASCII-8BIT') | |||
end | |||
def test_scm_version |
@@ -27,7 +27,6 @@ class MercurialAdapterTest < ActiveSupport::TestCase | |||
HgCommandArgumentError = Redmine::Scm::Adapters::MercurialAdapter::HgCommandArgumentError | |||
REPOSITORY_PATH = repository_path('mercurial') | |||
CHAR_1_HEX = "\xc3\x9c" | |||
if File.directory?(REPOSITORY_PATH) | |||
def setup | |||
@@ -44,10 +43,10 @@ class MercurialAdapterTest < ActiveSupport::TestCase | |||
nil, | |||
'ISO-8859-1') | |||
@diff_c_support = true | |||
@char_1 = CHAR_1_HEX.dup.force_encoding('UTF-8') | |||
@tag_char_1 = "tag-#{CHAR_1_HEX}-00".force_encoding('UTF-8') | |||
@branch_char_0 = "branch-#{CHAR_1_HEX}-00".force_encoding('UTF-8') | |||
@branch_char_1 = "branch-#{CHAR_1_HEX}-01".force_encoding('UTF-8') | |||
@char_1 = 'Ü' | |||
@tag_char_1 = 'tag-Ü-00' | |||
@branch_char_0 = 'branch-Ü-00' | |||
@branch_char_1 = 'branch-Ü-01' | |||
end | |||
def test_hgversion |
@@ -274,23 +274,20 @@ DIFF | |||
end | |||
def test_utf8_ja | |||
ja = " text_tip_issue_end_day: " | |||
ja += "\xe3\x81\x93\xe3\x81\xae\xe6\x97\xa5\xe3\x81\xab\xe7\xb5\x82\xe4\xba\x86\xe3\x81\x99\xe3\x82\x8b<span>\xe3\x82\xbf\xe3\x82\xb9\xe3\x82\xaf</span>".force_encoding('UTF-8') | |||
with_settings :repositories_encodings => '' do | |||
diff = Redmine::UnifiedDiff.new(read_diff_fixture('issue-12641-ja.diff'), :type => 'inline') | |||
assert_equal 1, diff.size | |||
assert_equal 12, diff.first.size | |||
assert_equal ja, diff.first[4].html_line_left | |||
assert_equal ' text_tip_issue_end_day: この日に終了する<span>タスク</span>', diff.first[4].html_line_left | |||
end | |||
end | |||
def test_utf8_ru | |||
ru = " other: "\xd0\xbe\xd0\xba\xd0\xbe\xd0\xbb\xd0\xbe %{count} \xd1\x87\xd0\xb0\xd1\x81<span>\xd0\xb0</span>"".force_encoding('UTF-8') | |||
with_settings :repositories_encodings => '' do | |||
diff = Redmine::UnifiedDiff.new(read_diff_fixture('issue-12641-ru.diff'), :type => 'inline') | |||
assert_equal 1, diff.size | |||
assert_equal 8, diff.first.size | |||
assert_equal ru, diff.first[3].html_line_left | |||
assert_equal ' other: "около %{count} час<span>а</span>"', diff.first[3].html_line_left | |||
end | |||
end | |||
@@ -329,70 +326,60 @@ DIFF | |||
end | |||
def test_offset_range_japanese_1 | |||
ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span></span>".force_encoding('UTF-8') | |||
ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xaa\x9e</span>".force_encoding('UTF-8') | |||
with_settings :repositories_encodings => '' do | |||
diff = Redmine::UnifiedDiff.new( | |||
read_diff_fixture('issue-13644-1.diff'), :type => 'sbs') | |||
assert_equal 1, diff.size | |||
assert_equal 3, diff.first.size | |||
assert_equal ja1, diff.first[1].html_line_left | |||
assert_equal ja2, diff.first[1].html_line_right | |||
assert_equal '日本<span></span>', diff.first[1].html_line_left | |||
assert_equal '日本<span>語</span>', diff.first[1].html_line_right | |||
end | |||
end | |||
def test_offset_range_japanese_2 | |||
ja1 = "<span></span>\xe6\x97\xa5\xe6\x9c\xac".force_encoding('UTF-8') | |||
ja2 = "<span>\xe3\x81\xab\xe3\x81\xa3\xe3\x81\xbd\xe3\x82\x93</span>\xe6\x97\xa5\xe6\x9c\xac".force_encoding('UTF-8') | |||
with_settings :repositories_encodings => '' do | |||
diff = Redmine::UnifiedDiff.new( | |||
read_diff_fixture('issue-13644-2.diff'), :type => 'sbs') | |||
assert_equal 1, diff.size | |||
assert_equal 3, diff.first.size | |||
assert_equal ja1, diff.first[1].html_line_left | |||
assert_equal ja2, diff.first[1].html_line_right | |||
assert_equal '<span></span>日本', diff.first[1].html_line_left | |||
assert_equal '<span>にっぽん</span>日本', diff.first[1].html_line_right | |||
end | |||
end | |||
def test_offset_range_japanese_3 | |||
# UTF-8 The 1st byte differs. | |||
ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xa8\x98</span>".force_encoding('UTF-8') | |||
ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe5\xa8\x98</span>".force_encoding('UTF-8') | |||
with_settings :repositories_encodings => '' do | |||
diff = Redmine::UnifiedDiff.new( | |||
read_diff_fixture('issue-13644-3.diff'), :type => 'sbs') | |||
assert_equal 1, diff.size | |||
assert_equal 3, diff.first.size | |||
assert_equal ja1, diff.first[1].html_line_left | |||
assert_equal ja2, diff.first[1].html_line_right | |||
assert_equal '日本<span>記</span>', diff.first[1].html_line_left | |||
assert_equal '日本<span>娘</span>', diff.first[1].html_line_right | |||
end | |||
end | |||
def test_offset_range_japanese_4 | |||
# UTF-8 The 2nd byte differs. | |||
ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xa8\x98</span>".force_encoding('UTF-8') | |||
ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xaa\x98</span>".force_encoding('UTF-8') | |||
with_settings :repositories_encodings => '' do | |||
diff = Redmine::UnifiedDiff.new( | |||
read_diff_fixture('issue-13644-4.diff'), :type => 'sbs') | |||
assert_equal 1, diff.size | |||
assert_equal 3, diff.first.size | |||
assert_equal ja1, diff.first[1].html_line_left | |||
assert_equal ja2, diff.first[1].html_line_right | |||
assert_equal '日本<span>記</span>', diff.first[1].html_line_left | |||
assert_equal '日本<span>誘</span>', diff.first[1].html_line_right | |||
end | |||
end | |||
def test_offset_range_japanese_5 | |||
# UTF-8 The 2nd byte differs. | |||
ja1 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xa8\x98</span>ok".force_encoding('UTF-8') | |||
ja2 = "\xe6\x97\xa5\xe6\x9c\xac<span>\xe8\xaa\x98</span>ok".force_encoding('UTF-8') | |||
with_settings :repositories_encodings => '' do | |||
diff = Redmine::UnifiedDiff.new( | |||
read_diff_fixture('issue-13644-5.diff'), :type => 'sbs') | |||
assert_equal 1, diff.size | |||
assert_equal 3, diff.first.size | |||
assert_equal ja1, diff.first[1].html_line_left | |||
assert_equal ja2, diff.first[1].html_line_right | |||
assert_equal '日本<span>記</span>ok', diff.first[1].html_line_left | |||
assert_equal '日本<span>誘</span>ok', diff.first[1].html_line_right | |||
end | |||
end | |||
@@ -515,8 +515,7 @@ class MailHandlerTest < ActiveSupport::TestCase | |||
end | |||
def test_add_issue_with_japanese_keywords | |||
ja_dev = "\xe9\x96\x8b\xe7\x99\xba".force_encoding('UTF-8') | |||
tracker = Tracker.generate!(:name => ja_dev) | |||
tracker = Tracker.generate!(:name => '開発') | |||
Project.find(1).trackers << tracker | |||
issue = submit_email( | |||
'japanese_keywords_iso_2022_jp.eml', | |||
@@ -550,9 +549,8 @@ class MailHandlerTest < ActiveSupport::TestCase | |||
) | |||
assert_kind_of Issue, issue | |||
assert_equal 1, issue.attachments.size | |||
ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88.txt".force_encoding('UTF-8') | |||
attachment = issue.attachments.first | |||
assert_equal ja, attachment.filename | |||
assert_equal 'テスト.txt', attachment.filename | |||
assert_equal 5, attachment.filesize | |||
assert File.exist?(attachment.diskfile) | |||
assert_equal 5, File.size(attachment.diskfile) | |||
@@ -565,8 +563,7 @@ class MailHandlerTest < ActiveSupport::TestCase | |||
:issue => {:project => 'ecookbook'} | |||
) | |||
assert_kind_of Issue, issue | |||
description = "\xD0\x97\xD0\xB4\xD1\x80\xD0\xB0\xD0\xB2\xD1\x81\xD1\x82\xD0\xB2\xD1\x83\xD0\xB9\xD1\x82\xD0\xB5?".force_encoding('UTF-8') | |||
assert_equal description, issue.description | |||
assert_equal 'Здравствуйте?', issue.description | |||
end | |||
def test_gmail_with_attachment_ja | |||
@@ -576,9 +573,8 @@ class MailHandlerTest < ActiveSupport::TestCase | |||
) | |||
assert_kind_of Issue, issue | |||
assert_equal 1, issue.attachments.size | |||
ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88.txt".force_encoding('UTF-8') | |||
attachment = issue.attachments.first | |||
assert_equal ja, attachment.filename | |||
assert_equal 'テスト.txt', attachment.filename | |||
assert_equal 5, attachment.filesize | |||
assert File.exist?(attachment.diskfile) | |||
assert_equal 5, File.size(attachment.diskfile) | |||
@@ -592,8 +588,8 @@ class MailHandlerTest < ActiveSupport::TestCase | |||
) | |||
assert_kind_of Issue, issue | |||
assert_equal 1, issue.attachments.size | |||
u = "".force_encoding('UTF-8') | |||
u1 = "\xc3\x84\xc3\xa4\xc3\x96\xc3\xb6\xc3\x9c\xc3\xbc".force_encoding('UTF-8') | |||
u = +'' | |||
u1 = 'ÄäÖöÜü' | |||
11.times { u << u1 } | |||
attachment = issue.attachments.first | |||
assert_equal "#{u}.png", attachment.filename | |||
@@ -610,8 +606,8 @@ class MailHandlerTest < ActiveSupport::TestCase | |||
) | |||
assert_kind_of Issue, issue | |||
assert_equal 1, issue.attachments.size | |||
u = "".force_encoding('UTF-8') | |||
u1 = "\xc3\x84\xc3\xa4\xc3\x96\xc3\xb6\xc3\x9c\xc3\xbc".force_encoding('UTF-8') | |||
u = +'' | |||
u1 = 'ÄäÖöÜü' | |||
11.times { u << u1 } | |||
attachment = issue.attachments.first | |||
assert_equal "#{u}.txt", attachment.filename | |||
@@ -633,7 +629,7 @@ class MailHandlerTest < ActiveSupport::TestCase | |||
assert_equal 19, attachment.filesize | |||
assert File.exist?(attachment.diskfile) | |||
assert_equal 19, File.size(attachment.diskfile) | |||
content = "p\xF8\xEDli\xB9 \xBEluou\xE8k\xFD k\xF9n".force_encoding('CP852') | |||
content = (+"p\xF8\xEDli\xB9 \xBEluou\xE8k\xFD k\xF9n").force_encoding('CP852') | |||
assert_equal content, File.read(attachment.diskfile).force_encoding('CP852') | |||
end | |||
@@ -686,9 +682,8 @@ class MailHandlerTest < ActiveSupport::TestCase | |||
'subject_as_iso-8859-1.eml', | |||
:issue => {:project => 'ecookbook'} | |||
) | |||
str = "Testmail from Webmail: \xc3\xa4 \xc3\xb6 \xc3\xbc...".force_encoding('UTF-8') | |||
assert_kind_of Issue, issue | |||
assert_equal str, issue.subject | |||
assert_equal 'Testmail from Webmail: ä ö ü...', issue.subject | |||
end | |||
def test_quoted_printable_utf8 | |||
@@ -697,8 +692,7 @@ class MailHandlerTest < ActiveSupport::TestCase | |||
:issue => {:project => 'ecookbook'} | |||
) | |||
assert_kind_of Issue, issue | |||
str = "Freundliche Gr\xc3\xbcsse".force_encoding('UTF-8') | |||
assert_equal str, issue.description | |||
assert_equal 'Freundliche Grüsse', issue.description | |||
end | |||
def test_gmail_iso8859_2 | |||
@@ -707,8 +701,7 @@ class MailHandlerTest < ActiveSupport::TestCase | |||
:issue => {:project => 'ecookbook'} | |||
) | |||
assert_kind_of Issue, issue | |||
str = "Na \xc5\xa1triku se su\xc5\xa1i \xc5\xa1osi\xc4\x87.".force_encoding('UTF-8') | |||
assert issue.description.include?(str) | |||
assert issue.description.include?('Na štriku se suši šosić.') | |||
end | |||
def test_add_issue_with_japanese_subject | |||
@@ -717,20 +710,16 @@ class MailHandlerTest < ActiveSupport::TestCase | |||
:issue => {:project => 'ecookbook'} | |||
) | |||
assert_kind_of Issue, issue | |||
ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88".force_encoding('UTF-8') | |||
assert_equal ja, issue.subject | |||
assert_equal 'テスト', issue.subject | |||
end | |||
def test_add_issue_with_korean_body | |||
# Make sure mail bodies with a charset unknown to Ruby | |||
# but known to the Mail gem 2.5.4 are handled correctly | |||
kr = "\xEA\xB3\xA0\xEB\xA7\x99\xEC\x8A\xB5\xEB\x8B\x88\xEB\x8B\xA4.".force_encoding('UTF-8') | |||
issue = submit_email( | |||
'body_ks_c_5601-1987.eml', | |||
:issue => {:project => 'ecookbook'} | |||
) | |||
assert_kind_of Issue, issue | |||
assert_equal kr, issue.description | |||
assert_equal '고맙습니다.', issue.description | |||
end | |||
def test_add_issue_with_no_subject_header | |||
@@ -748,8 +737,7 @@ class MailHandlerTest < ActiveSupport::TestCase | |||
:issue => {:project => 'ecookbook'} | |||
) | |||
assert_kind_of Issue, issue | |||
ja = "Re: \xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88".force_encoding('UTF-8') | |||
assert_equal ja, issue.subject | |||
assert_equal 'Re: テスト', issue.subject | |||
end | |||
def test_add_issue_with_iso_2022_jp_ms_subject | |||
@@ -1187,10 +1175,8 @@ class MailHandlerTest < ActiveSupport::TestCase | |||
end | |||
user = User.order('id DESC').first | |||
assert_equal "foo@example.org", user.mail | |||
str1 = "\xc3\x84\xc3\xa4".force_encoding('UTF-8') | |||
str2 = "\xc3\x96\xc3\xb6".force_encoding('UTF-8') | |||
assert_equal str1, user.firstname | |||
assert_equal str2, user.lastname | |||
assert_equal 'Ää', user.firstname | |||
assert_equal 'Öö', user.lastname | |||
end | |||
def test_new_user_with_fullname_in_parentheses |
@@ -88,7 +88,7 @@ class MemberTest < ActiveSupport::TestCase | |||
member = Member.new(:project_id => 1, :user_id => user.id, :role_ids => []) | |||
assert !member.save | |||
assert_include I18n.translate('activerecord.errors.messages.empty'), member.errors[:role] | |||
assert_equal "R\xc3\xb4le doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8'), | |||
assert_equal 'Rôle doit être renseigné(e)', | |||
[member.errors.full_messages].flatten.join | |||
end | |||
@@ -1830,7 +1830,7 @@ class QueryTest < ActiveSupport::TestCase | |||
def test_label_for_fr | |||
set_language_if_valid 'fr' | |||
q = IssueQuery.new | |||
assert_equal "Assign\xc3\xa9 \xc3\xa0".force_encoding('UTF-8'), q.label_for('assigned_to_id') | |||
assert_equal 'Assigné à', q.label_for('assigned_to_id') | |||
end | |||
def test_editable_by |
@@ -46,8 +46,8 @@ class RepositoryBazaarTest < ActiveSupport::TestCase | |||
RUN_LATIN1_OUTPUT_TEST = (RUBY_PLATFORM != 'java' && | |||
Encoding.locale_charmap == "ISO-8859-1") | |||
CHAR_1_UTF8_HEX = "\xc3\x9c".force_encoding('UTF-8') | |||
CHAR_1_LATIN1_HEX = "\xdc".force_encoding('ASCII-8BIT') | |||
CHAR_1_UTF8_HEX = 'Ü' | |||
CHAR_1_LATIN1_HEX = (+"\xdc").force_encoding('ASCII-8BIT') | |||
def setup | |||
User.current = nil | |||
@@ -72,7 +72,6 @@ class RepositoryBazaarTest < ActiveSupport::TestCase | |||
def test_blank_path_to_repository_error_message_fr | |||
set_language_if_valid 'fr' | |||
str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8') | |||
repo = Repository::Bazaar.new( | |||
:project => @project, | |||
:url => "", | |||
@@ -80,7 +79,7 @@ class RepositoryBazaarTest < ActiveSupport::TestCase | |||
:log_encoding => 'UTF-8' | |||
) | |||
assert !repo.save | |||
assert_include str, repo.errors.full_messages | |||
assert_include 'Chemin du dépôt doit être renseigné(e)', repo.errors.full_messages | |||
end | |||
if File.directory?(REPOSITORY_PATH_TRUNK) |
@@ -55,7 +55,6 @@ class RepositoryCvsTest < ActiveSupport::TestCase | |||
def test_blank_module_error_message_fr | |||
set_language_if_valid 'fr' | |||
str = "Module doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8') | |||
repo = Repository::Cvs.new( | |||
:project => @project, | |||
:identifier => 'test', | |||
@@ -65,7 +64,7 @@ class RepositoryCvsTest < ActiveSupport::TestCase | |||
:root_url => REPOSITORY_PATH | |||
) | |||
assert !repo.save | |||
assert_include str, repo.errors.full_messages | |||
assert_include 'Module doit être renseigné(e)', repo.errors.full_messages | |||
end | |||
def test_blank_cvsroot_error_message | |||
@@ -83,7 +82,6 @@ class RepositoryCvsTest < ActiveSupport::TestCase | |||
def test_blank_cvsroot_error_message_fr | |||
set_language_if_valid 'fr' | |||
str = "CVSROOT doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8') | |||
repo = Repository::Cvs.new( | |||
:project => @project, | |||
:identifier => 'test', | |||
@@ -93,7 +91,7 @@ class RepositoryCvsTest < ActiveSupport::TestCase | |||
:root_url => '' | |||
) | |||
assert !repo.save | |||
assert_include str, repo.errors.full_messages | |||
assert_include 'CVSROOT doit être renseigné(e)', repo.errors.full_messages | |||
end | |||
def test_root_url_should_be_validated_against_regexp_set_in_configuration |
@@ -50,7 +50,6 @@ class RepositoryFilesystemTest < ActiveSupport::TestCase | |||
def test_blank_root_directory_error_message_fr | |||
set_language_if_valid 'fr' | |||
str = "R\xc3\xa9pertoire racine doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8') | |||
repo = Repository::Filesystem.new( | |||
:project => @project, | |||
:url => "", | |||
@@ -58,7 +57,7 @@ class RepositoryFilesystemTest < ActiveSupport::TestCase | |||
:path_encoding => '' | |||
) | |||
assert !repo.save | |||
assert_include str, repo.errors.full_messages | |||
assert_include 'Répertoire racine doit être renseigné(e)', repo.errors.full_messages | |||
end | |||
if File.directory?(REPOSITORY_PATH) |
@@ -30,9 +30,6 @@ class RepositoryGitTest < ActiveSupport::TestCase | |||
NUM_REV = 28 | |||
NUM_HEAD = 6 | |||
FELIX_HEX = "Felix Sch\xC3\xA4fer".force_encoding('UTF-8') | |||
CHAR_1_HEX = "\xc3\x9c".force_encoding('UTF-8') | |||
## Git, Mercurial and CVS path encodings are binary. | |||
## Subversion supports URL encoding for path. | |||
## Redmine Mercurial adapter and extension use URL encoding. | |||
@@ -96,7 +93,6 @@ class RepositoryGitTest < ActiveSupport::TestCase | |||
def test_blank_path_to_repository_error_message_fr | |||
set_language_if_valid 'fr' | |||
str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8') | |||
repo = Repository::Git.new( | |||
:project => @project, | |||
:url => "", | |||
@@ -104,7 +100,7 @@ class RepositoryGitTest < ActiveSupport::TestCase | |||
:path_encoding => '' | |||
) | |||
assert !repo.save | |||
assert_include str, repo.errors.full_messages | |||
assert_include 'Chemin du dépôt doit être renseigné(e)', repo.errors.full_messages | |||
end | |||
if File.directory?(REPOSITORY_PATH) | |||
@@ -470,14 +466,14 @@ class RepositoryGitTest < ActiveSupport::TestCase | |||
else | |||
# latin-1 encoding path | |||
changesets = @repository.latest_changesets( | |||
"latin-1-dir/test-#{CHAR_1_HEX}-2.txt", '64f1f3e89') | |||
'latin-1-dir/test-Ü-2.txt', '64f1f3e89') | |||
assert_equal [ | |||
'64f1f3e89ad1cb57976ff0ad99a107012ba3481d', | |||
'4fc55c43bf3d3dc2efb66145365ddc17639ce81e', | |||
], changesets.collect(&:revision) | |||
changesets = @repository.latest_changesets( | |||
"latin-1-dir/test-#{CHAR_1_HEX}-2.txt", '64f1f3e89', 1) | |||
'latin-1-dir/test-Ü-2.txt', '64f1f3e89', 1) | |||
assert_equal [ | |||
'64f1f3e89ad1cb57976ff0ad99a107012ba3481d', | |||
], changesets.collect(&:revision) | |||
@@ -495,7 +491,7 @@ class RepositoryGitTest < ActiveSupport::TestCase | |||
@project.reload | |||
assert_equal NUM_REV, @repository.changesets.count | |||
changesets = @repository.latest_changesets( | |||
"latin-1-dir/test-#{CHAR_1_HEX}-subdir", '1ca7f5ed') | |||
'latin-1-dir/test-Ü-subdir', '1ca7f5ed') | |||
assert_equal [ | |||
'1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', | |||
], changesets.collect(&:revision) | |||
@@ -560,7 +556,7 @@ class RepositoryGitTest < ActiveSupport::TestCase | |||
assert_equal NUM_REV, @repository.changesets.count | |||
c = @repository.changesets.find_by_revision( | |||
'ed5bb786bbda2dee66a2d50faf51429dbc043a7b') | |||
assert_equal "#{FELIX_HEX} <felix@fachschaften.org>", c.committer | |||
assert_equal 'Felix Schäfer <felix@fachschaften.org>', c.committer | |||
end | |||
def test_previous |
@@ -27,9 +27,6 @@ class RepositoryMercurialTest < ActiveSupport::TestCase | |||
REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s | |||
NUM_REV = 34 | |||
CHAR_1_HEX = "\xc3\x9c".force_encoding('UTF-8') | |||
BRANCH_CHAR_1 = "branch-#{CHAR_1_HEX}-01".force_encoding('UTF-8') | |||
def setup | |||
User.current = nil | |||
@project = Project.find(3) | |||
@@ -54,7 +51,6 @@ class RepositoryMercurialTest < ActiveSupport::TestCase | |||
def test_blank_path_to_repository_error_message_fr | |||
set_language_if_valid 'fr' | |||
str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8') | |||
repo = Repository::Mercurial.new( | |||
:project => @project, | |||
:url => "", | |||
@@ -62,7 +58,7 @@ class RepositoryMercurialTest < ActiveSupport::TestCase | |||
:path_encoding => '' | |||
) | |||
assert !repo.save | |||
assert_include str, repo.errors.full_messages | |||
assert_include 'Chemin du dépôt doit être renseigné(e)', repo.errors.full_messages | |||
end | |||
if File.directory?(REPOSITORY_PATH) | |||
@@ -356,11 +352,11 @@ class RepositoryMercurialTest < ActiveSupport::TestCase | |||
assert_equal NUM_REV, @repository.changesets.count | |||
if @repository.scm.class.client_version_above?([1, 6]) | |||
changesets = @repository.latest_changesets('', BRANCH_CHAR_1) | |||
changesets = @repository.latest_changesets('', 'branch-Ü-01') | |||
assert_equal %w|27 26|, changesets.collect(&:revision) | |||
end | |||
changesets = @repository.latest_changesets("latin-1-dir/test-#{CHAR_1_HEX}-subdir", BRANCH_CHAR_1) | |||
changesets = @repository.latest_changesets('latin-1-dir/test-Ü-subdir', 'branch-Ü-01') | |||
assert_equal %w|27|, changesets.collect(&:revision) | |||
end | |||
@@ -423,8 +419,8 @@ class RepositoryMercurialTest < ActiveSupport::TestCase | |||
scmid3 = scmid_for_assert(hex3, is_short_scmid) | |||
assert_equal 1, c3.size | |||
assert_equal 'A', c3[0].action | |||
assert_equal "/latin-1-dir/test-#{CHAR_1_HEX}-1.txt", c3[0].path | |||
assert_equal "/latin-1-dir/test-#{CHAR_1_HEX}.txt", c3[0].from_path | |||
assert_equal '/latin-1-dir/test-Ü-1.txt', c3[0].path | |||
assert_equal '/latin-1-dir/test-Ü.txt', c3[0].from_path | |||
assert_equal scmid3, c3[0].from_revision | |||
end | |||
private :assert_copied_files |
@@ -236,7 +236,7 @@ class RepositorySubversionTest < ActiveSupport::TestCase | |||
def test_log_encoding_ignore_setting | |||
with_settings :commit_logs_encoding => 'windows-1252' do | |||
s2 = "\xc3\x82\xc2\x80".force_encoding('UTF-8') | |||
s2 = "Â\u0080" | |||
c = Changeset.new(:repository => @repository, | |||
:comments => s2, | |||
:revision => '123', |
@@ -60,13 +60,12 @@ class RepositoryTest < ActiveSupport::TestCase | |||
def test_blank_log_encoding_error_message_fr | |||
set_language_if_valid 'fr' | |||
str = "Encodage des messages de commit doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8') | |||
repo = Repository::Bazaar.new( | |||
:project => Project.find(3), | |||
:url => "/test" | |||
) | |||
assert !repo.save | |||
assert_include str, repo.errors.full_messages | |||
assert_include 'Encodage des messages de commit doit être renseigné(e)', repo.errors.full_messages | |||
end | |||
def test_create | |||
@@ -287,7 +286,7 @@ class RepositoryTest < ActiveSupport::TestCase | |||
:url => '/foo/bar/baz' ) | |||
long_whitespace = " " | |||
expected_comment = "This is a loooooooooooooooooooooooooooong comment" | |||
comment = "#{expected_comment}#{long_whitespace}\n" | |||
comment = +"#{expected_comment}#{long_whitespace}\n" | |||
3.times {comment << "#{long_whitespace}\n"} | |||
changeset = Changeset.new( | |||
:comments => comment, :commit_date => Time.now, |
@@ -82,7 +82,7 @@ class WikiTest < ActiveSupport::TestCase | |||
end | |||
def test_titleize | |||
ja_test = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88".force_encoding('UTF-8') | |||
ja_test = 'テスト' | |||
assert_equal 'Page_title_with_CAPITALES', Wiki.titleize('page title with CAPITALES') | |||
assert_equal ja_test, Wiki.titleize(ja_test) | |||
end |