class DateHelperSelectTagsI18nTests
Attributes
request[R]
Public Instance Methods
test_date_or_time_select_given_an_order_options_does_not_translate_order()
click to toggle source
date_or_time_select
# File actionview/test/template/date_helper_i18n_test.rb, line 141 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) end end
test_date_or_time_select_given_invalid_order()
click to toggle source
# File actionview/test/template/date_helper_i18n_test.rb, line 153 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_raise StandardError do datetime_select("post", "updated_at", locale: "en") end end end
test_date_or_time_select_given_no_order_options_translates_order()
click to toggle source
# File actionview/test/template/date_helper_i18n_test.rb, line 147 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") end end
test_date_or_time_select_given_symbol_keys()
click to toggle source
# File actionview/test/template/date_helper_i18n_test.rb, line 161 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") end end
test_date_or_time_select_translates_prompts()
click to toggle source
# File actionview/test/template/date_helper_i18n_test.rb, line 116 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.each do |key, prompt| defaults[[("datetime.prompts." + key.to_s).to_sym, locale: "en"]] = prompt end prompts_check = -> (prompt, x) do @prompt_called ||= 0 return_value = defaults[[prompt, x]] @prompt_called += 1 if return_value.present? return_value end I18n.stub(:translate, prompts_check) do 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
test_select_month_given_use_month_names_option_does_not_translate_monthnames()
click to toggle source
select_month
# File actionview/test/template/date_helper_i18n_test.rb, line 98 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) end end
test_select_month_given_use_short_month_option_translates_abbr_monthnames()
click to toggle source
# File actionview/test/template/date_helper_i18n_test.rb, line 110 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) end end
test_select_month_translates_monthnames()
click to toggle source
# File actionview/test/template/date_helper_i18n_test.rb, line 104 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") end end