aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-06-16 13:36:28 -0600
committerSean Griffin <sean@seantheprogrammer.com>2015-06-16 13:36:28 -0600
commitaf01f45f068ea382257090ec8a3aa2579e56dbdc (patch)
tree3e6c4e892f9c406fb7fa8763ef389f4708b15643 /activerecord/test
parente60c18931c81a88f4eb89059e955d6ff07c5e26c (diff)
parentba7377e8176315e7ac6ba1c24b2479925dc37cde (diff)
downloadrails-af01f45f068ea382257090ec8a3aa2579e56dbdc.tar.gz
rails-af01f45f068ea382257090ec8a3aa2579e56dbdc.tar.bz2
rails-af01f45f068ea382257090ec8a3aa2579e56dbdc.zip
Merge pull request #20578 from dcrec1/regression
raise ActiveModel::MissingAttributeError when trying to access a relationship without the foreign key attribute
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/belongs_to_associations_test.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb
index ba90c61d65..039cc46b0b 100644
--- a/activerecord/test/cases/associations/belongs_to_associations_test.rb
+++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb
@@ -31,6 +31,10 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
assert_equal companies(:first_firm).name, firm.name
end
+ def test_missing_attribute_error_is_raised_when_no_foreign_key_attribute
+ assert_raises(ActiveModel::MissingAttributeError) { Client.select(:id).first.firm }
+ end
+
def test_belongs_to_does_not_use_order_by
ActiveRecord::SQLCounter.clear_log
Client.find(3).firm