just_paginate 0.0.11 → 0.0.12
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.
- data/lib/just_paginate.rb +8 -4
- data/test/test_just_paginate.rb +6 -0
- metadata +1 -1
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.
|
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
|
-
|
44
|
-
|
45
|
-
|
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)
|
data/test/test_just_paginate.rb
CHANGED
@@ -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)
|