Revision 442:753f1380d6bc test/unit/lib

View differences:

test/unit/lib/.svn/all-wcprops
1 1
K 25
2 2
svn:wc:ra_dav:version-url
3
V 38
4
/svn/!svn/ver/4964/trunk/test/unit/lib
3
V 52
4
/svn/!svn/ver/5878/branches/1.2-stable/test/unit/lib
5 5
END
6
redmine_test.rb
7
K 25
8
svn:wc:ra_dav:version-url
9
V 54
10
/svn/!svn/ver/4509/trunk/test/unit/lib/redmine_test.rb
11
END
test/unit/lib/.svn/entries
1 1
10
2 2

  
3 3
dir
4
4993
5
http://redmine.rubyforge.org/svn/trunk/test/unit/lib
4
6000
5
http://redmine.rubyforge.org/svn/branches/1.2-stable/test/unit/lib
6 6
http://redmine.rubyforge.org/svn
7 7

  
8 8

  
9 9

  
10
2011-02-28T14:12:47.115180Z
11
4964
10
2011-05-21T02:40:19.290757Z
11
5871
12 12
tmaruyama
13 13

  
14 14

  
......
35 35

  
36 36

  
37 37

  
38
2011-03-03T11:05:08.000000Z
38
2011-06-06T13:15:00.000000Z
39 39
eec42202798f1936d0e12c27f43f9add
40 40
2010-12-12T23:24:34.194336Z
41 41
4509
test/unit/lib/redmine/.svn/all-wcprops
1 1
K 25
2 2
svn:wc:ra_dav:version-url
3
V 46
4
/svn/!svn/ver/4964/trunk/test/unit/lib/redmine
3
V 60
4
/svn/!svn/ver/5878/branches/1.2-stable/test/unit/lib/redmine
5 5
END
6
wiki_formatting.rb
7
K 25
8
svn:wc:ra_dav:version-url
9
V 65
10
/svn/!svn/ver/4509/trunk/test/unit/lib/redmine/wiki_formatting.rb
11
END
12
menu_manager_test.rb
13
K 25
14
svn:wc:ra_dav:version-url
15
V 67
16
/svn/!svn/ver/4509/trunk/test/unit/lib/redmine/menu_manager_test.rb
17
END
18
plugin_test.rb
19
K 25
20
svn:wc:ra_dav:version-url
21
V 61
22
/svn/!svn/ver/4509/trunk/test/unit/lib/redmine/plugin_test.rb
23
END
24
i18n_test.rb
25
K 25
26
svn:wc:ra_dav:version-url
27
V 59
28
/svn/!svn/ver/4894/trunk/test/unit/lib/redmine/i18n_test.rb
29
END
30
hook_test.rb
31
K 25
32
svn:wc:ra_dav:version-url
33
V 59
34
/svn/!svn/ver/4509/trunk/test/unit/lib/redmine/hook_test.rb
35
END
36
access_control_test.rb
37
K 25
38
svn:wc:ra_dav:version-url
39
V 69
40
/svn/!svn/ver/4509/trunk/test/unit/lib/redmine/access_control_test.rb
41
END
42
safe_attributes_test.rb
43
K 25
44
svn:wc:ra_dav:version-url
45
V 70
46
/svn/!svn/ver/4509/trunk/test/unit/lib/redmine/safe_attributes_test.rb
47
END
48
themes_test.rb
49
K 25
50
svn:wc:ra_dav:version-url
51
V 61
52
/svn/!svn/ver/4509/trunk/test/unit/lib/redmine/themes_test.rb
53
END
54
configuration_test.rb
55
K 25
56
svn:wc:ra_dav:version-url
57
V 68
58
/svn/!svn/ver/4949/trunk/test/unit/lib/redmine/configuration_test.rb
59
END
60
mime_type_test.rb
61
K 25
62
svn:wc:ra_dav:version-url
63
V 64
64
/svn/!svn/ver/4509/trunk/test/unit/lib/redmine/mime_type_test.rb
65
END
66
ciphering_test.rb
67
K 25
68
svn:wc:ra_dav:version-url
69
V 64
70
/svn/!svn/ver/4950/trunk/test/unit/lib/redmine/ciphering_test.rb
71
END
72
unified_diff_test.rb
73
K 25
74
svn:wc:ra_dav:version-url
75
V 67
76
/svn/!svn/ver/4929/trunk/test/unit/lib/redmine/unified_diff_test.rb
77
END
78
notifiable_test.rb
79
K 25
80
svn:wc:ra_dav:version-url
81
V 65
82
/svn/!svn/ver/4509/trunk/test/unit/lib/redmine/notifiable_test.rb
83
END
test/unit/lib/redmine/.svn/entries
1 1
10
2 2

  
3 3
dir
4
4993
5
http://redmine.rubyforge.org/svn/trunk/test/unit/lib/redmine
4
6000
5
http://redmine.rubyforge.org/svn/branches/1.2-stable/test/unit/lib/redmine
6 6
http://redmine.rubyforge.org/svn
7 7

  
8 8

  
9 9

  
10
2011-02-28T14:12:47.115180Z
11
4964
10
2011-05-21T02:40:19.290757Z
11
5871
12 12
tmaruyama
13 13

  
14 14

  
......
32 32

  
33 33

  
34 34

  
35
2011-03-03T11:40:17.000000Z
36
4368129679eec86fab2cd631de3b8cc5
37
2011-02-20T14:56:37.399906Z
38
4894
39
jplang
35
2011-06-06T13:17:46.000000Z
36
f51e2bdf18df778a4462c9a477c720d5
37
2011-05-08T07:12:34.399007Z
38
5707
39
tmaruyama
40 40
has-props
41 41

  
42 42

  
......
58 58

  
59 59

  
60 60

  
61
4952
61
5261
62

63
export
64
dir
62 65

63 66
scm
64 67
dir
......
69 72

  
70 73

  
71 74

  
72
2011-03-03T11:05:08.000000Z
75
2011-06-06T13:15:00.000000Z
73 76
761d6ebcd277ba4a1d0a2216a7fe8925
74 77
2010-12-12T23:24:34.194336Z
75 78
4509
......
103 106

  
104 107

  
105 108

  
106
2011-03-03T11:05:08.000000Z
109
2011-06-06T13:15:00.000000Z
107 110
2e952466cca65bea9ea095ad2ec01811
108 111
2010-12-12T23:24:34.194336Z
109 112
4509
......
137 140

  
138 141

  
139 142

  
140
2011-03-03T11:05:08.000000Z
143
2011-06-06T13:15:00.000000Z
141 144
161e4b78a0d1cdfd67d5bd54f6480726
142 145
2010-12-12T23:24:34.194336Z
143 146
4509
......
180 183

  
181 184

  
182 185

  
183
2011-03-03T11:05:08.000000Z
186
2011-06-06T13:15:00.000000Z
184 187
d2f2e4457ed4eda1b5efb8a41a3de255
185 188
2010-12-12T23:24:34.194336Z
186 189
4509
......
214 217

  
215 218

  
216 219

  
217
2011-03-03T11:05:08.000000Z
220
2011-06-06T13:15:00.000000Z
218 221
1a6043d0994b5fb4a09f3962ab5542ce
219 222
2010-12-12T23:24:34.194336Z
220 223
4509
......
248 251

  
249 252

  
250 253

  
251
2011-03-03T11:05:08.000000Z
254
2011-06-06T13:15:00.000000Z
252 255
22afe4f1981d3d856beef3275f95f243
253 256
2010-12-12T23:24:34.194336Z
254 257
4509
......
282 285

  
283 286

  
284 287

  
285
2011-03-03T11:05:08.000000Z
288
2011-06-06T13:15:00.000000Z
286 289
6b610cfc1e3e51f457eea06a6e6fb9a0
287 290
2010-12-12T23:24:34.194336Z
288 291
4509
......
316 319

  
317 320

  
318 321

  
319
2011-03-03T11:05:08.000000Z
322
2011-06-06T13:15:00.000000Z
320 323
6682bde90d30369ef1d27b806391134f
321 324
2010-12-12T23:24:34.194336Z
322 325
4509
......
353 356

  
354 357

  
355 358

  
356
2011-03-03T11:40:17.000000Z
359
2011-06-06T13:15:00.000000Z
357 360
d96ffe5035b073e1dffdb3f01fe8e06e
358 361
2011-02-25T14:30:05.998365Z
359 362
4949
......
387 390

  
388 391

  
389 392

  
390
2011-03-03T11:40:17.000000Z
393
2011-06-06T13:15:00.000000Z
391 394
c2c353211cdd7cf9a87b9102e26b8d14
392 395
2011-02-26T13:09:25.657748Z
393 396
4950
......
421 424

  
422 425

  
423 426

  
424
2011-03-03T11:40:17.000000Z
425
6b58d3612b430c0757566b1cd6bfcda0
426
2011-02-23T07:03:45.049119Z
427
4929
428
tmaruyama
427
2011-06-06T13:18:32.000000Z
428
a821efaefd2d94d0b1be4ac66a0f6b7a
429
2011-03-11T20:23:29.177962Z
430
5094
431
jplang
429 432
has-props
430 433

  
431 434

  
......
447 450

  
448 451

  
449 452

  
450
2455
453
4750
451 454

452 455
notifiable_test.rb
453 456
file
......
455 458

  
456 459

  
457 460

  
458
2011-03-03T11:05:08.000000Z
459
562f9308fbaa71c0ef605a5cfe24d3a5
460
2010-12-12T23:24:34.194336Z
461
4509
462
jbbarth
461
2011-06-06T13:18:32.000000Z
462
56129dfa45c8b7d521d0d0dcf534c307
463
2011-03-04T14:32:58.878627Z
464
5003
465
jplang
463 466

  
464 467

  
465 468

  
......
481 484

  
482 485

  
483 486

  
484
1328
487
1347
485 488

test/unit/lib/redmine/.svn/text-base/i18n_test.rb.svn-base
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2009  Jean-Philippe Lang
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
......
20 20
class Redmine::I18nTest < ActiveSupport::TestCase
21 21
  include Redmine::I18n
22 22
  include ActionView::Helpers::NumberHelper
23
  
23

  
24 24
  def setup
25 25
    @hook_module = Redmine::Hook
26 26
  end
27
  
27

  
28 28
  def test_date_format_default
29 29
    set_language_if_valid 'en'
30 30
    today = Date.today
31
    Setting.date_format = ''    
31
    Setting.date_format = ''
32 32
    assert_equal I18n.l(today), format_date(today)
33 33
  end
34
  
34

  
35 35
  def test_date_format
36 36
    set_language_if_valid 'en'
37 37
    today = Date.today
38 38
    Setting.date_format = '%d %m %Y'
39 39
    assert_equal today.strftime('%d %m %Y'), format_date(today)
40 40
  end
41
  
41

  
42 42
  def test_date_and_time_for_each_language
43 43
    Setting.date_format = ''
44 44
    valid_languages.each do |lang|
......
47 47
        format_date(Date.today)
48 48
        format_time(Time.now)
49 49
        format_time(Time.now, false)
50
        assert_not_equal 'default', ::I18n.l(Date.today, :format => :default), "date.formats.default missing in #{lang}"
51
        assert_not_equal 'time',    ::I18n.l(Time.now, :format => :time),      "time.formats.time missing in #{lang}"
50
        assert_not_equal 'default', ::I18n.l(Date.today, :format => :default),
51
                         "date.formats.default missing in #{lang}"
52
        assert_not_equal 'time',    ::I18n.l(Time.now, :format => :time),
53
                         "time.formats.time missing in #{lang}"
52 54
      end
53 55
      assert l('date.day_names').is_a?(Array)
54 56
      assert_equal 7, l('date.day_names').size
55
      
57

  
56 58
      assert l('date.month_names').is_a?(Array)
57 59
      assert_equal 13, l('date.month_names').size
58 60
    end
59 61
  end
60
  
62

  
61 63
  def test_time_format
62 64
    set_language_if_valid 'en'
63 65
    now = Time.parse('2011-02-20 15:45:22')
......
66 68
        assert_equal '02/20/2011 15:45', format_time(now)
67 69
        assert_equal '15:45', format_time(now, false)
68 70
      end
69
      
70 71
      with_settings :date_format => '%Y-%m-%d' do
71 72
        assert_equal '2011-02-20 15:45', format_time(now)
72 73
        assert_equal '15:45', format_time(now, false)
73 74
      end
74 75
    end
75 76
  end
76
  
77

  
77 78
  def test_time_format_default
78 79
    set_language_if_valid 'en'
79 80
    now = Time.parse('2011-02-20 15:45:22')
......
82 83
        assert_equal '02/20/2011 03:45 pm', format_time(now)
83 84
        assert_equal '03:45 pm', format_time(now, false)
84 85
      end
85
      
86 86
      with_settings :date_format => '%Y-%m-%d' do
87 87
        assert_equal '2011-02-20 03:45 pm', format_time(now)
88 88
        assert_equal '03:45 pm', format_time(now, false)
89 89
      end
90 90
    end
91 91
  end
92
  
92

  
93 93
  def test_time_format
94 94
    set_language_if_valid 'en'
95 95
    now = Time.now
......
98 98
    assert_equal now.strftime('%d %m %Y %H %M'), format_time(now)
99 99
    assert_equal now.strftime('%H %M'), format_time(now, false)
100 100
  end
101
  
101

  
102 102
  def test_utc_time_format
103 103
    set_language_if_valid 'en'
104
    now = Time.now.utc
104
    now = Time.now
105 105
    Setting.date_format = '%d %m %Y'
106 106
    Setting.time_format = '%H %M'
107
    assert_equal Time.now.strftime('%d %m %Y %H %M'), format_time(now)
108
    assert_equal Time.now.strftime('%H %M'), format_time(now, false)
107
    assert_equal now.strftime('%d %m %Y %H %M'), format_time(now.utc)
108
    assert_equal now.strftime('%H %M'), format_time(now.utc, false)
109 109
  end
110
  
110

  
111 111
  def test_number_to_human_size_for_each_language
112 112
    valid_languages.each do |lang|
113 113
      set_language_if_valid lang
......
116 116
      end
117 117
    end
118 118
  end
119
  
119

  
120 120
  def test_valid_languages
121 121
    assert valid_languages.is_a?(Array)
122 122
    assert valid_languages.first.is_a?(Symbol)
123 123
  end
124
  
124

  
125 125
  def test_valid_language
126 126
    to_test = {'fr' => :fr,
127 127
               'Fr' => :fr,
......
129 129
               'zh-tw' => :"zh-TW",
130 130
               'zh-TW' => :"zh-TW",
131 131
               'zh-ZZ' => nil }
132
    
133 132
    to_test.each {|lang, expected| assert_equal expected, find_language(lang)}
134 133
  end
135
  
134

  
136 135
  def test_fallback
137 136
    ::I18n.backend.store_translations(:en, {:untranslated => "Untranslated string"})
138 137
    ::I18n.locale = 'en'
139 138
    assert_equal "Untranslated string", l(:untranslated)
140 139
    ::I18n.locale = 'fr'
141 140
    assert_equal "Untranslated string", l(:untranslated)
142
    
141

  
143 142
    ::I18n.backend.store_translations(:fr, {:untranslated => "Pas de traduction"})
144 143
    ::I18n.locale = 'en'
145 144
    assert_equal "Untranslated string", l(:untranslated)
146 145
    ::I18n.locale = 'fr'
147 146
    assert_equal "Pas de traduction", l(:untranslated)
148 147
  end
148

  
149
  def test_utf8
150
    set_language_if_valid 'ja'
151
    str_ja_yes  = "\xe3\x81\xaf\xe3\x81\x84"
152
    i18n_ja_yes = l(:general_text_Yes)
153
    if str_ja_yes.respond_to?(:force_encoding)
154
      str_ja_yes.force_encoding('UTF-8')
155
      assert_equal "UTF-8", i18n_ja_yes.encoding.to_s
156
    end
157
    assert_equal str_ja_yes, i18n_ja_yes
158
  end
149 159
end
test/unit/lib/redmine/.svn/text-base/notifiable_test.rb.svn-base
1
# redMine - project management software
2
# Copyright (C) 2006-2008  Jean-Philippe Lang
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
22 22
  end
23 23

  
24 24
  def test_all
25
    assert_equal 11, Redmine::Notifiable.all.length
25
    assert_equal 12, Redmine::Notifiable.all.length
26 26

  
27
    %w(issue_added issue_updated issue_note_added issue_status_updated issue_priority_updated news_added document_added file_added message_posted wiki_content_added wiki_content_updated).each do |notifiable|
27
    %w(issue_added issue_updated issue_note_added issue_status_updated issue_priority_updated news_added news_comment_added document_added file_added message_posted wiki_content_added wiki_content_updated).each do |notifiable|
28 28
      assert Redmine::Notifiable.all.collect(&:name).include?(notifiable), "missing #{notifiable}"
29 29
    end
30 30
  end
test/unit/lib/redmine/.svn/text-base/unified_diff_test.rb.svn-base
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2008  Jean-Philippe Lang
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
34 34
    assert_equal 2, diff.size
35 35
  end
36 36
  
37
  def test_inline_partials
38
    diff = Redmine::UnifiedDiff.new(read_diff_fixture('partials.diff'))
39
    assert_equal 1, diff.size
40
    diff = diff.first
41
    assert_equal 43, diff.size
42
    
43
    assert_equal [51, -1], diff[0].offsets
44
    assert_equal [51, -1], diff[1].offsets
45
    assert_equal 'Lorem ipsum dolor sit amet, consectetur adipiscing <span>elit</span>', diff[0].html_line
46
    assert_equal 'Lorem ipsum dolor sit amet, consectetur adipiscing <span>xx</span>', diff[1].html_line
47
    
48
    assert_nil diff[2].offsets
49
    assert_equal 'Praesent et sagittis dui. Vivamus ac diam diam', diff[2].html_line
50
    
51
    assert_equal [0, -14], diff[3].offsets
52
    assert_equal [0, -14], diff[4].offsets
53
    assert_equal '<span>Ut sed</span> auctor justo', diff[3].html_line
54
    assert_equal '<span>xxx</span> auctor justo', diff[4].html_line
55
    
56
    assert_equal [13, -19], diff[6].offsets
57
    assert_equal [13, -19], diff[7].offsets
58
    
59
    assert_equal [24, -8], diff[9].offsets
60
    assert_equal [24, -8], diff[10].offsets
61
    
62
    assert_equal [37, -1], diff[12].offsets
63
    assert_equal [37, -1], diff[13].offsets
64
    
65
    assert_equal [0, -38], diff[15].offsets
66
    assert_equal [0, -38], diff[16].offsets
67
  end
68
  
69
  def test_side_by_side_partials
70
    diff = Redmine::UnifiedDiff.new(read_diff_fixture('partials.diff'), :type => 'sbs')
71
    assert_equal 1, diff.size
72
    diff = diff.first
73
    assert_equal 32, diff.size
74
    
75
    assert_equal [51, -1], diff[0].offsets
76
    assert_equal 'Lorem ipsum dolor sit amet, consectetur adipiscing <span>elit</span>', diff[0].html_line_left
77
    assert_equal 'Lorem ipsum dolor sit amet, consectetur adipiscing <span>xx</span>', diff[0].html_line_right
78
    
79
    assert_nil diff[1].offsets
80
    assert_equal 'Praesent et sagittis dui. Vivamus ac diam diam', diff[1].html_line_left
81
    assert_equal 'Praesent et sagittis dui. Vivamus ac diam diam', diff[1].html_line_right
82
    
83
    assert_equal [0, -14], diff[2].offsets
84
    assert_equal '<span>Ut sed</span> auctor justo', diff[2].html_line_left
85
    assert_equal '<span>xxx</span> auctor justo', diff[2].html_line_right
86

  
87
    assert_equal [13, -19], diff[4].offsets
88
    assert_equal [24, -8], diff[6].offsets
89
    assert_equal [37, -1], diff[8].offsets
90
    assert_equal [0, -38], diff[10].offsets
91
    
92
  end
93
  
37 94
  def test_line_starting_with_dashes
38 95
    diff = Redmine::UnifiedDiff.new(<<-DIFF
39 96
--- old.txt Wed Nov 11 14:24:58 2009
test/unit/lib/redmine/export/pdf_test.rb
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
require File.expand_path('../../../../../test_helper', __FILE__)
19
require 'iconv'
20

  
21
class PdfTest < ActiveSupport::TestCase
22
  include Redmine::I18n
23

  
24
  def test_fix_text_encoding_nil
25
    set_language_if_valid 'ja'
26
    assert_equal 'CP932', l(:general_pdf_encoding)
27
    if RUBY_VERSION < '1.9'
28
      ic = Iconv.new(l(:general_pdf_encoding), 'UTF-8')
29
    end
30
    assert_equal '', Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, nil)
31
  end
32

  
33
  def test_rdm_pdf_iconv_cannot_convert_ja_cp932
34
    set_language_if_valid 'ja'
35
    assert_equal 'CP932', l(:general_pdf_encoding)
36
    if RUBY_VERSION < '1.9'
37
      ic = Iconv.new(l(:general_pdf_encoding), 'UTF-8')
38
    end
39
    utf8_txt_1  = "\xe7\x8b\x80\xe6\x85\x8b"
40
    utf8_txt_2  = "\xe7\x8b\x80\xe6\x85\x8b\xe7\x8b\x80"
41
    utf8_txt_3  = "\xe7\x8b\x80\xe7\x8b\x80\xe6\x85\x8b\xe7\x8b\x80"
42
    if utf8_txt_1.respond_to?(:force_encoding)
43
      txt_1 = Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, utf8_txt_1)
44
      txt_2 = Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, utf8_txt_2)
45
      txt_3 = Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, utf8_txt_3)
46
      assert_equal "?\x91\xd4", txt_1
47
      assert_equal "?\x91\xd4?", txt_2
48
      assert_equal "??\x91\xd4?", txt_3
49
      assert_equal "ASCII-8BIT", txt_1.encoding.to_s
50
      assert_equal "ASCII-8BIT", txt_2.encoding.to_s
51
      assert_equal "ASCII-8BIT", txt_3.encoding.to_s
52
    else
53
      assert_equal "???\x91\xd4",
54
                   Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, utf8_txt_1)
55
      assert_equal "???\x91\xd4???",
56
                   Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, utf8_txt_2)
57
      assert_equal "??????\x91\xd4???",
58
                   Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, utf8_txt_3)
59
    end
60
  end
61

  
62
  def test_rdm_pdf_iconv_invalid_utf8_should_be_replaced_en
63
    set_language_if_valid 'en'
64
    assert_equal 'UTF-8', l(:general_pdf_encoding)
65
    str1 = "Texte encod\xe9 en ISO-8859-1"
66
    str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test"
67
    str1.force_encoding("UTF-8") if str1.respond_to?(:force_encoding)
68
    str2.force_encoding("ASCII-8BIT") if str2.respond_to?(:force_encoding)
69
    if RUBY_VERSION < '1.9'
70
      ic = Iconv.new(l(:general_pdf_encoding), 'UTF-8')
71
    end
72
    txt_1 = Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, str1)
73
    txt_2 = Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, str2)
74
    if txt_1.respond_to?(:force_encoding)
75
      assert_equal "ASCII-8BIT", txt_1.encoding.to_s
76
      assert_equal "ASCII-8BIT", txt_2.encoding.to_s
77
    end
78
    assert_equal "Texte encod? en ISO-8859-1", txt_1
79
    assert_equal "?a?b?c?d?e test", txt_2
80
  end
81

  
82
  def test_rdm_pdf_iconv_invalid_utf8_should_be_replaced_ja
83
    set_language_if_valid 'ja'
84
    assert_equal 'CP932', l(:general_pdf_encoding)
85
    str1 = "Texte encod\xe9 en ISO-8859-1"
86
    str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test"
87
    str1.force_encoding("UTF-8") if str1.respond_to?(:force_encoding)
88
    str2.force_encoding("ASCII-8BIT") if str2.respond_to?(:force_encoding)
89
    if RUBY_VERSION < '1.9'
90
      ic = Iconv.new(l(:general_pdf_encoding), 'UTF-8')
91
    end
92
    txt_1 = Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, str1)
93
    txt_2 = Redmine::Export::PDF::RDMPdfEncoding::rdm_pdf_iconv(ic, str2)
94
    if txt_1.respond_to?(:force_encoding)
95
      assert_equal "ASCII-8BIT", txt_1.encoding.to_s
96
      assert_equal "ASCII-8BIT", txt_2.encoding.to_s
97
    end
98
    assert_equal "Texte encod? en ISO-8859-1", txt_1
99
    assert_equal "?a?b?c?d?e test", txt_2
100
  end
101
end
test/unit/lib/redmine/helpers/.svn/entries
1 1
10
2 2

  
3 3
dir
4
4993
5
http://redmine.rubyforge.org/svn/trunk/test/unit/lib/redmine/helpers
4
6000
5
http://redmine.rubyforge.org/svn/branches/1.2-stable/test/unit/lib/redmine/helpers
6 6
http://redmine.rubyforge.org/svn
7 7

  
8 8

  
9 9

  
10
2010-12-29T20:29:42.467534Z
11
4582
10
2011-03-28T17:35:20.425352Z
11
5236
12 12
jplang
13 13

  
14 14

  
......
26 26

  
27 27
e93f8b46-1217-0410-a6f0-8f06a7374b81
28 28

29
calendar_test.rb
30
file
31

  
32

  
33

  
34

  
35
2011-06-06T13:18:32.000000Z
36
5d9bda2d9476a944a5ff5e2c61cb41c8
37
2011-03-27T16:49:35.269584Z
38
5231
39
jplang
40
has-props
41

  
42

  
43

  
44

  
45

  
46

  
47

  
48

  
49

  
50

  
51

  
52

  
53

  
54

  
55

  
56

  
57

  
58

  
59

  
60

  
61
2371
62

29 63
gantt_test.rb
30 64
file
31 65

  
32 66

  
33 67

  
34 68

  
35
2011-03-03T11:05:08.000000Z
36
1d6b4373836fef676ab3a28235c140b8
37
2010-12-29T20:29:42.467534Z
38
4582
69
2011-06-06T13:18:32.000000Z
70
7eeeaf89c44d3c361193d131cc931b9b
71
2011-03-28T17:35:20.425352Z
72
5236
39 73
jplang
40 74

  
41 75

  
......
58 92

  
59 93

  
60 94

  
61
28117
95
29243
62 96

test/unit/lib/redmine/helpers/.svn/text-base/gantt_test.rb.svn-base
1
# redMine - project management software
2
# Copyright (C) 2006-2008  Jean-Philippe Lang
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
95 95
    setup do
96 96
      create_gantt
97 97
    end
98
    
99
    should "clear the @query.project so cross-project issues and versions can be counted" do
100
      assert @gantt.query.project
101
      @gantt.number_of_rows_on_project(@project)
102
      assert_nil @gantt.query.project
103
    end
104 98

  
105
    should "count 1 for the project itself" do
106
      assert_equal 1, @gantt.number_of_rows_on_project(@project)
99
    should "count 0 for an empty the project" do
100
      assert_equal 0, @gantt.number_of_rows_on_project(@project)
107 101
    end
108 102

  
109 103
    should "count the number of issues without a version" do
......
111 105
      assert_equal 2, @gantt.number_of_rows_on_project(@project)
112 106
    end
113 107

  
114
    should "count the number of versions" do
115
      @project.versions << Version.generate!
116
      @project.versions << Version.generate!
117
      assert_equal 3, @gantt.number_of_rows_on_project(@project)
118
    end
119

  
120 108
    should "count the number of issues on versions, including cross-project" do
121 109
      version = Version.generate!
122 110
      @project.versions << version
......
124 112
      
125 113
      assert_equal 3, @gantt.number_of_rows_on_project(@project)
126 114
    end
127
    
128
    should "recursive and count the number of rows on each subproject" do
129
      @project.versions << Version.generate! # +1
130

  
131
      @subproject = Project.generate!(:enabled_module_names => ['issue_tracking']) # +1
132
      @subproject.set_parent!(@project)
133
      @subproject.issues << Issue.generate_for_project!(@subproject) # +1
134
      @subproject.issues << Issue.generate_for_project!(@subproject) # +1
135

  
136
      @subsubproject = Project.generate!(:enabled_module_names => ['issue_tracking']) # +1
137
      @subsubproject.set_parent!(@subproject)
138
      @subsubproject.issues << Issue.generate_for_project!(@subsubproject) # +1
139

  
140
      assert_equal 7, @gantt.number_of_rows_on_project(@project) # +1 for self
141
    end
142 115
  end
143 116

  
144 117
  # TODO: more of an integration test
......
183 156
        @response.body = @gantt.subjects
184 157
        assert_select "div.version-name[style*=left:24px]"
185 158
      end
159
      
160
      context "without assigned issues" do
161
        setup do
162
          @version = Version.generate!(:effective_date => 2.week.from_now.to_date, :sharing => 'none', :name => 'empty_version')
163
          @project.versions << @version
164
        end
165
      
166
        should "not be rendered" do
167
          @response.body = @gantt.subjects
168
          assert_select "div.version-name a", :text => /#{@version.name}/, :count => 0
169
        end
170
      end
186 171
    end
187 172
  
188 173
    context "issue" do
......
196 181
        assert_select "div.issue-subject[style*=left:44px]"
197 182
      end
198 183
      
184
      context "assigned to a shared version of another project" do
185
        setup do
186
          p = Project.generate!
187
          p.trackers << @tracker
188
          p.enabled_module_names = [:issue_tracking]
189
          @shared_version = Version.generate!(:sharing => 'system')
190
          p.versions << @shared_version
191
          # Reassign the issue to a shared version of another project
192
          
193
          @issue = Issue.generate!(:fixed_version => @shared_version,
194
                                   :subject => "gantt#assigned_to_shared_version",
195
                                   :tracker => @tracker,
196
                                   :project => @project,
197
                                   :done_ratio => 30,
198
                                   :start_date => Date.yesterday,
199
                                   :due_date => 1.week.from_now.to_date)
200
          @project.issues << @issue
201
        end
202
        
203
        should "be rendered" do
204
          @response.body = @gantt.subjects
205
          assert_select "div.issue-subject", /#{@issue.subject}/
206
        end
207
      end
208
      
199 209
      context "with subtasks" do
200 210
        setup do
201 211
          attrs = {:project => @project, :tracker => @tracker, :fixed_version => @version}
......
537 547
          assert_select "div.version.task_done[style*=left:28px]", true, @response.body
538 548
        end
539 549

  
540
        should "Be the total done width of the version"  do
550
        should "be the total done width of the version"  do
541 551
          @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
542
          assert_select "div.version.task_done[style*=width:18px]", true, @response.body
552
          assert_select "div.version.task_done[style*=width:16px]", true, @response.body
543 553
        end
544 554
      end
545 555

  
......
697 707
          assert_select "div.task_done[style*=left:28px]", true, @response.body
698 708
        end
699 709

  
700
        should "Be the total done width of the issue"  do
710
        should "be the total done width of the issue"  do
701 711
          @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
702
          assert_select "div.task_done[style*=width:18px]", true, @response.body
712
          # 15 days * 4 px * 30% - 2 px for borders = 16 px
713
          assert_select "div.task_done[style*=width:16px]", true, @response.body
703 714
        end
704 715

  
705 716
        should "not be the total done width if the chart starts after issue start date"  do
......
707 718
          
708 719
          @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
709 720
          assert_select "div.task_done[style*=left:0px]", true, @response.body
710
          assert_select "div.task_done[style*=width:10px]", true, @response.body
721
          assert_select "div.task_done[style*=width:8px]", true, @response.body
722
        end
723
        
724
        context "for completed issue" do
725
          setup do
726
            @issue.done_ratio = 100
727
          end
728

  
729
          should "be the total width of the issue"  do
730
            @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
731
            assert_select "div.task_done[style*=width:58px]", true, @response.body
732
          end
733
  
734
          should "be the total width of the issue with due_date=start_date"  do
735
            @issue.due_date = @issue.start_date
736
            @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
737
            assert_select "div.task_done[style*=width:2px]", true, @response.body
738
          end
711 739
        end
712 740
      end
713 741

  
test/unit/lib/redmine/helpers/calendar_test.rb
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
# 
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
# 
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
require File.expand_path('../../../../../test_helper', __FILE__)
19

  
20
class CalendarTest < ActiveSupport::TestCase
21
  
22
  def test_monthly
23
    c = Redmine::Helpers::Calendar.new(Date.today, :fr, :month)
24
    assert_equal [1, 7], [c.startdt.cwday, c.enddt.cwday]
25
    
26
    c = Redmine::Helpers::Calendar.new('2007-07-14'.to_date, :fr, :month)
27
    assert_equal ['2007-06-25'.to_date, '2007-08-05'.to_date], [c.startdt, c.enddt]   
28
     
29
    c = Redmine::Helpers::Calendar.new(Date.today, :en, :month)
30
    assert_equal [7, 6], [c.startdt.cwday, c.enddt.cwday]
31
  end
32

  
33
  def test_weekly
34
    c = Redmine::Helpers::Calendar.new(Date.today, :fr, :week)
35
    assert_equal [1, 7], [c.startdt.cwday, c.enddt.cwday]
36
    
37
    c = Redmine::Helpers::Calendar.new('2007-07-14'.to_date, :fr, :week)
38
    assert_equal ['2007-07-09'.to_date, '2007-07-15'.to_date], [c.startdt, c.enddt]
39

  
40
    c = Redmine::Helpers::Calendar.new(Date.today, :en, :week)
41
    assert_equal [7, 6], [c.startdt.cwday, c.enddt.cwday]
42
  end
43
  
44
  def test_monthly_start_day
45
    [1, 6, 7].each do |day|
46
      with_settings :start_of_week => day do
47
        c = Redmine::Helpers::Calendar.new(Date.today, :en, :month)
48
        assert_equal day , c.startdt.cwday
49
        assert_equal (day + 5) % 7 + 1, c.enddt.cwday
50
      end
51
    end
52
  end
53
  
54
  def test_weekly_start_day
55
    [1, 6, 7].each do |day|
56
      with_settings :start_of_week => day do
57
        c = Redmine::Helpers::Calendar.new(Date.today, :en, :week)
58
        assert_equal day, c.startdt.cwday
59
        assert_equal (day + 5) % 7 + 1, c.enddt.cwday
60
      end
61
    end
62
  end
63
end
test/unit/lib/redmine/helpers/gantt_test.rb
1
# redMine - project management software
2
# Copyright (C) 2006-2008  Jean-Philippe Lang
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
95 95
    setup do
96 96
      create_gantt
97 97
    end
98
    
99
    should "clear the @query.project so cross-project issues and versions can be counted" do
100
      assert @gantt.query.project
101
      @gantt.number_of_rows_on_project(@project)
102
      assert_nil @gantt.query.project
103
    end
104 98

  
105
    should "count 1 for the project itself" do
106
      assert_equal 1, @gantt.number_of_rows_on_project(@project)
99
    should "count 0 for an empty the project" do
100
      assert_equal 0, @gantt.number_of_rows_on_project(@project)
107 101
    end
108 102

  
109 103
    should "count the number of issues without a version" do
......
111 105
      assert_equal 2, @gantt.number_of_rows_on_project(@project)
112 106
    end
113 107

  
114
    should "count the number of versions" do
115
      @project.versions << Version.generate!
116
      @project.versions << Version.generate!
117
      assert_equal 3, @gantt.number_of_rows_on_project(@project)
118
    end
119

  
120 108
    should "count the number of issues on versions, including cross-project" do
121 109
      version = Version.generate!
122 110
      @project.versions << version
......
124 112
      
125 113
      assert_equal 3, @gantt.number_of_rows_on_project(@project)
126 114
    end
127
    
128
    should "recursive and count the number of rows on each subproject" do
129
      @project.versions << Version.generate! # +1
130

  
131
      @subproject = Project.generate!(:enabled_module_names => ['issue_tracking']) # +1
132
      @subproject.set_parent!(@project)
133
      @subproject.issues << Issue.generate_for_project!(@subproject) # +1
134
      @subproject.issues << Issue.generate_for_project!(@subproject) # +1
135

  
136
      @subsubproject = Project.generate!(:enabled_module_names => ['issue_tracking']) # +1
137
      @subsubproject.set_parent!(@subproject)
138
      @subsubproject.issues << Issue.generate_for_project!(@subsubproject) # +1
139

  
140
      assert_equal 7, @gantt.number_of_rows_on_project(@project) # +1 for self
141
    end
142 115
  end
143 116

  
144 117
  # TODO: more of an integration test
......
183 156
        @response.body = @gantt.subjects
184 157
        assert_select "div.version-name[style*=left:24px]"
185 158
      end
159
      
160
      context "without assigned issues" do
161
        setup do
162
          @version = Version.generate!(:effective_date => 2.week.from_now.to_date, :sharing => 'none', :name => 'empty_version')
163
          @project.versions << @version
164
        end
165
      
166
        should "not be rendered" do
167
          @response.body = @gantt.subjects
168
          assert_select "div.version-name a", :text => /#{@version.name}/, :count => 0
169
        end
170
      end
186 171
    end
187 172
  
188 173
    context "issue" do
......
196 181
        assert_select "div.issue-subject[style*=left:44px]"
197 182
      end
198 183
      
184
      context "assigned to a shared version of another project" do
185
        setup do
186
          p = Project.generate!
187
          p.trackers << @tracker
188
          p.enabled_module_names = [:issue_tracking]
189
          @shared_version = Version.generate!(:sharing => 'system')
190
          p.versions << @shared_version
