just_paginate 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/lib/just_paginate.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module JustPaginate
3
3
 
4
- VERSION = "0.0.11"
4
+ VERSION = "0.0.12"
5
5
 
6
6
  # TODO make sure negative numbers, non-integers etc are just converted to page 1.
7
7
  def self.page_value(page)
@@ -40,9 +40,13 @@ module JustPaginate
40
40
  end
41
41
 
42
42
  def self.beyond_page_range?(curr_page, per_page, total_entry_count)
43
- start_index = ((curr_page-1)*per_page)
44
- end_index = (start_index+per_page)-1
45
- start_index > total_entry_count
43
+ if curr_page < 1
44
+ true
45
+ else
46
+ start_index = ((curr_page-1)*per_page)
47
+ end_index = (start_index+per_page)-1
48
+ start_index > total_entry_count
49
+ end
46
50
  end
47
51
 
48
52
  def self.page_navigation(curr_page, total_page_count, &page_link_constructor)
@@ -26,6 +26,12 @@ class JustPaginateTest < Test::Unit::TestCase
26
26
  assert !JustPaginate.beyond_page_range?(1,20,100)
27
27
  end
28
28
 
29
+ should "state that pages below page 1 are out of bounds" do
30
+ assert JustPaginate.beyond_page_range?(-2,2,4)
31
+ assert JustPaginate.beyond_page_range?(-1,2,4)
32
+ assert JustPaginate.beyond_page_range?(0,2,4)
33
+ end
34
+
29
35
  should "calculate correct total page count" do
30
36
  assert_equal 25, JustPaginate.total_page_number(500, 20)
31
37
  assert_equal 25, JustPaginate.total_page_number(498, 20)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: just_paginate
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.11
5
+ version: 0.0.12
6
6
  platform: ruby
7
7
  authors:
8
8
  - Gitorious AS