1
0
Fork 0
mirror of https://github.com/heartcombo/simple_form.git synced 2022-11-09 12:19:26 -05:00

Tidy up previous commit

This commit is contained in:
Carlos Antonio da Silva 2010-08-14 00:19:59 -03:00
parent 03450f0007
commit 5702125175
2 changed files with 3 additions and 8 deletions

View file

@ -24,7 +24,7 @@ module SimpleForm
protected
def has_errors?
object && errors.present?
object && object.respond_to?(:errors) && errors.present?
end
def errors
@ -32,11 +32,7 @@ module SimpleForm
end
def errors_on_attribute
if object.respond_to?(:errors)
object.errors[attribute_name]
else
[]
end
object.errors[attribute_name]
end
def errors_on_association

View file

@ -24,12 +24,11 @@ class ErrorTest < ActionView::TestCase
end
test "error should not generate messages when object doesn't respond to errors method" do
@user.instance_eval {undef errors}
@user.instance_eval { undef errors }
with_error_for @user, :name, :string
assert_no_select 'span.error'
end
test 'error should generate messages for attribute with single error' do
with_error_for @user, :name, :string
assert_select 'span.error', "can't be blank"