Commit e6399ff5d7afb02fae803208b000096069cf5e70

Authored by Andrew Kane
1 parent 1ff92eda

Fixed offset_value - closes #206

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