aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_one_associations_test.rb
diff options
context:
space:
mode:
authorbrainopia <brainopia@evilmartians.com>2014-12-31 00:19:09 +0300
committerbrainopia <brainopia@evilmartians.com>2014-12-31 00:19:09 +0300
commit7f3b246b99afc8bc6e591c8808a38556c400ad3c (patch)
tree9e567042b7d4b504ed63046e331a0f4a340b10d1 /activerecord/test/cases/associations/has_one_associations_test.rb
parent322750e213ee929752a8bb07dbe44b839452e0a3 (diff)
downloadrails-7f3b246b99afc8bc6e591c8808a38556c400ad3c.tar.gz
rails-7f3b246b99afc8bc6e591c8808a38556c400ad3c.tar.bz2
rails-7f3b246b99afc8bc6e591c8808a38556c400ad3c.zip
Share foreign_key_present? implementation in _has_ associations
Diffstat (limited to 'activerecord/test/cases/associations/has_one_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_one_associations_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb
index a69f7a5262..ddf967b166 100644
--- a/activerecord/test/cases/associations/has_one_associations_test.rb
+++ b/activerecord/test/cases/associations/has_one_associations_test.rb
@@ -566,6 +566,12 @@ class HasOneAssociationsTest < ActiveRecord::TestCase
assert_equal author.post, post
end
+ def test_has_one_loading_for_new_record
+ post = Post.create!(author_id: 42, title: 'foo', body: 'bar')
+ author = Author.new(id: 42)
+ assert author.post
+ end
+
def test_has_one_relationship_cannot_have_a_counter_cache
assert_raise(ArgumentError) do
Class.new(ActiveRecord::Base) do