mongoid 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -127,7 +127,9 @@ module Mongoid #:nodoc:
127
127
  params[:page] || 1,
128
128
  params[:per_page] || 20,
129
129
  0) do |pager|
130
- results = collection.find(selector, { :limit => pager.per_page, :offset => pager.offset })
130
+ results = collection.find(selector, { :sort => (params[:sort] || {}),
131
+ :limit => pager.per_page,
132
+ :offset => pager.offset })
131
133
  pager.total_entries = results.count
132
134
  pager.replace(results.collect { |doc| new(doc) })
133
135
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongoid}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Durran Jordan"]
@@ -419,7 +419,7 @@ describe Mongoid::Document do
419
419
  context "when pagination parameters are passed" do
420
420
 
421
421
  it "delegates to will paginate with the results" do
422
- @collection.expects(:find).with({ :test => "Test" }, {:limit => 20, :offset => 20}).returns(@cursor)
422
+ @collection.expects(:find).with({ :test => "Test" }, { :sort => {}, :limit => 20, :offset => 20}).returns(@cursor)
423
423
  Person.paginate(:conditions => { :test => "Test" }, :page => 2, :per_page => 20)
424
424
  end
425
425
 
@@ -428,12 +428,21 @@ describe Mongoid::Document do
428
428
  context "when pagination parameters are not passed" do
429
429
 
430
430
  it "delegates to will paginate with default values" do
431
- @collection.expects(:find).with({ :test => "Test" }, {:limit => 20, :offset => 0}).returns(@cursor)
431
+ @collection.expects(:find).with({ :test => "Test" }, { :sort => {}, :limit => 20, :offset => 0}).returns(@cursor)
432
432
  Person.paginate(:conditions => { :test => "Test" })
433
433
  end
434
434
 
435
435
  end
436
436
 
437
+ context "when sorting paramters provided" do
438
+
439
+ it "adds the sorting parameters in the collection#find" do
440
+ @collection.expects(:find).with({ :test => "Test" }, { :sort => { :test => -1}, :limit => 20, :offset => 0}).returns(@cursor)
441
+ Person.paginate(:conditions => { :test => "Test" }, :sort => { :test => -1 })
442
+ end
443
+
444
+ end
445
+
437
446
  end
438
447
 
439
448
  describe "#parent" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Durran Jordan