mirror of
https://github.com/heartcombo/simple_form.git
synced 2022-11-09 12:19:26 -05:00
Handle situation when I18n date.order values are strings
Rails 4 changes the `date.order` I18n setting to return strings, which resulted in a missed lookup in POSITION, and a value like `date_i` instead of `date_1i` for the `for` attribute on `label` elements.
This commit is contained in:
parent
442a2c57b7
commit
c00533bf7c
2 changed files with 5 additions and 5 deletions
|
@ -14,7 +14,7 @@ module SimpleForm
|
|||
date_order.first
|
||||
else
|
||||
:hour
|
||||
end
|
||||
end.to_sym
|
||||
|
||||
position = ActionView::Helpers::DateTimeSelector::POSITION[position]
|
||||
"#{attribute_name}_#{position}i"
|
||||
|
|
|
@ -63,26 +63,26 @@ class DateTimeInputTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
test 'label should use i18n to get target for date input type' do
|
||||
store_translations(:en, date: { order: [:month, :day, :year] }) do
|
||||
store_translations(:en, date: { order: ['month', 'day', 'year'] }) do
|
||||
with_input_for :project, :created_at, :date
|
||||
assert_select 'label[for=project_created_at_2i]'
|
||||
end
|
||||
end
|
||||
|
||||
test 'label should use i18n to get target for datetime input type' do
|
||||
store_translations(:en, date: { order: [:month, :day, :year] }) do
|
||||
store_translations(:en, date: { order: ['month', 'day', 'year'] }) do
|
||||
with_input_for :project, :created_at, :datetime
|
||||
assert_select 'label[for=project_created_at_2i]'
|
||||
end
|
||||
end
|
||||
|
||||
test 'label should use order to get target when date input type' do
|
||||
with_input_for :project, :created_at, :date, order: [:month, :year, :day]
|
||||
with_input_for :project, :created_at, :date, order: ['month', 'year', 'day']
|
||||
assert_select 'label[for=project_created_at_2i]'
|
||||
end
|
||||
|
||||
test 'label should use order to get target when datetime input type' do
|
||||
with_input_for :project, :created_at, :datetime, order: [:month, :year, :day]
|
||||
with_input_for :project, :created_at, :datetime, order: ['month', 'year', 'day']
|
||||
assert_select 'label[for=project_created_at_2i]'
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue