Mercurial > hg > soundsoftware-site
comparison test/unit/lib/redmine/.svn/text-base/i18n_test.rb.svn-base @ 119:8661b858af72
* Update to Redmine trunk rev 4705
author | Chris Cannam |
---|---|
date | Thu, 13 Jan 2011 14:12:06 +0000 |
parents | 94944d00e43c |
children | cd2282d2aa55 051f544170fe |
comparison
equal
deleted
inserted
replaced
39:150ceac17a8d | 119:8661b858af72 |
---|---|
13 # | 13 # |
14 # You should have received a copy of the GNU General Public License | 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 | 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. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 require File.dirname(__FILE__) + '/../../../test_helper' | 18 require File.expand_path('../../../../test_helper', __FILE__) |
19 | 19 |
20 class Redmine::I18nTest < ActiveSupport::TestCase | 20 class Redmine::I18nTest < ActiveSupport::TestCase |
21 include Redmine::I18n | 21 include Redmine::I18n |
22 include ActionView::Helpers::NumberHelper | 22 include ActionView::Helpers::NumberHelper |
23 | 23 |
27 | 27 |
28 def test_date_format_default | 28 def test_date_format_default |
29 set_language_if_valid 'en' | 29 set_language_if_valid 'en' |
30 today = Date.today | 30 today = Date.today |
31 Setting.date_format = '' | 31 Setting.date_format = '' |
32 assert_equal I18n.l(today, :count => today.strftime('%d')), format_date(today) | 32 assert_equal I18n.l(today), format_date(today) |
33 end | 33 end |
34 | 34 |
35 def test_date_format | 35 def test_date_format |
36 set_language_if_valid 'en' | 36 set_language_if_valid 'en' |
37 today = Date.today | 37 today = Date.today |
45 set_language_if_valid lang | 45 set_language_if_valid lang |
46 assert_nothing_raised "#{lang} failure" do | 46 assert_nothing_raised "#{lang} failure" do |
47 format_date(Date.today) | 47 format_date(Date.today) |
48 format_time(Time.now) | 48 format_time(Time.now) |
49 format_time(Time.now, false) | 49 format_time(Time.now, false) |
50 assert_not_equal 'default', ::I18n.l(Date.today, :count => Date.today.strftime('%d'), :format => :default), "date.formats.default missing in #{lang}" | 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}" | 51 assert_not_equal 'time', ::I18n.l(Time.now, :format => :time), "time.formats.time missing in #{lang}" |
52 end | 52 end |
53 assert l('date.day_names').is_a?(Array) | 53 assert l('date.day_names').is_a?(Array) |
54 assert_equal 7, l('date.day_names').size | 54 assert_equal 7, l('date.day_names').size |
55 | 55 |
61 def test_time_format_default | 61 def test_time_format_default |
62 set_language_if_valid 'en' | 62 set_language_if_valid 'en' |
63 now = Time.now | 63 now = Time.now |
64 Setting.date_format = '' | 64 Setting.date_format = '' |
65 Setting.time_format = '' | 65 Setting.time_format = '' |
66 assert_equal I18n.l(now, :count => now.strftime('%d')), format_time(now) | 66 assert_equal I18n.l(now), format_time(now) |
67 assert_equal I18n.l(now, :count => now.strftime('%d'), :format => :time), format_time(now, false) | 67 assert_equal I18n.l(now, :format => :time), format_time(now, false) |
68 end | 68 end |
69 | 69 |
70 def test_time_format | 70 def test_time_format |
71 set_language_if_valid 'en' | 71 set_language_if_valid 'en' |
72 now = Time.now | 72 now = Time.now |
107 'zh-TW' => :"zh-TW", | 107 'zh-TW' => :"zh-TW", |
108 'zh-ZZ' => nil } | 108 'zh-ZZ' => nil } |
109 | 109 |
110 to_test.each {|lang, expected| assert_equal expected, find_language(lang)} | 110 to_test.each {|lang, expected| assert_equal expected, find_language(lang)} |
111 end | 111 end |
112 | |
113 def test_fallback | |
114 ::I18n.backend.store_translations(:en, {:untranslated => "Untranslated string"}) | |
115 ::I18n.locale = 'en' | |
116 assert_equal "Untranslated string", l(:untranslated) | |
117 ::I18n.locale = 'fr' | |
118 assert_equal "Untranslated string", l(:untranslated) | |
119 | |
120 ::I18n.backend.store_translations(:fr, {:untranslated => "Pas de traduction"}) | |
121 ::I18n.locale = 'en' | |
122 assert_equal "Untranslated string", l(:untranslated) | |
123 ::I18n.locale = 'fr' | |
124 assert_equal "Pas de traduction", l(:untranslated) | |
125 end | |
112 end | 126 end |