Skip to content

Commit

Permalink
Merge pull request #10036 from wangjohn/norecord_error_message_consis…
Browse files Browse the repository at this point in the history
…tency_issues

Updated the error message for find to stay consistent across Rails
  • Loading branch information
rafaelfranca committed Apr 1, 2013
2 parents 78defbb + a605c44 commit abad4f7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
Expand Up @@ -83,7 +83,7 @@ def find(*args)
find_by_scan(*args) find_by_scan(*args)
elsif options[:inverse_of] elsif options[:inverse_of]
args = args.flatten 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) result = find_by_scan(*args)


Expand Down
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 def test_raise_record_not_found_error_when_invalid_ids_are_passed
man = Man.create! man = Man.create!
interest = Interest.create!(man: man)


invalid_id = 2394823094892348920348523452345 invalid_id = 2394823094892348920348523452345
assert_raise(ActiveRecord::RecordNotFound) { man.interests.find(invalid_id) } 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 def test_raise_record_not_found_error_when_no_ids_are_passed
man = Man.create! man = Man.create!
interest = Interest.create!(man: man)


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

0 comments on commit abad4f7

Please sign in to comment.