Skip to content

Commit

Permalink
Updated the error message for +find+ on an inverse_of association
Browse files Browse the repository at this point in the history
so that it is consistent with the error thrown for +find+ without an
inverse_of association.
  • Loading branch information
wangjohn committed Apr 1, 2013
1 parent 78defbb commit a605c44
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def find(*args)
find_by_scan(*args)
elsif options[:inverse_of]
args = args.flatten
raise RecordNotFound, "Must specify an id to find" if args.blank?
raise RecordNotFound, "Couldn't find #{scope.klass.name} without an ID" if args.blank?

result = find_by_scan(*args)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ def test_parent_instance_should_find_child_instance_using_child_instance_id_when

def test_raise_record_not_found_error_when_invalid_ids_are_passed
man = Man.create!
interest = Interest.create!(man: man)

invalid_id = 2394823094892348920348523452345
assert_raise(ActiveRecord::RecordNotFound) { man.interests.find(invalid_id) }
Expand All @@ -316,7 +315,6 @@ def test_raise_record_not_found_error_when_invalid_ids_are_passed

def test_raise_record_not_found_error_when_no_ids_are_passed
man = Man.create!
interest = Interest.create!(man: man)

assert_raise(ActiveRecord::RecordNotFound) { man.interests.find() }
end
Expand Down

0 comments on commit a605c44

Please sign in to comment.