Commit e6399ff5d7afb02fae803208b000096069cf5e70

Authored by Andrew Kane
1 parent 1ff92eda

Fixed offset_value - closes #206

CHANGELOG.md
... ... @@ -2,6 +2,7 @@
2 2  
3 3 - Do not throw errors when index becomes out of sync with database
4 4 - Added custom exception types
  5 +- Fixed `offset` and `offset_value`
5 6  
6 7 ## 0.7.4
7 8  
... ...
lib/searchkick/results.rb
... ... @@ -96,7 +96,7 @@ module Searchkick
96 96 alias_method :num_pages, :total_pages
97 97  
98 98 def offset_value
99   - current_page * per_page
  99 + (current_page - 1) * per_page
100 100 end
101 101 alias_method :offset, :offset_value
102 102  
... ...
test/sql_test.rb
... ... @@ -30,8 +30,8 @@ class TestSql < Minitest::Unit::TestCase
30 30 assert_equal 5, products.total_count
31 31 assert_equal 5, products.total_entries
32 32 assert_equal 2, products.limit_value
33   - assert_equal 4, products.offset_value
34   - assert_equal 4, products.offset
  33 + assert_equal 2, products.offset_value
  34 + assert_equal 2, products.offset
35 35 assert !products.first_page?
36 36 assert !products.last_page?
37 37 assert !products.empty?
... ...