cache_crispies 0.2.1 → 0.3.0

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
  SHA256:
3
- metadata.gz: 857d0744e791b1a0fcb11a97eb9b0cc453770d9e5c6bbebb84bdc7837bf69abf
4
- data.tar.gz: 27b2b36f326fe88bcb4a5c9c3462933dfae0c0e47f75a00a011a8066afebbd65
3
+ metadata.gz: 76ca43cc7ba1c1a1b9dbee3f37d3744044ee9ce41b2bfd70033b479b465275c3
4
+ data.tar.gz: 159e4e9ff0c3081e223bfd8343fb6aaa07515f7fd380a55b154894b7dceaed91
5
5
  SHA512:
6
- metadata.gz: 7861a2cd9a3eafa762234d32bbdc1499f5c89c7da04c7d8dfa9d5184ca25bb7b966412cb7ef8239f8f2f55c51f844b9417d03bccb8dc0d7a918e0026c59149c6
7
- data.tar.gz: 5246144362972f7b3678fe7a8f94ae351a6cc12d3ab4df9dd15f727f798f3394a8d338d23da2669589b2ea0877e134fc49e063153f5ee36b808b52649eb503bb
6
+ metadata.gz: 1c7788c4754ab205a64321654bdaac9801c29e1c96dde70c9cf61d73029d017aea9f9c18134b733a2b03fb60f65c49248f9ced643169784a8aa440005b96fe91
7
+ data.tar.gz: 44cca6ae138e923009f9e7ea347e44336975fc68059839f1d48e97256a9259bf5af0a8bfa3fc9c6380e2ab4eaf1f59b63a58f9d15cf814869d229f37fd5ce6b0
@@ -21,6 +21,9 @@ module CacheCrispies
21
21
  # data under
22
22
  # @option options [Boolean] :collection whether to render the data as a
23
23
  # collection/array or a single object
24
+ # @option options [Integer, Symbol] :status the HTTP response status code
25
+ # or Rails-supported symbol. See
26
+ # https://guides.rubyonrails.org/layouts_and_rendering.html#the-status-option
24
27
  # @return [void]
25
28
  def cache_render(serializer, cacheable, options = {})
26
29
  plan = CacheCrispies::Plan.new(serializer, cacheable, options)
@@ -38,7 +41,10 @@ module CacheCrispies
38
41
  plan.cache { serializer.new(cacheable, options).as_json }
39
42
  end
40
43
 
41
- render json: Oj.dump(plan.wrap(serializer_json), mode: OJ_MODE)
44
+ render_hash = { json: Oj.dump(plan.wrap(serializer_json), mode: OJ_MODE) }
45
+ render_hash[:status] = options[:status] if options.key?(:status)
46
+
47
+ render render_hash
42
48
  end
43
49
  end
44
50
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module CacheCrispies
4
4
  # The version of the gem
5
- VERSION = '0.2.1'
5
+ VERSION = '0.3.0'
6
6
  end
@@ -50,5 +50,20 @@ describe CacheCrispies::Controller do
50
50
 
51
51
  subject.cache_render CerealSerializerForController, collection.first
52
52
  end
53
+
54
+ context 'with a status: option' do
55
+ it 'passes the status option to the Rails render call' do
56
+ expect(subject).to receive(:render).with(
57
+ json: { cereal: { name: cereal_names.first } }.to_json,
58
+ status: 418
59
+ )
60
+
61
+ subject.cache_render(
62
+ CerealSerializerForController,
63
+ collection.first,
64
+ status: 418
65
+ )
66
+ end
67
+ end
53
68
  end
54
- end
69
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cache_crispies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Crownoble
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-30 00:00:00.000000000 Z
11
+ date: 2019-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj