aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/duration_test.rb
diff options
context:
space:
mode:
authorDominik Masur <dominik.masur@gmail.com>2015-01-12 19:34:32 +0100
committerDominik Masur <dominik.masur@gmail.com>2015-01-12 19:34:32 +0100
commitf76d1aa54d25670f6b6d635ad0350cea8b88c706 (patch)
tree0ac43168ff44ff80f5e4665529647f3069901339 /activesupport/test/core_ext/duration_test.rb
parent970fe27b02fa7df9e01276861adebc131083958c (diff)
downloadrails-f76d1aa54d25670f6b6d635ad0350cea8b88c706.tar.gz
rails-f76d1aa54d25670f6b6d635ad0350cea8b88c706.tar.bz2
rails-f76d1aa54d25670f6b6d635ad0350cea8b88c706.zip
Removing :en in favor of I18n.default_locale in duration#inspect
Hi there, i have an app without english as available locale. So i got an error when we try to inspect something like 1.day. This is done automatically when we use the dalli cache. I would like to change the :en to ::I18n.default_locale to be sure that this is always constant and is an available locale. Tests are all green with this change. Calculating ------------------------------------- :locale => :en 2.024k i/100ms :locale => ::I18n.default_locale 2.236k i/100ms ------------------------------------------------- :locale => :en 25.758k (±26.3%) i/s - 117.392k :locale => ::I18n.default_locale 26.311k (±18.1%) i/s - 127.452k
Diffstat (limited to 'activesupport/test/core_ext/duration_test.rb')
-rw-r--r--activesupport/test/core_ext/duration_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb
index 2b893c7cd0..c283b546e6 100644
--- a/activesupport/test/core_ext/duration_test.rb
+++ b/activesupport/test/core_ext/duration_test.rb
@@ -70,6 +70,15 @@ class DurationTest < ActiveSupport::TestCase
assert_equal '14 days', 1.fortnight.inspect
end
+ def test_inspect_locale
+ current_locale = I18n.default_locale
+ I18n.default_locale = :de
+ I18n.backend.store_translations(:de, { support: { array: { last_word_connector: ' und ' } } })
+ assert_equal '10 years, 1 month und 1 day', (10.years + 1.month + 1.day).inspect
+ ensure
+ I18n.default_locale = current_locale
+ end
+
def test_minus_with_duration_does_not_break_subtraction_of_date_from_date
assert_nothing_raised { Date.today - Date.today }
end