just_paginate 0.0.12 → 0.0.13
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 +2 -7
- data/test/test_just_paginate.rb +5 -5
- 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.13"
|
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)
|
@@ -39,7 +39,7 @@ module JustPaginate
|
|
39
39
|
Range.new(start_index, end_index)
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.
|
42
|
+
def self.page_out_of_bounds?(curr_page, per_page, total_entry_count)
|
43
43
|
if curr_page < 1
|
44
44
|
true
|
45
45
|
else
|
@@ -105,9 +105,4 @@ module JustPaginate
|
|
105
105
|
return labels
|
106
106
|
end
|
107
107
|
|
108
|
-
module Rails
|
109
|
-
def warn_on_oob(requested_page, per_page, total_element_count)
|
110
|
-
flash[:error] = "Page #{@page} out of bounds." if JustPaginate.beyond_page_range?(requested_page, per_page, total_element_count)
|
111
|
-
end
|
112
|
-
end
|
113
108
|
end
|
data/test/test_just_paginate.rb
CHANGED
@@ -22,14 +22,14 @@ class JustPaginateTest < Test::Unit::TestCase
|
|
22
22
|
end
|
23
23
|
|
24
24
|
should "provide predicate to check if pagination would exceed total pagecount" do
|
25
|
-
assert JustPaginate.
|
26
|
-
assert !JustPaginate.
|
25
|
+
assert JustPaginate.page_out_of_bounds?(7,2,4)
|
26
|
+
assert !JustPaginate.page_out_of_bounds?(1,20,100)
|
27
27
|
end
|
28
28
|
|
29
29
|
should "state that pages below page 1 are out of bounds" do
|
30
|
-
assert JustPaginate.
|
31
|
-
assert JustPaginate.
|
32
|
-
assert JustPaginate.
|
30
|
+
assert JustPaginate.page_out_of_bounds?(-2,2,4)
|
31
|
+
assert JustPaginate.page_out_of_bounds?(-1,2,4)
|
32
|
+
assert JustPaginate.page_out_of_bounds?(0,2,4)
|
33
33
|
end
|
34
34
|
|
35
35
|
should "calculate correct total page count" do
|