ddy_remote_resource 0.4.9 → 0.4.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4fb6043c6ff3de6d36965017bffec730b1659f17
4
- data.tar.gz: 32cf30b232c83c0a42c969ff24ce78f362a3bd6c
3
+ metadata.gz: 105352f9caf2a46040cd7428628bd73371f09b76
4
+ data.tar.gz: e64caf4294b2d126b306b8906327e5adea78c249
5
5
  SHA512:
6
- metadata.gz: 948ad8bad7470092350a50a357f63810ff24728e4b9b4114766a64d56c217e720ba76727b4ea3b4c3a982e044db6c4e4a905b0cf0626fba01cdee7060338dffc
7
- data.tar.gz: 02723a379602c6bb06e99b7c63882d833a79562122951e886c050ee7c4dd044d0242e85168eae0d3fe5d86a90155d03627e1c9e2d5bafb87409ffdf555349aec
6
+ metadata.gz: 697f9c48d2761ed0c689866ea9ffb0a86133b9232a822807a8bdbe8f19c4eca5f7b0dab48b0767fd83054389cb46f29a13990b9437225b99dc505194cff9b748
7
+ data.tar.gz: 8dcf2452275ea8ecf7a03f83a81f6537fd2853d5694a48e7eadaaeb64c97eba1d5e928118a3b57f077554a70c8bc205e78c9b2bae581805ffff22fbd2eab0776
@@ -13,7 +13,7 @@ module RemoteResource
13
13
 
14
14
  def destroy(id, connection_options = {})
15
15
  resource = new
16
- response = RemoteResource::Request.new(self, :delete, { id: id }, connection_options).perform
16
+ response = RemoteResource::Request.new(self, :delete, { id: id }, connection_options.reverse_merge(no_attributes: true)).perform
17
17
  resource.handle_response(response)
18
18
  end
19
19
  end
@@ -41,7 +41,7 @@ module RemoteResource
41
41
 
42
42
  def destroy(connection_options = {})
43
43
  id.present? || raise(RemoteResource::IdMissingError.new("`id` is missing from resource"))
44
- response = RemoteResource::Request.new(self, :delete, { id: id }, connection_options).perform
44
+ response = RemoteResource::Request.new(self, :delete, { id: id }, connection_options.reverse_merge(no_attributes: true)).perform
45
45
  handle_response(response)
46
46
  success? ? self : false
47
47
  end
@@ -32,7 +32,7 @@ module RemoteResource
32
32
  when :put, :patch, :post
33
33
  response = connection.public_send rest_action, determined_request_url, body: determined_attributes, headers: determined_headers
34
34
  when :delete
35
- response = connection.public_send rest_action, determined_request_url, body: determined_attributes, headers: determined_headers
35
+ response = connection.public_send rest_action, determined_request_url, params: determined_params, headers: determined_headers
36
36
  else
37
37
  raise RemoteResource::RESTActionUnknown, "for action: '#{rest_action}'"
38
38
  end
@@ -1,3 +1,3 @@
1
1
  module RemoteResource
2
- VERSION = '0.4.9'
2
+ VERSION = '0.4.10'
3
3
  end
@@ -60,7 +60,7 @@ describe RemoteResource::Querying::PersistenceMethods do
60
60
  end
61
61
 
62
62
  it 'performs a RemoteResource::Request' do
63
- expect(RemoteResource::Request).to receive(:new).with(dummy_class, :delete, { id: '15' }, {}).and_call_original
63
+ expect(RemoteResource::Request).to receive(:new).with(dummy_class, :delete, { id: '15' }, { no_attributes: true }).and_call_original
64
64
  expect_any_instance_of(RemoteResource::Request).to receive(:perform)
65
65
  dummy_class.destroy('15')
66
66
  end
@@ -69,6 +69,21 @@ describe RemoteResource::Querying::PersistenceMethods do
69
69
  expect_any_instance_of(dummy_class).to receive(:handle_response).with response
70
70
  dummy_class.destroy('15')
71
71
  end
72
+
73
+ context 'request' do
74
+ let(:response) { { status: 200, body: '' } }
75
+ before { allow_any_instance_of(RemoteResource::Request).to receive(:perform).and_call_original }
76
+
77
+ it 'generates correct request url' do
78
+ stub_request(:delete, 'https://foobar.com/persistence_methods_dummy/15.json').with(body: nil).to_return(response)
79
+ dummy_class.destroy('15')
80
+ end
81
+
82
+ it 'includes params' do
83
+ stub_request(:delete, 'https://foobar.com/persistence_methods_dummy/15.json?pseudonym=3s8e3j').with(body: nil).to_return(response)
84
+ dummy_class.destroy('15', params: { pseudonym: '3s8e3j' })
85
+ end
86
+ end
72
87
  end
73
88
 
74
89
  describe '#update_attributes' do
@@ -208,7 +223,7 @@ describe RemoteResource::Querying::PersistenceMethods do
208
223
  end
209
224
 
210
225
  it 'performs a RemoteResource::Request with rest_action :delete' do
211
- expect(RemoteResource::Request).to receive(:new).with(dummy, :delete, { id: dummy.id }, {}).and_call_original
226
+ expect(RemoteResource::Request).to receive(:new).with(dummy, :delete, { id: dummy.id }, { no_attributes: true }).and_call_original
212
227
  expect_any_instance_of(RemoteResource::Request).to receive(:perform)
213
228
  dummy.destroy
214
229
  end
@@ -218,6 +233,21 @@ describe RemoteResource::Querying::PersistenceMethods do
218
233
  dummy.destroy
219
234
  end
220
235
 
236
+ context 'request' do
237
+ let(:response) { { status: 200, body: '' } }
238
+ before { allow_any_instance_of(RemoteResource::Request).to receive(:perform).and_call_original }
239
+
240
+ it 'generates correct request url' do
241
+ stub_request(:delete, 'https://foobar.com/persistence_methods_dummy/18.json').with(body: nil).to_return(response)
242
+ dummy.destroy
243
+ end
244
+
245
+ it 'includes params' do
246
+ stub_request(:delete, 'https://foobar.com/persistence_methods_dummy/18.json?pseudonym=3s8e3j').with(body: nil).to_return(response)
247
+ dummy.destroy(params: { pseudonym: '3s8e3j' })
248
+ end
249
+ end
250
+
221
251
  context 'when the destroy was successful' do
222
252
  it 'returns the resource' do
223
253
  allow(dummy).to receive(:success?) { true }
@@ -275,7 +275,7 @@ describe RemoteResource::Request do
275
275
  let(:rest_action) { 'delete' }
276
276
 
277
277
  it 'makes a DELETE request with the attributes as body' do
278
- expect(connection).to receive(:delete).with(determined_request_url, body: determined_attributes, headers: determined_headers).and_call_original
278
+ expect(connection).to receive(:delete).with(determined_request_url, params: determined_params, headers: determined_headers).and_call_original
279
279
  request.perform
280
280
  end
281
281
 
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe RemoteResource::VERSION do
4
4
 
5
- it { should eql '0.4.9' }
5
+ it { should eql '0.4.10' }
6
6
  end
7
7
 
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddy_remote_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan van der Pas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-25 00:00:00.000000000 Z
11
+ date: 2016-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler