clean_pagination 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2f08b4adf87167a5c49bc33b0666a30f3679407
4
- data.tar.gz: db0e200a6b5d456b6eabf39460fc7ffcf924069c
3
+ metadata.gz: bc83a0b2f1b894df997f13f0599230edb5e935cf
4
+ data.tar.gz: 4dad8369da2b93279d30a0d0fc09bbfd4c582ae2
5
5
  SHA512:
6
- metadata.gz: de3234c79aa3cd720c70f37e9c5f77e2c44251f8edeab7d60279a988ed6054b6ee902af66ee340fbab269cf585420c5af4bbdaa3bede1fc1368356cdfd61dffd
7
- data.tar.gz: b216c1feca44e35433d78178851efcf1d972f8f23aa707a66f43acb6b38a9358c5b639251aae2a7c5039e80f97724565bb60af2bfe109d459c5760ca6065707d
6
+ metadata.gz: b62c0ad0ad9783f727c0d95d5f70ef7b76e3996289644930b3da08378739c9ae85ba02a3044cbac28424d484a07c461245f961fabb1eedd622e9b951d34aec14
7
+ data.tar.gz: 82321d852b9e6ea89fbafa02f85cd12415ad3e565359b6632526572125ac0498f7a78aeebabde92357de0615c86131a3b681bddfdf9912a1d1297e0038a7f400
@@ -1,3 +1,3 @@
1
1
  module CleanPagination
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -13,7 +13,7 @@ module CleanPagination
13
13
  end
14
14
  end
15
15
 
16
- if requested_from >= [requested_to, total_items].min
16
+ if requested_from > requested_to || requested_from >= total_items
17
17
  response.status = 416
18
18
  headers['Content-Range'] = "*/#{total_items}"
19
19
  return
@@ -93,6 +93,16 @@ class ApplicationControllerTest < ActionController::TestCase
93
93
  assert_equal '*/101', response.headers['Content-Range']
94
94
  end
95
95
 
96
+ test "allows one-item requests" do
97
+ @request.headers['Range-Unit'] = 'items'
98
+ @request.headers['Range'] = "0-0"
99
+
100
+ @controller.expects(:action).with(1, 0)
101
+ get :index
102
+ assert_equal 206, response.status
103
+ assert_equal '0-0/101', response.headers['Content-Range']
104
+ end
105
+
96
106
  test "handles ranges beyond collection length via truncation" do
97
107
  @request.headers['Range-Unit'] = 'items'
98
108
  @request.headers['Range'] = "50-200"