Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Query#object_ids was not passing keys argument through to criteria. M…

…ade it so Query#object_ids with no arguments returns the criteria's object_ids.
  • Loading branch information...
commit 407583c22c741c6058645f6b9e6b8139739ad35d 1 parent 711f440
@jnunemaker jnunemaker authored
Showing with 18 additions and 2 deletions.
  1. +2 −1  lib/plucky/query.rb
  2. +16 −1 test/plucky/test_query.rb
View
3  lib/plucky/query.rb
@@ -13,7 +13,8 @@ def initialize(collection, opts={})
end
def object_ids(*keys)
- criteria.object_ids = @object_ids
+ return criteria.object_ids if keys.empty?
+ criteria.object_ids = *keys
self
end
View
17 test/plucky/test_query.rb
@@ -35,7 +35,7 @@ class QueryTest < Test::Unit::TestCase
subject[:skip] = 1
subject[:skip].should == 1
end
-
+
should "set key on criteria for criteria" do
subject[:foo] = 'bar'
subject[:foo].should == 'bar'
@@ -274,6 +274,21 @@ class QueryTest < Test::Unit::TestCase
end
end
+ context "#object_ids" do
+ setup { @query = Query.new(@collection) }
+ subject { @query }
+
+ should "set criteria's object_ids" do
+ subject.criteria.expects(:object_ids=).with([:foo, :bar])
+ subject.object_ids(:foo, :bar)
+ end
+
+ should "return current object ids if keys argument is empty" do
+ subject.object_ids(:foo, :bar)
+ subject.object_ids.should == [:foo, :bar]
+ end
+ end
+
context "#merge" do
should "overwrite options" do
query1 = Query.new(@collection, :skip => 5, :limit => 5)
Please sign in to comment.
Something went wrong with that request. Please try again.