mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #8978 from chrismcg/remove_i18n_symbol_dependency
Remove i18n symbol dependency
This commit is contained in:
commit
b718998f3e
3 changed files with 12 additions and 6 deletions
|
@ -880,6 +880,7 @@ module ActionView
|
|||
|
||||
def translated_date_order
|
||||
date_order = I18n.translate(:'date.order', :locale => @options[:locale], :default => [])
|
||||
date_order = date_order.map { |element| element.to_sym }
|
||||
|
||||
forbidden_elements = date_order - [:year, :month, :day]
|
||||
if forbidden_elements.any?
|
||||
|
|
|
@ -117,7 +117,7 @@ class DateHelperSelectTagsI18nTests < ActiveSupport::TestCase
|
|||
I18n.expects(:translate).with(('datetime.prompts.' + key.to_s).to_sym, :locale => 'en').returns prompt
|
||||
end
|
||||
|
||||
I18n.expects(:translate).with(:'date.order', :locale => 'en', :default => []).returns [:year, :month, :day]
|
||||
I18n.expects(:translate).with(:'date.order', :locale => 'en', :default => []).returns %w(year month day)
|
||||
datetime_select('post', 'updated_at', :locale => 'en', :include_seconds => true, :prompt => true)
|
||||
end
|
||||
|
||||
|
@ -129,15 +129,20 @@ class DateHelperSelectTagsI18nTests < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_date_or_time_select_given_no_order_options_translates_order
|
||||
I18n.expects(:translate).with(:'date.order', :locale => 'en', :default => []).returns [:year, :month, :day]
|
||||
I18n.expects(:translate).with(:'date.order', :locale => 'en', :default => []).returns %w(year month day)
|
||||
datetime_select('post', 'updated_at', :locale => 'en')
|
||||
end
|
||||
|
||||
def test_date_or_time_select_given_invalid_order
|
||||
I18n.expects(:translate).with(:'date.order', :locale => 'en', :default => []).returns [:invalid, :month, :day]
|
||||
I18n.expects(:translate).with(:'date.order', :locale => 'en', :default => []).returns %w(invalid month day)
|
||||
|
||||
assert_raise StandardError do
|
||||
datetime_select('post', 'updated_at', :locale => 'en')
|
||||
end
|
||||
end
|
||||
|
||||
def test_date_or_time_select_given_symbol_keys
|
||||
I18n.expects(:translate).with(:'date.order', :locale => 'en', :default => []).returns [:year, :month, :day]
|
||||
datetime_select('post', 'updated_at', :locale => 'en')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,9 +16,9 @@ en:
|
|||
abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]
|
||||
# Used in date_select and datetime_select.
|
||||
order:
|
||||
- :year
|
||||
- :month
|
||||
- :day
|
||||
- year
|
||||
- month
|
||||
- day
|
||||
|
||||
time:
|
||||
formats:
|
||||
|
|
Loading…
Reference in a new issue