apill 3.0.4 → 3.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/apill/resource/processors/indexing.rb +8 -2
- data/lib/apill/resource/processors/paging.rb +4 -4
- data/lib/apill/version.rb +1 -1
- data/spec/apill/resource/model_spec.rb +5 -8
- data/spec/apill/resource/processors/indexing_spec.rb +18 -0
- data/spec/apill/resource/processors/paging_spec.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f324072e0e5b2dc28efc2d33cf00ce77c9bc00e
|
4
|
+
data.tar.gz: 31d46fd191eefced883cf03c2b632fc6269c3e30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e7b1a2c44c2534765be9ba23129ae85bb125e272fff333ffd9c8b650e9c37d247c336d9584139f821979158f5d553920e10f91906de9b2b58f9af6a221692a6
|
7
|
+
data.tar.gz: db6b498df64503368495b5533b49fe8eeb6aa010ee4541bde0b996b5c7985ce5f1a8d9f528522fbf67522e57d836bf53ca2fa42298badea5011bb171b7a460ea
|
@@ -21,9 +21,15 @@ class Indexing
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def processed
|
24
|
-
return resource unless parameters.present?
|
24
|
+
return resource unless parameters.present? || force_query
|
25
25
|
|
26
|
-
resource.for_query(parameters.query)
|
26
|
+
resource.for_query(parameters.query || Parameters::Index::DEFAULT_QUERY)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def force_query
|
32
|
+
resource.class.name.include? 'Index'
|
27
33
|
end
|
28
34
|
end
|
29
35
|
end
|
@@ -31,10 +31,10 @@ class Paging
|
|
31
31
|
return {} unless parameters.present?
|
32
32
|
|
33
33
|
{
|
34
|
-
'total-pages' =>
|
35
|
-
'current-page' =>
|
36
|
-
'previous-page' =>
|
37
|
-
'next-page' =>
|
34
|
+
'total-pages' => resource.total_pages,
|
35
|
+
'current-page' => resource.current_page,
|
36
|
+
'previous-page' => resource.prev_page,
|
37
|
+
'next-page' => resource.next_page,
|
38
38
|
}
|
39
39
|
end
|
40
40
|
end
|
data/lib/apill/version.rb
CHANGED
@@ -39,19 +39,16 @@ describe Model do
|
|
39
39
|
allow(resource).to receive(:for_query).
|
40
40
|
with('my_query').
|
41
41
|
and_return(processed_resource)
|
42
|
-
|
42
|
+
|
43
|
+
allow(processed_resource).to receive(:total_pages).
|
43
44
|
and_return(10)
|
44
|
-
allow(
|
45
|
+
allow(processed_resource).to receive(:current_page).
|
45
46
|
and_return(5)
|
46
|
-
allow(
|
47
|
+
allow(processed_resource).to receive(:prev_page).
|
47
48
|
and_return(4)
|
48
|
-
allow(
|
49
|
+
allow(processed_resource).to receive(:next_page).
|
49
50
|
and_return(6)
|
50
51
|
|
51
|
-
allow(processed_resource).to receive(:page).
|
52
|
-
with(10).
|
53
|
-
and_return(resource)
|
54
|
-
|
55
52
|
expect(model.processed).to eql processed_resource
|
56
53
|
expect(model.meta).to eql(
|
57
54
|
'current-page' => 5,
|
@@ -1,6 +1,13 @@
|
|
1
1
|
require 'rspectacular'
|
2
2
|
require 'apill/resource/processors/indexing'
|
3
3
|
|
4
|
+
module Apill
|
5
|
+
class TestIndexClass
|
6
|
+
def for_query(_param)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
4
11
|
module Apill
|
5
12
|
module Resource
|
6
13
|
module Processors
|
@@ -12,6 +19,17 @@ describe Indexing do
|
|
12
19
|
|
13
20
|
expect(indexing.processed).to eql indexing_resource
|
14
21
|
end
|
22
|
+
|
23
|
+
it 'forces a query even if no parameters were passed in' do
|
24
|
+
indexing_resource = TestIndexClass.new
|
25
|
+
indexing = Indexing.new(indexing_resource)
|
26
|
+
|
27
|
+
allow(indexing_resource).to receive(:for_query).
|
28
|
+
with('*').
|
29
|
+
and_return('blah')
|
30
|
+
|
31
|
+
expect(indexing.processed).to eql 'blah'
|
32
|
+
end
|
15
33
|
end
|
16
34
|
end
|
17
35
|
end
|
@@ -14,10 +14,10 @@ describe Paging do
|
|
14
14
|
'size' => 10,
|
15
15
|
})
|
16
16
|
|
17
|
-
allow(
|
18
|
-
allow(
|
19
|
-
allow(
|
20
|
-
allow(
|
17
|
+
allow(paging_resource).to receive(:total_pages).and_return 10
|
18
|
+
allow(paging_resource).to receive(:current_page).and_return 1
|
19
|
+
allow(paging_resource).to receive(:prev_page).and_return nil
|
20
|
+
allow(paging_resource).to receive(:next_page).and_return nil
|
21
21
|
|
22
22
|
allow(paging_resource).to receive(:page).
|
23
23
|
with(1).
|