Permalink
Browse files

fix default I18n lookup for association input

closes #679
  • Loading branch information...
1 parent 87c6766 commit c5f913c37890d52adf39c38521f686a117e864be @nashby nashby committed Oct 24, 2012
Showing with 14 additions and 1 deletion.
  1. +3 −0 CHANGELOG.md
  2. +1 −1 lib/simple_form/inputs/base.rb
  3. +10 −0 test/form_builder/association_test.rb
View
@@ -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))
@@ -174,7 +174,7 @@ def translate(namespace, default='')
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
@@ -180,4 +180,14 @@ def with_association_for(object, *args)
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

0 comments on commit c5f913c

Please sign in to comment.