fix default I18n lookup for association input

closes #679
This commit is contained in:
Vasiliy Ermolovich 2012-10-24 20:51:13 +03:00
parent 87c6766396
commit c5f913c378
3 changed files with 14 additions and 1 deletions

View File

@ -6,6 +6,9 @@
Closes [#576](https://github.com/plataformatec/simple_form/issues/576).
### bug fix
* Fix default I18n lookup for association input.
([@nashby](https://github.com/nashby))
Closes [#679](https://github.com/plataformatec/simple_form/issues/679).
* Fix escaping issue in `label_input` component
([@allomov](https://github.com/allomov))

View File

@ -174,7 +174,7 @@ module SimpleForm
lookups << :"#{joined_model_names}.#{reflection_or_attribute_name}"
end
lookups << :"defaults.#{lookup_action}.#{reflection_or_attribute_name}"
lookups << :"defaults.#{attribute_name}"
lookups << :"defaults.#{reflection_or_attribute_name}"
lookups << default
I18n.t(lookups.shift, :scope => :"simple_form.#{namespace}", :default => lookups).presence

View File

@ -180,4 +180,14 @@ class AssociationTest < ActionView::TestCase
assert_equal({ :as => :check_boxes, :collection_wrapper_tag => :ul, :item_wrapper_tag => :li},
options)
end
test 'builder association uses i18n under defaults namespace to lookup translation' do
store_translations(:en, :simple_form => {
:labels => {:defaults => {:company => 'Plataformatec' } }
}) do
with_association_for @user, :company, :required => false
assert_select 'form label', 'Plataformatec'
end
end
end