diff options
author | Yves Senn <yves.senn@gmail.com> | 2015-01-12 19:39:26 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2015-01-12 19:39:26 +0100 |
commit | 0fee2d4085eb70fe7c15d5ddc2a378b93b815ab9 (patch) | |
tree | e97118afe100725f121741495f1ce3e7b14a6a80 | |
parent | da175a2b46c4db59cd8c4bd0b9c6c613651e3db0 (diff) | |
parent | f76d1aa54d25670f6b6d635ad0350cea8b88c706 (diff) | |
download | rails-0fee2d4085eb70fe7c15d5ddc2a378b93b815ab9.tar.gz rails-0fee2d4085eb70fe7c15d5ddc2a378b93b815ab9.tar.bz2 rails-0fee2d4085eb70fe7c15d5ddc2a378b93b815ab9.zip |
Merge pull request #18462 from dmasur/patch-1
Removing :en in favor of default locale for duration#inspect
-rw-r--r-- | activesupport/lib/active_support/duration.rb | 2 | ||||
-rw-r--r-- | activesupport/test/core_ext/duration_test.rb | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb index 2818b8d68b..5a64fc52cc 100644 --- a/activesupport/lib/active_support/duration.rb +++ b/activesupport/lib/active_support/duration.rb @@ -91,7 +91,7 @@ module ActiveSupport reduce(::Hash.new(0)) { |h,(l,r)| h[l] += r; h }. sort_by {|unit, _ | [:years, :months, :days, :minutes, :seconds].index(unit)}. map {|unit, val| "#{val} #{val == 1 ? unit.to_s.chop : unit.to_s}"}. - to_sentence(:locale => :en) + to_sentence(locale: ::I18n.default_locale) end def as_json(options = nil) #:nodoc: 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 |