Project

General

Profile

Patch #31059 » tests.patch

Pavel Rosický, 2019-03-19 18:39

View differences:

changeset_test.rb (working copy)
448 448

  
449 449
  def test_comments_should_be_converted_to_utf8
450 450
    proj = Project.find(3)
451
    str = (+"Texte encod\xe9 en ISO-8859-1.").force_encoding("ASCII-8BIT")
451
    str = "Texte encod\xe9 en ISO-8859-1.".b
452 452
    r = Repository::Bazaar.create!(
453 453
            :project      => proj,
454 454
            :url          => '/tmp/test/bazaar',
......
465 465

  
466 466
  def test_invalid_utf8_sequences_in_comments_should_be_replaced_latin1
467 467
    proj = Project.find(3)
468
    str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT")
468
    str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".b
469 469
    r = Repository::Bazaar.create!(
470 470
            :project      => proj,
471 471
            :url          => '/tmp/test/bazaar',
......
484 484

  
485 485
  def test_invalid_utf8_sequences_in_comments_should_be_replaced_ja_jis
486 486
    proj = Project.find(3)
487
    str = (+"test\xb5\xfetest\xb5\xfe").force_encoding('ASCII-8BIT')
487
    str = "test\xb5\xfetest\xb5\xfe".b
488 488
    r = Repository::Bazaar.create!(
489 489
            :project      => proj,
490 490
            :url          => '/tmp/test/bazaar',
......
504 504
    s2 = +"\xc3\x82\xc2\x80"
505 505
    s4 = s2.dup
506 506
    s3 = s1.dup
507
    s1.force_encoding('ASCII-8BIT')
508
    s2.force_encoding('ASCII-8BIT')
507
    s1 = s1.b
508
    s2 = s2.b
509 509
    s3.force_encoding('ISO-8859-1')
510 510
    s4.force_encoding('UTF-8')
511 511
    assert_equal s3.encode('UTF-8'), s4
......
526 526

  
527 527
  def test_invalid_utf8_sequences_in_paths_should_be_replaced
528 528
    proj = Project.find(3)
529
    str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT")
529
    str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".b
530 530
    r = Repository::Bazaar.create!(
531 531
            :project => proj,
532 532
            :url => '/tmp/test/bazaar',
custom_field_test.rb (working copy)
107 107

  
108 108
  def test_possible_values_should_return_utf8_encoded_strings
109 109
    field = CustomField.new
110
    s = (+"Value").force_encoding('BINARY')
110
    s = "Value".b
111 111
    field.possible_values = s
112 112
    assert_equal [s], field.possible_values
113 113
    assert_equal 'UTF-8', field.possible_values.first.encoding.name
lib/redmine/codeset_util_test.rb (working copy)
24 24
  def test_to_utf8_by_setting_from_latin1
25 25
    with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
26 26
      s1 = 'Texte encodé'
27
      s2 = (+"Texte encod\xe9").force_encoding("ASCII-8BIT")
27
      s2 = "Texte encod\xe9".b
28 28
      s3 = s2.dup.force_encoding("UTF-8")
29 29
      assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s2)
30 30
      assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s3)
......
34 34
  def test_to_utf8_by_setting_from_euc_jp
35 35
    with_settings :repositories_encodings => 'UTF-8,EUC-JP' do
36 36
      s1 = 'レッドマイン'
37
      s2 = (+"\xa5\xec\xa5\xc3\xa5\xc9\xa5\xde\xa5\xa4\xa5\xf3").force_encoding("ASCII-8BIT")
37
      s2 = "\xa5\xec\xa5\xc3\xa5\xc9\xa5\xde\xa5\xa4\xa5\xf3".b
38 38
      s3 = s2.dup.force_encoding("UTF-8")
39 39
      assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s2)
40 40
      assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s3)
......
44 44
  def test_to_utf8_by_setting_should_be_converted_all_latin1
45 45
    with_settings :repositories_encodings => 'ISO-8859-1' do
46 46
      s1 = "Â\u0080"
47
      s2 = (+"\xC2\x80").force_encoding("ASCII-8BIT")
47
      s2 = "\xC2\x80".b
48 48
      s3 = s2.dup.force_encoding("UTF-8")
49 49
      assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s2)
50 50
      assert_equal s1, Redmine::CodesetUtil.to_utf8_by_setting(s3)
......
69 69

  
70 70
  def test_to_utf8_by_setting_invalid_utf8_sequences_should_be_stripped
71 71
    with_settings :repositories_encodings => '' do
72
      s1 = (+"Texte encod\xe9 en ISO-8859-1.").force_encoding("ASCII-8BIT")
72
      s1 = "Texte encod\xe9 en ISO-8859-1.".b
73 73
      str = Redmine::CodesetUtil.to_utf8_by_setting(s1)
74 74
      assert str.valid_encoding?
75 75
      assert_equal "UTF-8", str.encoding.to_s
......
79 79

  
80 80
  def test_to_utf8_by_setting_invalid_utf8_sequences_should_be_stripped_ja_jis
81 81
    with_settings :repositories_encodings => 'ISO-2022-JP' do
82
      s1 = (+"test\xb5\xfetest\xb5\xfe").force_encoding("ASCII-8BIT")
82
      s1 = "test\xb5\xfetest\xb5\xfe".b
83 83
      str = Redmine::CodesetUtil.to_utf8_by_setting(s1)
84 84
      assert str.valid_encoding?
85 85
      assert_equal "UTF-8", str.encoding.to_s
lib/redmine/export/pdf_test.rb (working copy)
36 36
      txt_1 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(utf8_txt_1, encoding)
37 37
      txt_2 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(utf8_txt_2, encoding)
38 38
      txt_3 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(utf8_txt_3, encoding)
39
      assert_equal (+"?\x91\xd4").force_encoding("ASCII-8BIT"), txt_1
40
      assert_equal (+"?\x91\xd4?").force_encoding("ASCII-8BIT"), txt_2
41
      assert_equal (+"??\x91\xd4?").force_encoding("ASCII-8BIT"), txt_3
39
      assert_equal "?\x91\xd4".b, txt_1
40
      assert_equal "?\x91\xd4?".b, txt_2
41
      assert_equal "??\x91\xd4?".b, txt_3
42 42
      assert_equal "ASCII-8BIT", txt_1.encoding.to_s
43 43
      assert_equal "ASCII-8BIT", txt_2.encoding.to_s
44 44
      assert_equal "ASCII-8BIT", txt_3.encoding.to_s
......
47 47

  
48 48
  def test_rdm_pdf_iconv_invalid_utf8_should_be_replaced_en
49 49
    str1 = "Texte encod\xE9 en ISO-8859-1"
50
    str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT")
50
    str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".b
51 51
    txt_1 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str1, 'UTF-8')
52 52
    txt_2 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str2, 'UTF-8')
53 53
    assert_equal "ASCII-8BIT", txt_1.encoding.to_s
......
58 58

  
59 59
  def test_rdm_pdf_iconv_invalid_utf8_should_be_replaced_ja
60 60
    str1 = "Texte encod\xE9 en ISO-8859-1"
61
    str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT")
61
    str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".b
62 62
    encoding = ( RUBY_PLATFORM == 'java' ? "SJIS" : "CP932" )
63 63
    txt_1 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str1, encoding)
64 64
    txt_2 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str2, encoding)
......
72 72
    ["CP932", "SJIS"].each do |encoding|
73 73
      set_fixtures_attachments_directory
74 74

  
75
      str2 = (+"\x83e\x83X\x83g").force_encoding("ASCII-8BIT")
75
      str2 = "\x83e\x83X\x83g".b
76 76

  
77 77
      a1 = Attachment.find(17)
78 78
      a2 = Attachment.find(19)
lib/redmine/scm/adapters/git_adapter_test.rb (working copy)
58 58
                 )
59 59
      assert @adapter
60 60
      @char_1 = 'Ü'
61
      @str_felix_hex  = (+"Felix Sch\xC3\xA4fer").force_encoding('ASCII-8BIT')
61
      @str_felix_hex  = "Felix Sch\xC3\xA4fer".b
62 62
    end
63 63

  
64 64
    def test_scm_version
repository_bazaar_test.rb (working copy)
47 47
                             Encoding.locale_charmap == "ISO-8859-1")
48 48

  
49 49
  CHAR_1_UTF8_HEX   = 'Ü'
50
  CHAR_1_LATIN1_HEX = (+"\xdc").force_encoding('ASCII-8BIT')
50
  CHAR_1_LATIN1_HEX = "\xdc".b
51 51

  
52 52
  def setup
53 53
    User.current = nil
(2-2/4)