Make custom error work with full_error component

This commit is contained in:
Rafael Mendonça França 2014-04-03 17:38:25 -03:00
parent 402623c200
commit 70c334123e
2 changed files with 10 additions and 1 deletions

View File

@ -40,7 +40,7 @@ module SimpleForm
end
def full_errors_on_attribute
object.errors.full_messages_for(attribute_name)
has_error_in_options? ? [options[:error]] : object.errors.full_messages_for(attribute_name)
end
def errors_on_association

View File

@ -145,4 +145,13 @@ class ErrorTest < ActionView::TestCase
assert_select 'span.error', "#{error_text}"
end
test 'input with custom error works when using full_error component' do
swap_wrapper :default, self.custom_wrapper_with_full_error do
error_text = "Super User Name! can't be blank"
with_custom_error_for(@user, :name, error: error_text)
assert_select 'span.error', "#{error_text}"
end
end
end