ddy_remote_resource 0.4.9 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/remote_resource/querying/persistence_methods.rb +2 -2
- data/lib/remote_resource/request.rb +1 -1
- data/lib/remote_resource/version.rb +1 -1
- data/spec/lib/remote_resource/querying/persistence_methods_spec.rb +32 -2
- data/spec/lib/remote_resource/request_spec.rb +1 -1
- data/spec/lib/remote_resource/version_spec.rb +1 -1
- 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: 105352f9caf2a46040cd7428628bd73371f09b76
|
4
|
+
data.tar.gz: e64caf4294b2d126b306b8906327e5adea78c249
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,
|
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
|
@@ -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,
|
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
|
|
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.
|
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-
|
11
|
+
date: 2016-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|