Permalink
Browse files

has_many associations should accept arguments to scoped, as they did …

…in 2.3
  • Loading branch information...
1 parent 87bbf48 commit a9d656852929ba80f04f09970564ef0a46fa46ee @willbryant committed Oct 11, 2011
@@ -35,8 +35,8 @@ def select(select = nil)
end
end
- def scoped
- with_scope(construct_scope) { @reflection.klass.scoped }
+ def scoped(*args)
+ with_scope(construct_scope) { @reflection.klass.scoped(*args) }
end
def find(*args)
@@ -252,6 +252,19 @@ def test_counting_using_finder_sql
end
end
+ def test_scoped_without_arguments
+ clients = Firm.first.clients.all
+ assert !clients.empty?
+ assert_equal clients, Firm.first.clients.scoped.all
+ end
+
+ def test_scoped_with_arguments
+ clients = Firm.first.clients.all
+ assert !clients.empty?
+ assert_equal clients, Firm.first.clients.scoped(:conditions => "id IS NOT NULL").all
+ assert Firm.first.clients.scoped(:conditions => "id IS NULL").all.empty?
+ end
+
def test_belongs_to_sanity
c = Client.new
assert_nil c.firm

0 comments on commit a9d6568

Please sign in to comment.