aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template/date_helper_i18n_test.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-08-06 19:36:34 +0200
committerXavier Noria <fxn@hashref.com>2016-08-06 19:36:34 +0200
commit63fff600accb41b56a3e6ac403d9b1732de3086d (patch)
treeeabc84f16214eade7d44386de14a23415a9c3e3d /actionview/test/template/date_helper_i18n_test.rb
parent5b6eb1d58b48fada298215b2cccda89f993890c3 (diff)
downloadrails-63fff600accb41b56a3e6ac403d9b1732de3086d.tar.gz
rails-63fff600accb41b56a3e6ac403d9b1732de3086d.tar.bz2
rails-63fff600accb41b56a3e6ac403d9b1732de3086d.zip
modernizes hash syntax in actionview
Diffstat (limited to 'actionview/test/template/date_helper_i18n_test.rb')
-rw-r--r--actionview/test/template/date_helper_i18n_test.rb70
1 files changed, 35 insertions, 35 deletions
diff --git a/actionview/test/template/date_helper_i18n_test.rb b/actionview/test/template/date_helper_i18n_test.rb
index 9d094bf773..a6559bd54f 100644
--- a/actionview/test/template/date_helper_i18n_test.rb
+++ b/actionview/test/template/date_helper_i18n_test.rb
@@ -12,24 +12,24 @@ class DateHelperDistanceOfTimeInWordsI18nTests < ActiveSupport::TestCase
def test_distance_of_time_in_words_calls_i18n
{ # with include_seconds
- [2.seconds, { :include_seconds => true }] => [:'less_than_x_seconds', 5],
- [9.seconds, { :include_seconds => true }] => [:'less_than_x_seconds', 10],
- [19.seconds, { :include_seconds => true }] => [:'less_than_x_seconds', 20],
- [30.seconds, { :include_seconds => true }] => [:'half_a_minute', nil],
- [59.seconds, { :include_seconds => true }] => [:'less_than_x_minutes', 1],
- [60.seconds, { :include_seconds => true }] => [:'x_minutes', 1],
+ [2.seconds, { include_seconds: true }] => [:'less_than_x_seconds', 5],
+ [9.seconds, { include_seconds: true }] => [:'less_than_x_seconds', 10],
+ [19.seconds, { include_seconds: true }] => [:'less_than_x_seconds', 20],
+ [30.seconds, { include_seconds: true }] => [:'half_a_minute', nil],
+ [59.seconds, { include_seconds: true }] => [:'less_than_x_minutes', 1],
+ [60.seconds, { include_seconds: true }] => [:'x_minutes', 1],
# without include_seconds
- [29.seconds, { :include_seconds => false }] => [:'less_than_x_minutes', 1],
- [60.seconds, { :include_seconds => false }] => [:'x_minutes', 1],
- [44.minutes, { :include_seconds => false }] => [:'x_minutes', 44],
- [61.minutes, { :include_seconds => false }] => [:'about_x_hours', 1],
- [24.hours, { :include_seconds => false }] => [:'x_days', 1],
- [30.days, { :include_seconds => false }] => [:'about_x_months', 1],
- [60.days, { :include_seconds => false }] => [:'x_months', 2],
- [1.year, { :include_seconds => false }] => [:'about_x_years', 1],
- [3.years + 6.months, { :include_seconds => false }] => [:'over_x_years', 3],
- [3.years + 10.months, { :include_seconds => false }] => [:'almost_x_years', 4]
+ [29.seconds, { include_seconds: false }] => [:'less_than_x_minutes', 1],
+ [60.seconds, { include_seconds: false }] => [:'x_minutes', 1],
+ [44.minutes, { include_seconds: false }] => [:'x_minutes', 44],
+ [61.minutes, { include_seconds: false }] => [:'about_x_hours', 1],
+ [24.hours, { include_seconds: false }] => [:'x_days', 1],
+ [30.days, { include_seconds: false }] => [:'about_x_months', 1],
+ [60.days, { include_seconds: false }] => [:'x_months', 2],
+ [1.year, { include_seconds: false }] => [:'about_x_years', 1],
+ [3.years + 6.months, { include_seconds: false }] => [:'over_x_years', 3],
+ [3.years + 10.months, { include_seconds: false }] => [:'almost_x_years', 4]
}.each do |passed, expected|
assert_distance_of_time_in_words_translates_key passed, expected
@@ -46,8 +46,8 @@ class DateHelperDistanceOfTimeInWordsI18nTests < ActiveSupport::TestCase
end
def test_time_ago_in_words_passes_locale
- assert_called_with(I18n, :t, [:less_than_x_minutes, :scope => :'datetime.distance_in_words', :count => 1, :locale => "ru"]) do
- time_ago_in_words(15.seconds.ago, :locale => "ru")
+ assert_called_with(I18n, :t, [:less_than_x_minutes, scope: :'datetime.distance_in_words', count: 1, locale: "ru"]) do
+ time_ago_in_words(15.seconds.ago, locale: "ru")
end
end
@@ -69,7 +69,7 @@ class DateHelperDistanceOfTimeInWordsI18nTests < ActiveSupport::TestCase
}.each do |args, expected|
key, count = *args
- assert_equal expected, I18n.t(key, :count => count, :scope => "datetime.distance_in_words")
+ assert_equal expected, I18n.t(key, count: count, scope: "datetime.distance_in_words")
end
end
@@ -95,28 +95,28 @@ class DateHelperSelectTagsI18nTests < ActiveSupport::TestCase
def test_select_month_given_use_month_names_option_does_not_translate_monthnames
assert_not_called(I18n, :translate) do
- select_month(8, :locale => "en", :use_month_names => Date::MONTHNAMES)
+ select_month(8, locale: "en", use_month_names: Date::MONTHNAMES)
end
end
def test_select_month_translates_monthnames
- assert_called_with(I18n, :translate, [:'date.month_names', :locale => "en"], returns: Date::MONTHNAMES) do
- select_month(8, :locale => "en")
+ assert_called_with(I18n, :translate, [:'date.month_names', locale: "en"], returns: Date::MONTHNAMES) do
+ select_month(8, locale: "en")
end
end
def test_select_month_given_use_short_month_option_translates_abbr_monthnames
- assert_called_with(I18n, :translate, [:'date.abbr_month_names', :locale => "en"], returns: Date::ABBR_MONTHNAMES) do
- select_month(8, :locale => "en", :use_short_month => true)
+ assert_called_with(I18n, :translate, [:'date.abbr_month_names', locale: "en"], returns: Date::ABBR_MONTHNAMES) do
+ select_month(8, locale: "en", use_short_month: true)
end
end
def test_date_or_time_select_translates_prompts
- prompt_defaults = {:year => "Year", :month => "Month", :day => "Day", :hour => "Hour", :minute => "Minute", :second => "Seconds"}
- defaults = {[:'date.order', :locale => "en", :default => []] => %w(year month day)}
+ prompt_defaults = {year: "Year", month: "Month", day: "Day", hour: "Hour", minute: "Minute", second: "Seconds"}
+ defaults = {[:'date.order', locale: "en", default: []] => %w(year month day)}
prompt_defaults.each do |key, prompt|
- defaults[[("datetime.prompts." + key.to_s).to_sym, :locale => "en"]] = prompt
+ defaults[[("datetime.prompts." + key.to_s).to_sym, locale: "en"]] = prompt
end
prompts_check = -> (prompt, x) do
@@ -129,7 +129,7 @@ class DateHelperSelectTagsI18nTests < ActiveSupport::TestCase
end
I18n.stub(:translate, prompts_check) do
- datetime_select("post", "updated_at", :locale => "en", :include_seconds => true, :prompt => true, :use_month_names => Date::MONTHNAMES)
+ datetime_select("post", "updated_at", locale: "en", include_seconds: true, prompt: true, use_month_names: Date::MONTHNAMES)
end
assert_equal defaults.count, @prompt_called
end
@@ -138,27 +138,27 @@ class DateHelperSelectTagsI18nTests < ActiveSupport::TestCase
def test_date_or_time_select_given_an_order_options_does_not_translate_order
assert_not_called(I18n, :translate) do
- datetime_select("post", "updated_at", :order => [:year, :month, :day], :locale => "en", :use_month_names => Date::MONTHNAMES)
+ datetime_select("post", "updated_at", order: [:year, :month, :day], locale: "en", use_month_names: Date::MONTHNAMES)
end
end
def test_date_or_time_select_given_no_order_options_translates_order
- assert_called_with(I18n, :translate, [ [:'date.order', :locale => "en", :default => []], [:"date.month_names", {:locale=>"en"}] ], returns: %w(year month day)) do
- datetime_select("post", "updated_at", :locale => "en")
+ assert_called_with(I18n, :translate, [ [:'date.order', locale: "en", default: []], [:"date.month_names", {locale: "en"}] ], returns: %w(year month day)) do
+ datetime_select("post", "updated_at", locale: "en")
end
end
def test_date_or_time_select_given_invalid_order
- assert_called_with(I18n, :translate, [:'date.order', :locale => "en", :default => []], returns: %w(invalid month day)) do
+ assert_called_with(I18n, :translate, [:'date.order', locale: "en", default: []], returns: %w(invalid month day)) do
assert_raise StandardError do
- datetime_select("post", "updated_at", :locale => "en")
+ datetime_select("post", "updated_at", locale: "en")
end
end
end
def test_date_or_time_select_given_symbol_keys
- assert_called_with(I18n, :translate, [ [:'date.order', :locale => "en", :default => []], [:"date.month_names", {:locale=>"en"}] ], returns: [:year, :month, :day]) do
- datetime_select("post", "updated_at", :locale => "en")
+ assert_called_with(I18n, :translate, [ [:'date.order', locale: "en", default: []], [:"date.month_names", {locale: "en"}] ], returns: [:year, :month, :day]) do
+ datetime_select("post", "updated_at", locale: "en")
end
end
end