Merge pull request #1136 from mvdamme/full_messages_for_bug

Fix full_messages_for bug for associations
This commit is contained in:
Carlos Antonio da Silva 2014-10-12 19:29:46 -03:00
commit 7dff44357e
2 changed files with 9 additions and 1 deletions

View File

@ -52,7 +52,7 @@ module SimpleForm
end
def full_errors_on_association
reflection ? object.full_messages_for(reflection.name) : []
reflection ? object.errors.full_messages_for(reflection.name) : []
end
def has_custom_error?

View File

@ -133,6 +133,14 @@ class ErrorTest < ActionView::TestCase
end
end
test 'full error finds errors on association with reflection' do
swap_wrapper :default, self.custom_wrapper_with_full_error do
with_form_for @user, :company_id, as: :select,
reflection: Association.new(Company, :company, {})
assert_select 'span.error', 'Company must be valid'
end
end
test 'full error can be disabled' do
swap_wrapper :default, self.custom_wrapper_with_full_error do
with_form_for @user, :company_id, as: :select, full_error: false