aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/finder_test.rb
diff options
context:
space:
mode:
authorMichel Pigassou <mpigassou@zendesk.com>2016-07-30 15:19:30 +0200
committerMichel Pigassou <mpigassou@zendesk.com>2016-08-13 12:41:45 -0700
commitcafdbeba9043c25280fb816ec5e554ae2d020f86 (patch)
treec9904aa5466cabbf8114d012af51b80b1ba13228 /activerecord/test/cases/finder_test.rb
parent6107a40c0e4d05614493bddf33d5ae8d9ce8a8d2 (diff)
downloadrails-cafdbeba9043c25280fb816ec5e554ae2d020f86.tar.gz
rails-cafdbeba9043c25280fb816ec5e554ae2d020f86.tar.bz2
rails-cafdbeba9043c25280fb816ec5e554ae2d020f86.zip
When calling association.find RecordNotFound is now raised with the same argument as when we do it in Record.find (primary_key, id and model).
Diffstat (limited to 'activerecord/test/cases/finder_test.rb')
-rw-r--r--activerecord/test/cases/finder_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index bf0ce18bb8..390156ef37 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -1119,6 +1119,16 @@ class FinderTest < ActiveRecord::TestCase
assert_equal [0, 1, 1], posts.map(&:author_id).sort
end
+ def test_find_one_message_on_primary_key
+ e = assert_raises(ActiveRecord::RecordNotFound) do
+ Car.find(0)
+ end
+ assert_equal 0, e.id
+ assert_equal "id", e.primary_key
+ assert_equal "Car", e.model
+ assert_equal "Couldn't find Car with 'id'=0", e.message
+ end
+
def test_find_one_message_with_custom_primary_key
table_with_custom_primary_key do |model|
model.primary_key = :name