diff options
author | Steve Klabnik <steve@steveklabnik.com> | 2012-11-26 10:33:06 -0800 |
---|---|---|
committer | Steve Klabnik <steve@steveklabnik.com> | 2012-11-26 10:41:20 -0800 |
commit | 1a876f622865979ea6415d913adface70716e458 (patch) | |
tree | ab9fd1a6db1f85d2e941ae76ecdf39f017021159 /actionpack/test/template/date_helper_i18n_test.rb | |
parent | 51676652a3568ad09b06385564de4fdcb13af05e (diff) | |
download | rails-1a876f622865979ea6415d913adface70716e458.tar.gz rails-1a876f622865979ea6415d913adface70716e458.tar.bz2 rails-1a876f622865979ea6415d913adface70716e458.zip |
Add i18n scope to disance_of_time_in_words.
This is a backport of rails/rails#7997.
Diffstat (limited to 'actionpack/test/template/date_helper_i18n_test.rb')
-rw-r--r-- | actionpack/test/template/date_helper_i18n_test.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/actionpack/test/template/date_helper_i18n_test.rb b/actionpack/test/template/date_helper_i18n_test.rb index d45215acfd..b0b407b473 100644 --- a/actionpack/test/template/date_helper_i18n_test.rb +++ b/actionpack/test/template/date_helper_i18n_test.rb @@ -36,16 +36,25 @@ class DateHelperDistanceOfTimeInWordsI18nTests < Test::Unit::TestCase end end - def assert_distance_of_time_in_words_translates_key(passed, expected) + def test_distance_of_time_in_words_calls_i18n_with_custom_scope + { + [30.days, false] => [:'about_x_months', 1], + [60.days, false] => [:'x_months', 2], + }.each do |passed, expected| + assert_distance_of_time_in_words_translates_key(passed, expected, {:scope => :'datetime.distance_in_words_ago'}) + end + end + + def assert_distance_of_time_in_words_translates_key(passed, expected, options = {}) diff, include_seconds = *passed key, count = *expected to = @from + diff - options = {:locale => 'en', :scope => :'datetime.distance_in_words'} + options = {:locale => 'en', :scope => :'datetime.distance_in_words'}.merge(options) options[:count] = count if count I18n.expects(:t).with(key, options) - distance_of_time_in_words(@from, to, include_seconds, :locale => 'en') + distance_of_time_in_words(@from, to, include_seconds, options) end def test_distance_of_time_pluralizations |