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:
parent
03450f0007
commit
5702125175
2 changed files with 3 additions and 8 deletions
|
@ -24,7 +24,7 @@ module SimpleForm
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def has_errors?
|
def has_errors?
|
||||||
object && errors.present?
|
object && object.respond_to?(:errors) && errors.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def errors
|
def errors
|
||||||
|
@ -32,11 +32,7 @@ module SimpleForm
|
||||||
end
|
end
|
||||||
|
|
||||||
def errors_on_attribute
|
def errors_on_attribute
|
||||||
if object.respond_to?(:errors)
|
object.errors[attribute_name]
|
||||||
object.errors[attribute_name]
|
|
||||||
else
|
|
||||||
[]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def errors_on_association
|
def errors_on_association
|
||||||
|
|
|
@ -24,12 +24,11 @@ class ErrorTest < ActionView::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
test "error should not generate messages when object doesn't respond to errors method" do
|
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
|
with_error_for @user, :name, :string
|
||||||
assert_no_select 'span.error'
|
assert_no_select 'span.error'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
test 'error should generate messages for attribute with single error' do
|
test 'error should generate messages for attribute with single error' do
|
||||||
with_error_for @user, :name, :string
|
with_error_for @user, :name, :string
|
||||||
assert_select 'span.error', "can't be blank"
|
assert_select 'span.error', "can't be blank"
|
||||||
|
|
Loading…
Reference in a new issue