Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make it possible to query with order but no conditions

  • Loading branch information...
commit 891c6d624e8734656eb9738ecb9194c4682a0ead 1 parent a5ec139
@jamesgolick authored
View
3  lib/friendly/data_store.rb
@@ -12,7 +12,8 @@ def insert(persistable, attributes)
end
def all(persistable, query)
- filtered = dataset(persistable).where(query.conditions)
+ filtered = dataset(persistable)
+ filtered = filtered.where(query.conditions) unless query.conditions.empty?
if query.limit || query.offset
filtered = filtered.limit(query.limit, query.offset)
end
View
5 spec/integration/finder_spec.rb
@@ -65,8 +65,7 @@
describe "all with only order" do
it "queries the index" do
- lambda {
- Address.all(:order! => :created_at.desc)
- }.should_not raise_error
+ Address.create
+ Address.all(:order! => :created_at.desc, :limit! => 5)
end
end
View
13 spec/unit/data_store_spec.rb
@@ -76,6 +76,19 @@
end
end
+ describe "all without conditions" do
+ before do
+ @all = stub(:map => [])
+ @users.stubs(:order).with(:created_at).returns(@all)
+ @query = query(:order! => :created_at)
+ @return = @datastore.all(@klass, @query)
+ end
+
+ it "orders the filtered dataset and returns the results" do
+ @return.should == []
+ end
+ end
+
describe "retrieving first with conditions" do
before do
@users.first = {{:id => 1} => {:id => 1}}
Please sign in to comment.
Something went wrong with that request. Please try again.