cache_crispies 0.2.1 → 0.3.0
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.
- checksums.yaml +4 -4
- data/lib/cache_crispies/controller.rb +7 -1
- data/lib/cache_crispies/version.rb +1 -1
- data/spec/controller_spec.rb +16 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76ca43cc7ba1c1a1b9dbee3f37d3744044ee9ce41b2bfd70033b479b465275c3
|
4
|
+
data.tar.gz: 159e4e9ff0c3081e223bfd8343fb6aaa07515f7fd380a55b154894b7dceaed91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
data/spec/controller_spec.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2019-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|