191
          # Reassign the issue to a shared version of another project
192
          
193
          @issue = Issue.generate!(:fixed_version => @shared_version,
194
                                   :subject => "gantt#assigned_to_shared_version",
195
                                   :tracker => @tracker,
196
                                   :project => @project,
197
                                   :done_ratio => 30,
198
                                   :start_date => Date.yesterday,
199
                                   :due_date => 1.week.from_now.to_date)
200
          @project.issues << @issue
201
        end
202
        
203
        should "be rendered" do
204
          @response.body = @gantt.subjects
205
          assert_select "div.issue-subject", /#{@issue.subject}/
206
        end
207
      end
208
      
199 209
      context "with subtasks" do
200 210
        setup do
201 211
          attrs = {:project => @project, :tracker => @tracker, :fixed_version => @version}
......
537 547
          assert_select "div.version.task_done[style*=left:28px]", true, @response.body
538 548
        end
539 549

  
540
        should "Be the total done width of the version"  do
550
        should "be the total done width of the version"  do
541 551
          @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
542
          assert_select "div.version.task_done[style*=width:18px]", true, @response.body
552
          assert_select "div.version.task_done[style*=width:16px]", true, @response.body
543 553
        end
544 554
      end
545 555

  
......
697 707
          assert_select "div.task_done[style*=left:28px]", true, @response.body
698 708
        end
699 709

  
700
        should "Be the total done width of the issue"  do
710
        should "be the total done width of the issue"  do
701 711
          @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
702
          assert_select "div.task_done[style*=width:18px]", true, @response.body
712
          # 15 days * 4 px * 30% - 2 px for borders = 16 px
713
          assert_select "div.task_done[style*=width:16px]", true, @response.body
703 714
        end
704 715

  
705 716
        should "not be the total done width if the chart starts after issue start date"  do
......
707 718
          
708 719
          @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
709 720
          assert_select "div.task_done[style*=left:0px]", true, @response.body
710
          assert_select "div.task_done[style*=width:10px]", true, @response.body
721
          assert_select "div.task_done[style*=width:8px]", true, @response.body
722
        end
723
        
724
        context "for completed issue" do
725
          setup do
726
            @issue.done_ratio = 100
727
          end
728

  
729
          should "be the total width of the issue"  do
730
            @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
731
            assert_select "div.task_done[style*=width:58px]", true, @response.body
732
          end
733
  
734
          should "be the total width of the issue with due_date=start_date"  do
735
            @issue.due_date = @issue.start_date
736
            @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
737
            assert_select "div.task_done[style*=width:2px]", true, @response.body
738
          end
711 739
        end
712 740
      end
713 741

  
test/unit/lib/redmine/i18n_test.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2009  Jean-Philippe Lang
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
......
20 20
class Redmine::I18nTest < ActiveSupport::TestCase
21 21
  include Redmine::I18n
22 22
  include ActionView::Helpers::NumberHelper
23
  
23

  
24 24
  def setup
25 25
    @hook_module = Redmine::Hook
26 26
  end
27
  
27

  
28 28
  def test_date_format_default
29 29
    set_language_if_valid 'en'
30 30
    today = Date.today
31
    Setting.date_format = ''    
31
    Setting.date_format = ''
32 32
    assert_equal I18n.l(today), format_date(today)
33 33
  end
34
  
34

  
35 35
  def test_date_format
36 36
    set_language_if_valid 'en'
37 37
    today = Date.today
38 38
    Setting.date_format = '%d %m %Y'
39 39
    assert_equal today.strftime('%d %m %Y'), format_date(today)
40 40
  end
41
  
41

  
42 42
  def test_date_and_time_for_each_language
43 43
    Setting.date_format = ''
44 44
    valid_languages.each do |lang|
......
47 47
        format_date(Date.today)
48 48
        format_time(Time.now)
49 49
        format_time(Time.now, false)
50
        assert_not_equal 'default', ::I18n.l(Date.today, :format => :default), "date.formats.default missing in #{lang}"
51
        assert_not_equal 'time',    ::I18n.l(Time.now, :format => :time),      "time.formats.time missing in #{lang}"
50
        assert_not_equal 'default', ::I18n.l(Date.today, :format => :default),
51
                         "date.formats.default missing in #{lang}"
52
        assert_not_equal 'time',    ::I18n.l(Time.now, :format => :time),
53
                         "time.formats.time missing in #{lang}"
52 54
      end
53 55
      assert l('date.day_names').is_a?(Array)
54 56
      assert_equal 7, l('date.day_names').size
55
      
57

  
56 58
      assert l('date.month_names').is_a?(Array)
57 59
      assert_equal 13, l('date.month_names').size
58 60
    end
59 61
  end
60
  
62

  
61 63
  def test_time_format
62 64
    set_language_if_valid 'en'
63 65
    now = Time.parse('2011-02-20 15:45:22')
......
66 68
        assert_equal '02/20/2011 15:45', format_time(now)
67 69
        assert_equal '15:45', format_time(now, false)
68 70
      end
69
      
70 71
      with_settings :date_format => '%Y-%m-%d' do
71 72
        assert_equal '2011-02-20 15:45', format_time(now)
72 73
        assert_equal '15:45', format_time(now, false)
73 74
      end
74 75
    end
75 76
  end
76
  
77

  
77 78
  def test_time_format_default
78 79
    set_language_if_valid 'en'
79 80
    now = Time.parse('2011-02-20 15:45:22')
......
82 83
        assert_equal '02/20/2011 03:45 pm', format_time(now)
83 84
        assert_equal '03:45 pm', format_time(now, false)
84 85
      end
85
      
86 86
      with_settings :date_format => '%Y-%m-%d' do
87 87
        assert_equal '2011-02-20 03:45 pm', format_time(now)
88 88
        assert_equal '03:45 pm', format_time(now, false)
89 89
      end
90 90
    end
91 91
  end
92
  
92

  
93 93
  def test_time_format
94 94
    set_language_if_valid 'en'
95 95
    now = Time.now
......
98 98
    assert_equal now.strftime('%d %m %Y %H %M'), format_time(now)
99 99
    assert_equal now.strftime('%H %M'), format_time(now, false)
100 100
  end
101
  
101

  
102 102
  def test_utc_time_format
103 103
    set_language_if_valid 'en'
104
    now = Time.now.utc
104
    now = Time.now
105 105
    Setting.date_format = '%d %m %Y'
106 106
    Setting.time_format = '%H %M'
107
    assert_equal Time.now.strftime('%d %m %Y %H %M'), format_time(now)
108
    assert_equal Time.now.strftime('%H %M'), format_time(now, false)
107
    assert_equal now.strftime('%d %m %Y %H %M'), format_time(now.utc)
108
    assert_equal now.strftime('%H %M'), format_time(now.utc, false)
109 109
  end
110
  
110

  
111 111
  def test_number_to_human_size_for_each_language
112 112
    valid_languages.each do |lang|
113 113
      set_language_if_valid lang
......
116 116
      end
117 117
    end
118 118
  end
119
  
119

  
120 120
  def test_valid_languages
121 121
    assert valid_languages.is_a?(Array)
122 122
    assert valid_languages.first.is_a?(Symbol)
123 123
  end
124
  
124

  
125 125
  def test_valid_language
126 126
    to_test = {'fr' => :fr,
127 127
               'Fr' => :fr,
......
129 129
               'zh-tw' => :"zh-TW",
130 130
               'zh-TW' => :"zh-TW",
131 131
               'zh-ZZ' => nil }
132
    
133 132
    to_test.each {|lang, expected| assert_equal expected, find_language(lang)}
134 133
  end
135
  
134

  
136 135
  def test_fallback
137 136
    ::I18n.backend.store_translations(:en, {:untranslated => "Untranslated string"})
138 137
    ::I18n.locale = 'en'
139 138
    assert_equal "Untranslated string", l(:untranslated)
140 139
    ::I18n.locale = 'fr'
141 140
    assert_equal "Untranslated string", l(:untranslated)
142
    
141

  
143 142
    ::I18n.backend.store_translations(:fr, {:untranslated => "Pas de traduction"})
144 143
    ::I18n.locale = 'en'
145 144
    assert_equal "Untranslated string", l(:untranslated)
146 145
    ::I18n.locale = 'fr'
147 146
    assert_equal "Pas de traduction", l(:untranslated)
148 147
  end
148

  
149
  def test_utf8
150
    set_language_if_valid 'ja'
151
    str_ja_yes  = "\xe3\x81\xaf\xe3\x81\x84"
152
    i18n_ja_yes = l(:general_text_Yes)
153
    if str_ja_yes.respond_to?(:force_encoding)
154
      str_ja_yes.force_encoding('UTF-8')
155
      assert_equal "UTF-8", i18n_ja_yes.encoding.to_s
156
    end
157
    assert_equal str_ja_yes, i18n_ja_yes
158
  end
149 159
end
test/unit/lib/redmine/menu_manager/.svn/entries
1 1
10
2 2

  
3 3
dir
4
4993
5
http://redmine.rubyforge.org/svn/trunk/test/unit/lib/redmine/menu_manager
4
6000
5
http://redmine.rubyforge.org/svn/branches/1.2-stable/test/unit/lib/redmine/menu_manager
6 6
http://redmine.rubyforge.org/svn
7 7

  
8 8

  
......
32 32

  
33 33

  
34 34

  
35
2011-03-03T11:05:08.000000Z
35
2011-06-06T13:15:00.000000Z
36 36
fdf6a6902bb3de694d7a4fabbdfe2798
37 37
2010-12-12T23:24:34.194336Z
38 38
4509
......
66 66

  
67 67

  
68 68

  
69
2011-03-03T11:05:08.000000Z
69
2011-06-06T13:15:00.000000Z
70 70
fdde38850555e88b18c742d7d15be035
71 71
2010-12-12T23:24:34.194336Z
72 72
4509
......
100 100

  
101 101

  
102 102

  
103
2011-03-03T11:05:08.000000Z
103
2011-06-06T13:15:00.000000Z
104 104
18c96ac64de73c38eb9d766226b34ca7
105 105
2010-12-12T23:24:34.194336Z
106 106
4509
test/unit/lib/redmine/notifiable_test.rb
1
# redMine - project management software
2
# Copyright (C) 2006-2008  Jean-Philippe Lang
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
22 22
  end
23 23

  
24 24
  def test_all
25
    assert_equal 11, Redmine::Notifiable.all.length
25
    assert_equal 12, Redmine::Notifiable.all.length
26 26

  
27
    %w(issue_added issue_updated issue_note_added issue_status_updated issue_priority_updated news_added document_added file_added message_posted wiki_content_added wiki_content_updated).each do |notifiable|
27
    %w(issue_added issue_updated issue_note_added issue_status_updated issue_priority_updated news_added news_comment_added document_added file_added message_posted wiki_content_added wiki_content_updated).each do |notifiable|
28 28
      assert Redmine::Notifiable.all.collect(&:name).include?(notifiable), "missing #{notifiable}"
29 29
    end
30 30
  end
test/unit/lib/redmine/scm/.svn/entries
1 1
10
2 2

  
3 3
dir
4
4993
5
http://redmine.rubyforge.org/svn/trunk/test/unit/lib/redmine/scm
4
6000
5
http://redmine.rubyforge.org/svn/branches/1.2-stable/test/unit/lib/redmine/scm
6 6
http://redmine.rubyforge.org/svn
7 7

  
8 8

  
9 9

  
10
2011-02-28T14:12:47.115180Z
11
4964
10
2011-05-21T02:40:19.290757Z
11
5871
12 12
tmaruyama
13 13

  
14 14

  
test/unit/lib/redmine/scm/adapters/.svn/entries
1 1
10
2 2

  
3 3
dir
4
4993
5
http://redmine.rubyforge.org/svn/trunk/test/unit/lib/redmine/scm/adapters
4
6000
5
http://redmine.rubyforge.org/svn/branches/1.2-stable/test/unit/lib/redmine/scm/adapters
6 6
http://redmine.rubyforge.org/svn
7 7

  
8 8

  
9 9

  
10
2011-02-28T14:12:47.115180Z
11
4964
10
2011-05-21T02:40:19.290757Z
11
5871
12 12
tmaruyama
13 13

  
14 14

  
......
32 32

  
33 33

  
34 34

  
35
2011-03-03T11:40:17.000000Z
36
f0de1284b35555e358dcb810fff1e7e5
37
2011-02-15T02:12:39.628343Z
38
4825
35
2011-06-06T13:17:45.000000Z
36
f557b1bd1a675ea916f153007ba3b63b
37
2011-05-13T06:18:18.001804Z
38
5782
39 39
tmaruyama
40 40
has-props
41 41

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff