aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-08-08 16:59:06 +0000
committerRick Olson <technoweenie@gmail.com>2006-08-08 16:59:06 +0000
commit94a1309194fa5962e33d395ede14e94b237c54f5 (patch)
tree33c1e6edbe2297e9f19206c18480db5b76bafd84 /activerecord/test
parent2ce49e7dd56515491238ccb7961987ea82055105 (diff)
downloadrails-94a1309194fa5962e33d395ede14e94b237c54f5.tar.gz
rails-94a1309194fa5962e33d395ede14e94b237c54f5.tar.bz2
rails-94a1309194fa5962e33d395ede14e94b237c54f5.zip
Cache nil results for has_one associations so multiple calls don't call the database. Closes #5757. [Michael A. Schoen]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4721 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-xactiverecord/test/associations_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb
index eecb096521..f99322d976 100755
--- a/activerecord/test/associations_test.rb
+++ b/activerecord/test/associations_test.rb
@@ -96,6 +96,11 @@ class HasOneAssociationsTest < Test::Unit::TestCase
assert_equal Account.find(1).credit_limit, companies(:first_firm).account.credit_limit
end
+ def test_has_one_cache_nils
+ assert_nil companies(:another_firm).account
+ assert_queries(0) { companies(:another_firm).account }
+ end
+
def test_proxy_assignment
company = companies(:first_firm)
assert_nothing_raised { company.account = company.account }