aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/method_scoping_test.rb
diff options
context:
space:
mode:
authorMark Catley <mark@nexx.co.nz>2008-06-21 23:41:30 +1200
committerJeremy Kemper <jeremy@bitsweat.net>2008-06-22 19:21:15 -0700
commit0fd3e4cd2b2b1b31304a922dc65284d5363f78b6 (patch)
tree512a7018a967141c3762c0553e25f5dc4851e70f /activerecord/test/cases/method_scoping_test.rb
parentbb6e8eea5a8190aaab67da0a7efedb3bb3d9fccb (diff)
downloadrails-0fd3e4cd2b2b1b31304a922dc65284d5363f78b6.tar.gz
rails-0fd3e4cd2b2b1b31304a922dc65284d5363f78b6.tar.bz2
rails-0fd3e4cd2b2b1b31304a922dc65284d5363f78b6.zip
Fix column collision with named_scope and :joins. [#46 state:resolved]
Diffstat (limited to 'activerecord/test/cases/method_scoping_test.rb')
-rw-r--r--activerecord/test/cases/method_scoping_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/method_scoping_test.rb b/activerecord/test/cases/method_scoping_test.rb
index 1a9a875730..d6b3e341df 100644
--- a/activerecord/test/cases/method_scoping_test.rb
+++ b/activerecord/test/cases/method_scoping_test.rb
@@ -87,6 +87,16 @@ class MethodScopingTest < ActiveRecord::TestCase
assert_equal 1, scoped_developers.size
end
+ def test_scoped_find_joins
+ scoped_developers = Developer.with_scope(:find => { :joins => 'JOIN developers_projects ON id = developer_id' } ) do
+ Developer.find(:all, :conditions => 'developers_projects.project_id = 2')
+ end
+ assert scoped_developers.include?(developers(:david))
+ assert !scoped_developers.include?(developers(:jamis))
+ assert_equal 1, scoped_developers.size
+ assert_equal developers(:david).attributes, scoped_developers.first.attributes
+ end
+
def test_scoped_count_include
# with the include, will retrieve only developers for the given project
Developer.with_scope(:find => { :include => :projects }) do