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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f049c1119333765ceb81d8028a413f65f24c5fd2
4
- data.tar.gz: c580f77b5f02d714e1f922139a057cc34fdf18b2
3
+ metadata.gz: 7f324072e0e5b2dc28efc2d33cf00ce77c9bc00e
4
+ data.tar.gz: 31d46fd191eefced883cf03c2b632fc6269c3e30
5
5
  SHA512:
6
- metadata.gz: 38ab4b7bb671d868810d635dcfcba8d334d7e1e6782969ed5b06c46a8156bc07498877adc61bd6a6ded85761208fe193ebc67ad0e6f43d8a915f02dc5384d9f1
7
- data.tar.gz: 2753cbefe2316d02c93c7bcd6b9e9452bd2548ff3cfd264cfb4b8d51e09e66d7c0633bc09c782b377f0ef3d61acd113fdce9a019e957d904c90b278319155c3a
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' => processed.total_pages,
35
- 'current-page' => processed.current_page,
36
- 'previous-page' => processed.prev_page,
37
- 'next-page' => processed.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
@@ -1,3 +1,3 @@
1
1
  module Apill
2
- VERSION = '3.0.4'
2
+ VERSION = '3.0.5'
3
3
  end
@@ -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
- allow(resource).to receive(:total_pages).
42
+
43
+ allow(processed_resource).to receive(:total_pages).
43
44
  and_return(10)
44
- allow(resource).to receive(:current_page).
45
+ allow(processed_resource).to receive(:current_page).
45
46
  and_return(5)
46
- allow(resource).to receive(:prev_page).
47
+ allow(processed_resource).to receive(:prev_page).
47
48
  and_return(4)
48
- allow(resource).to receive(:next_page).
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(processed_resource).to receive(:total_pages).and_return 10
18
- allow(processed_resource).to receive(:current_page).and_return 1
19
- allow(processed_resource).to receive(:prev_page).and_return nil
20
- allow(processed_resource).to receive(:next_page).and_return nil
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).
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apill
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - jfelchner