aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorFrederick Cheung <frederick.cheung@gmail.com>2008-12-17 23:39:09 +0000
committerPratik Naik <pratiknaik@gmail.com>2008-12-18 19:19:35 +0000
commit707d0dd3e1e8df7771073670e4257d933d2818f9 (patch)
tree97ac33fde3f7e4004d607911ad1b9a5437ddf037 /activerecord/test/cases
parent428e77bf0fcee4369cb8d94011141f791b8e2ba9 (diff)
downloadrails-707d0dd3e1e8df7771073670e4257d933d2818f9.tar.gz
rails-707d0dd3e1e8df7771073670e4257d933d2818f9.tar.bz2
rails-707d0dd3e1e8df7771073670e4257d933d2818f9.zip
Fix preloading of belongs_to with null foreign key generating useless query [#1027 state:resolved]
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/associations/eager_test.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb
index 3c8408d14b..2fd51ef03a 100644
--- a/activerecord/test/cases/associations/eager_test.rb
+++ b/activerecord/test/cases/associations/eager_test.rb
@@ -145,7 +145,7 @@ class EagerAssociationTest < ActiveRecord::TestCase
def test_finding_with_includes_on_null_belongs_to_association_with_same_include_includes_only_once
post = posts(:welcome)
post.update_attributes!(:author => nil)
- post = assert_queries(2) { Post.find(post.id, :include => {:author_with_address => :author_address}) } # find the post, then find the author which is null so no query for the address
+ post = assert_queries(1) { Post.find(post.id, :include => {:author_with_address => :author_address}) } # find the post, then find the author which is null so no query for the author or address
assert_no_queries do
assert_equal nil, post.author_with_address
end
@@ -705,4 +705,5 @@ class EagerAssociationTest < ActiveRecord::TestCase
def test_order_on_join_table_with_include_and_limit
assert_equal 5, Developer.find(:all, :include => 'projects', :order => 'developers_projects.joined_on DESC', :limit => 5).size
end
+
end