aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/belongs_to_associations_test.rb
diff options
context:
space:
mode:
authorGeorg Friedrich <georg@wobolando.com>2011-09-05 21:25:57 +1000
committerAaron Patterson <aaron.patterson@gmail.com>2011-09-05 13:49:29 -0700
commit21750122308a38cd2eaf9b46aa1789966eb8abd9 (patch)
treed0035fcbae56208fc6bb62763c34584434d588b7 /activerecord/test/cases/associations/belongs_to_associations_test.rb
parent7f7e362c14b4d462e3b796219d3b68c076b01643 (diff)
downloadrails-21750122308a38cd2eaf9b46aa1789966eb8abd9.tar.gz
rails-21750122308a38cd2eaf9b46aa1789966eb8abd9.tar.bz2
rails-21750122308a38cd2eaf9b46aa1789966eb8abd9.zip
Don't find belongs_to target when the foreign_key is NULL. Fixes #2828
Diffstat (limited to 'activerecord/test/cases/associations/belongs_to_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/belongs_to_associations_test.rb6
1 files changed, 6 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 818902beb5..866a3cca10 100644
--- a/activerecord/test/cases/associations/belongs_to_associations_test.rb
+++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb
@@ -352,6 +352,12 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
assert_equal members(:groucho), sponsor.sponsorable
end
+ def test_dont_find_target_when_foreign_key_is_null
+ tagging = taggings(:thinking_general)
+ queries = assert_sql { tagging.super_tag }
+ assert_equal 0, queries.length
+ end
+
def test_field_name_same_as_foreign_key
computer = Computer.find(1)
assert_not_nil computer.developer, ":foreign key == attribute didn't lock up" # '