freelancing-god-thinking-sphinx 1.2.6 → 1.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 2
4
- :patch: 6
4
+ :patch: 7
@@ -154,7 +154,8 @@ module ThinkingSphinx
154
154
  # @return [Integer]
155
155
  #
156
156
  def total_pages
157
- @total_pages ||= (total_entries / per_page.to_f).ceil
157
+ populate
158
+ @total_pages ||= (@results[:total] / per_page.to_f).ceil
158
159
  end
159
160
  # Compatibility with older versions of will_paginate
160
161
  alias_method :page_count, :total_pages
@@ -7,7 +7,7 @@ describe ThinkingSphinx::Search do
7
7
  @client = Riddle::Client.new
8
8
 
9
9
  @config.stub!(:client => @client)
10
- @client.stub!(:query => {:matches => [], :total_found => 41})
10
+ @client.stub!(:query => {:matches => [], :total_found => 41, :total => 41})
11
11
  end
12
12
 
13
13
  it "not request results from the client if not accessing items" do
@@ -756,6 +756,14 @@ describe ThinkingSphinx::Search do
756
756
  it "should allow for custom per_page values" do
757
757
  ThinkingSphinx::Search.new(:per_page => 30).total_pages.should == 2
758
758
  end
759
+
760
+ it "should not overstep the max_matches implied limit" do
761
+ @client.stub!(:query => {
762
+ :matches => [], :total_found => 41, :total => 40
763
+ })
764
+
765
+ ThinkingSphinx::Search.new.total_pages.should == 2
766
+ end
759
767
  end
760
768
 
761
769
  describe '#next_page' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freelancing-god-thinking-sphinx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-08 00:00:00 -07:00
12
+ date: 2009-08-10 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency