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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d863415ede238942b129990f02f18cea1aa4559
4
- data.tar.gz: 7c3d1bcccd7bdc03bcae2ef81961ce42f2310b14
3
+ metadata.gz: b5a636539bd001d456101a2ba453beaf34f03c79
4
+ data.tar.gz: 0b0dfc64396cbe21c7d0a9d8d1e24b99b0649648
5
5
  SHA512:
6
- metadata.gz: dc54b713028b679613973789cfec78b0fcc199bca49f8d0acae78bf073113feefef3d2d357f9ab2264815cc4e4ada39daf21f21e2e12ff5b4b6ad7cec942fdff
7
- data.tar.gz: afe03537078e703abf8737db8ec99300da5ac634f9f24864c35387193ff8281d108e813d462d6f66d7eeb117fc4251df70bf165b60c649429ca60ace0e68aaee
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
- render json: {errors: errors}, status: status
79
+ render_opts = {
80
+ json: {errors: errors}, status: status }
80
81
  else
81
- render json: obj, status: status
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
@@ -1,3 +1,3 @@
1
1
  module Ddc
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -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.2
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-03-13 00:00:00.000000000 Z
11
+ date: 2015-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler