ddc 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ddc/controller_builder.rb +7 -2
- data/lib/ddc/version.rb +1 -1
- data/spec/controller_builder_spec.rb +51 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5a636539bd001d456101a2ba453beaf34f03c79
|
4
|
+
data.tar.gz: 0b0dfc64396cbe21c7d0a9d8d1e24b99b0649648
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73e58a273638f57fce3500fc38e504c3ff73bce43069842033a508b2630adbeb630883c1e89baa058fd919b6c599021020d5ae87b0db9cebd9a62086b232107d
|
7
|
+
data.tar.gz: 0f34ccfd5550fc48c4c8ac5bb90c689c188ec25a1ebb0a7041a04900728580f134bd4702cdcfd51722f4bf45a58509e7d092b703554481d6b5a0bc1b7103f27d
|
@@ -76,10 +76,15 @@ module DDC
|
|
76
76
|
respond_to do |format|
|
77
77
|
format.json do
|
78
78
|
if obj.nil?
|
79
|
-
|
79
|
+
render_opts = {
|
80
|
+
json: {errors: errors}, status: status }
|
80
81
|
else
|
81
|
-
|
82
|
+
render_opts = { json: obj, status: status }
|
82
83
|
end
|
84
|
+
|
85
|
+
render_opts[:serializer] = action_desc[:serializer] if action_desc.has_key? :serializer
|
86
|
+
render_opts[:each_serializer] = action_desc[:each_serializer] if action_desc.has_key? :each_serializer
|
87
|
+
render render_opts
|
83
88
|
end
|
84
89
|
format.html do
|
85
90
|
result.each do |k,v|
|
data/lib/ddc/version.rb
CHANGED
@@ -175,6 +175,57 @@ describe DDC::ControllerBuilder do
|
|
175
175
|
class BazService
|
176
176
|
def qux(context) {} end
|
177
177
|
end
|
178
|
+
|
179
|
+
it 'uses specified serializer json render calls' do
|
180
|
+
class FooController
|
181
|
+
def current_user; end
|
182
|
+
def some_user; end
|
183
|
+
def render(args); end
|
184
|
+
def respond_to; end
|
185
|
+
end
|
186
|
+
controller = FooController.new
|
187
|
+
expect(controller).to receive_messages( params: {a: :b})
|
188
|
+
|
189
|
+
|
190
|
+
subject.build :foo,
|
191
|
+
actions: {
|
192
|
+
index: {
|
193
|
+
context: 'foo_context_builder#bar',
|
194
|
+
service: 'baz_service#qux',
|
195
|
+
serializer: MySerializer
|
196
|
+
}
|
197
|
+
|
198
|
+
}
|
199
|
+
|
200
|
+
render_args = nil
|
201
|
+
expect(controller).to receive(:render) do |args|
|
202
|
+
render_args = args
|
203
|
+
end
|
204
|
+
expect(controller).to receive(:respond_to) do |&block|
|
205
|
+
block.call(json_format)
|
206
|
+
end
|
207
|
+
expect_any_instance_of(FooContextBuilder).to receive(:bar).with(hash_including(
|
208
|
+
params: {a: :b})) { :context }
|
209
|
+
|
210
|
+
expect_any_instance_of(BazService).to receive(:qux).with(:context) do
|
211
|
+
{ object: :some_obj, status: :ok }
|
212
|
+
end
|
213
|
+
|
214
|
+
controller.index
|
215
|
+
|
216
|
+
expect(render_args[:serializer]).to eq(MySerializer)
|
217
|
+
end
|
218
|
+
|
219
|
+
class MySerializer
|
220
|
+
end
|
221
|
+
|
222
|
+
class FooContextBuilder
|
223
|
+
def bar(opts) {} end
|
224
|
+
end
|
225
|
+
|
226
|
+
class BazService
|
227
|
+
def qux(context) {} end
|
228
|
+
end
|
178
229
|
end
|
179
230
|
|
180
231
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ddc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shawn Anderson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|