json-crud-api 0.0.9 → 0.0.10

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: 783895fbee97ba45427d51d8f0220e3aee4a60b9
4
- data.tar.gz: 311de6db45e1d3db7bd3ac7108577d5f8fba1577
3
+ metadata.gz: 6729e49ff86fc11ee1d2983ad50f51882271dc17
4
+ data.tar.gz: 635e5569006dfa942d6f1b1e090f1326e085f19c
5
5
  SHA512:
6
- metadata.gz: 77dab5ab969c0a1450baa4933bddd00222cf5967cc2fd46d9ef6337d9d1935f2baccbc5fcd20f3b9e29dd6d2a1f318ce7705586cd4b430f10ef4c25ad34913af
7
- data.tar.gz: 7d4bb5bedaaab7decf7876b8cdd846457ea669bdf820af2c889dff24c8842e20e1c541042bd5c13f2972d3e9e7a5c81e8b34ca8cb9d85357ac8abb291a3d3da4
6
+ metadata.gz: b64f144c33f2ef911b0e84752d1dfb2e09edd28a890cf49052c5dd54bd060c57b299863ab3f959cf119d65d2e27e11485cb40ed13afc3d07638cd0e28c922e52
7
+ data.tar.gz: 5a489916c393614074d6941038167691a49335566fbae2aba9c884f443219c6fe88e1fc2279d8fdc510c3a369662d9594bf12b43a9a1be92d2adf0375fc92b9f
@@ -27,7 +27,7 @@ module JsonCrudApi
27
27
  presenter = settings.presenters[key]
28
28
  return fail_unauthorized unless service.user_authorized_for? :create
29
29
  post_data = presenter.parse @payload, :post
30
- return fail_with_errors unless service.is_valid? post_data, :create, self
30
+ return fail_with_errors unless service.valid_for? post_data, :create, self
31
31
  entity = service.create post_data
32
32
  JSON.fast_generate presenter.render(entity, :post)
33
33
  end
@@ -37,7 +37,7 @@ module JsonCrudApi
37
37
  presenter = settings.presenters[key]
38
38
  return fail_unauthorized unless service.user_authorized_for? :update
39
39
  put_data = presenter.parse @payload, :put
40
- return fail_with_errors unless service.is_valid? put_data, :update, self
40
+ return fail_with_errors unless service.valid_for? put_data, :update, self
41
41
  return fail_not_found unless service.update params["id"], put_data
42
42
  entity = service.get params["id"]
43
43
  JSON.fast_generate presenter.render(entity, :put)
@@ -143,7 +143,7 @@ describe JsonCrudApi::AuthClient do
143
143
  expect(@test.test_settings.presenters).to receive(:[]).with('thekey').and_return(@presenter)
144
144
 
145
145
  expect(@service).to receive(:user_authorized_for?).with(:create).and_return(true)
146
- expect(@service).to receive(:is_valid?).with({ :test_output => 12398}, :create, @test).and_return(true)
146
+ expect(@service).to receive(:valid_for?).with({ :test_output => 12398}, :create, @test).and_return(true)
147
147
  expect(@service).to receive(:create).with({ :test_output => 12398}).and_return({ :test_output => 77234})
148
148
 
149
149
  expect(@presenter).to receive(:parse).with(@test.payload, :post).and_return({ :test_output => 12398})
@@ -152,12 +152,12 @@ describe JsonCrudApi::AuthClient do
152
152
  expect(@test.send(:crud_post,'thekey')).to eq '{"test_output":12313}'
153
153
  end
154
154
 
155
- it 'should fail with 422 if service is_valid? fails' do
155
+ it 'should fail with 422 if service valid_for? fails' do
156
156
  expect(@test.test_settings.services).to receive(:[]).with('thekey').and_return(@service)
157
157
  expect(@test.test_settings.presenters).to receive(:[]).with('thekey').and_return(@presenter)
158
158
 
159
159
  expect(@service).to receive(:user_authorized_for?).with(:create).and_return(true)
160
- expect(@service).to receive(:is_valid?).with({ :test_output => 12398}, :create, @test).and_return(false)
160
+ expect(@service).to receive(:valid_for?).with({ :test_output => 12398}, :create, @test).and_return(false)
161
161
 
162
162
  expect(@presenter).to receive(:parse).with(@test.payload, :post).and_return({ :test_output => 12398})
163
163
 
@@ -203,7 +203,7 @@ describe JsonCrudApi::AuthClient do
203
203
 
204
204
  expect(@service).to receive(:user_authorized_for?).with(:update).and_return(true)
205
205
  expect(@presenter).to receive(:parse).with(@test.payload, :put).and_return({ :test_output => 12398})
206
- expect(@service).to receive(:is_valid?).with({ :test_output => 12398},:update,@test).and_return(true)
206
+ expect(@service).to receive(:valid_for?).with({ :test_output => 12398},:update,@test).and_return(true)
207
207
  expect(@service).to receive(:update).with(7345, { :test_output => 12398}).and_return(true)
208
208
  expect(@service).to receive(:get).with(7345).and_return({ :test_output => 77234})
209
209
 
@@ -212,13 +212,13 @@ describe JsonCrudApi::AuthClient do
212
212
  expect(@test.send(:crud_put,'thekey')).to eq '{"test_output":12313}'
213
213
  end
214
214
 
215
- it 'should fail_with_errors if service is_valid? fails' do
215
+ it 'should fail_with_errors if service valid_for? fails' do
216
216
  expect(@test.test_settings.services).to receive(:[]).with('thekey').and_return(@service)
217
217
  expect(@test.test_settings.presenters).to receive(:[]).with('thekey').and_return(@presenter)
218
218
 
219
219
  expect(@service).to receive(:user_authorized_for?).with(:update).and_return(true)
220
220
  expect(@presenter).to receive(:parse).with(@test.payload, :put).and_return({ :test_output => 12398})
221
- expect(@service).to receive(:is_valid?).with({ :test_output => 12398},:update,@test).and_return(false)
221
+ expect(@service).to receive(:valid_for?).with({ :test_output => 12398},:update,@test).and_return(false)
222
222
  expect(@presenter).not_to receive(:render)
223
223
 
224
224
  expect(@test).to receive(:fail_with_errors)
@@ -231,7 +231,7 @@ describe JsonCrudApi::AuthClient do
231
231
  expect(@test.test_settings.presenters).to receive(:[]).with('thekey').and_return(@presenter)
232
232
 
233
233
  expect(@service).to receive(:user_authorized_for?).with(:update).and_return(true)
234
- expect(@service).to receive(:is_valid?).with({ :test_output => 12398},:update,@test).and_return(true)
234
+ expect(@service).to receive(:valid_for?).with({ :test_output => 12398},:update,@test).and_return(true)
235
235
  expect(@service).to receive(:update).with(7345, { :test_output => 12398}).and_return(false)
236
236
 
237
237
  expect(@test).to receive(:fail_not_found)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json-crud-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Cully