Skip to content

Commit b3e79be

Browse files
Merge pull request #45675 from hirotaka/fix_date_select_with_locale
Fixes Date Helper with locale (cherry picked from commit 3661d0d)
1 parent 6407d39 commit b3e79be

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

actionview/lib/action_view/helpers/date_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ def set_day_if_discarded
888888
def month_names
889889
@month_names ||= begin
890890
month_names = @options[:use_month_names] || translated_month_names
891-
month_names.unshift(nil) if month_names.size < 13
891+
month_names = [nil, *month_names] if month_names.size < 13
892892
month_names
893893
end
894894
end

actionview/test/template/date_helper_i18n_test.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ def test_select_month_given_use_short_month_option_translates_abbr_monthnames
114114
end
115115
end
116116

117+
def test_select_month_with_frozen_month_names
118+
month_names = Date::MONTHNAMES.dup.drop(1).freeze
119+
120+
assert_called_with(I18n, :translate, [:'date.month_names', locale: "en"], returns: month_names) do
121+
select_month(8, locale: "en")
122+
end
123+
end
124+
125+
# date_or_time_select
126+
117127
def test_date_or_time_select_translates_prompts
118128
prompt_defaults = { year: "Year", month: "Month", day: "Day", hour: "Hour", minute: "Minute", second: "Seconds" }
119129
defaults = { [:'date.order', locale: "en", default: []] => %w(year month day) }
@@ -137,8 +147,6 @@ def test_date_or_time_select_translates_prompts
137147
assert_equal defaults.count, @prompt_called
138148
end
139149

140-
# date_or_time_select
141-
142150
def test_date_or_time_select_given_an_order_options_does_not_translate_order
143151
assert_not_called(I18n, :translate) do
144152
datetime_select("post", "updated_at", order: [:year, :month, :day], locale: "en", use_month_names: Date::MONTHNAMES)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy