ddy_remote_resource 1.3.4 → 1.3.5
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/remote_resource/request.rb +3 -0
- data/lib/remote_resource/version.rb +1 -1
- data/spec/integration/destroy_spec.rb +14 -0
- data/spec/lib/remote_resource/querying/persistence_methods_spec.rb +9 -0
- data/spec/lib/remote_resource/request_spec.rb +73 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '08f25322ca3d01eebb8816f4623aeec281e47b71e89ed46ba810d28f77abbb0e'
|
|
4
|
+
data.tar.gz: d1c8965207f1dd8c7df47de47e709f796918592307c6445941ca45898a2f1e97
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f0738e9617ee9716b7553553314bac7163bb6cce9f2ef7cd6b1689d2dde0575f51035e475887f79c568d2aec4c62c9ab171e5aaf87983188f4ae1ee55b8adbe4
|
|
7
|
+
data.tar.gz: 4c98e7bc8cbb8c1d508310a163ad498371a9e7e490071f72d166ac3961c4223f34bed9ece37ad4ac572503ed389fe0f427838f37f8ccc67085970b992abb9b7a
|
data/CHANGELOG.md
CHANGED
|
@@ -81,6 +81,9 @@ module RemoteResource
|
|
|
81
81
|
case http_action
|
|
82
82
|
when :put, :patch, :post
|
|
83
83
|
attributes.to_json
|
|
84
|
+
when :delete
|
|
85
|
+
body_attributes = connection_options[:body]
|
|
86
|
+
body_attributes.present? ? body_attributes.to_json : nil
|
|
84
87
|
when :get
|
|
85
88
|
connection_options[:params].to_json if connection_options[:force_get_params_in_body]
|
|
86
89
|
else
|
|
@@ -180,6 +180,20 @@ RSpec.describe '.destroy and #destroy' do
|
|
|
180
180
|
end
|
|
181
181
|
end
|
|
182
182
|
|
|
183
|
+
describe 'with connection_options[:body]' do
|
|
184
|
+
let!(:expected_request) do
|
|
185
|
+
mock_request = stub_request(:delete, 'https://www.example.com/posts/12.json')
|
|
186
|
+
mock_request.with(body: { pseudonym: 'pseudonym' }.to_json, headers: expected_default_headers.merge('Content-Type' => 'application/json'))
|
|
187
|
+
mock_request.to_return(status: 204, body: response_body.to_json)
|
|
188
|
+
mock_request
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
it 'performs the correct HTTP DELETE request' do
|
|
192
|
+
resource.destroy(body: { pseudonym: 'pseudonym' })
|
|
193
|
+
expect(expected_request).to have_been_requested
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
183
197
|
describe 'with connection_options[:headers]' do
|
|
184
198
|
let!(:expected_request) do
|
|
185
199
|
mock_request = stub_request(:delete, 'https://www.example.com/posts/12.json')
|
|
@@ -415,6 +415,15 @@ RSpec.describe RemoteResource::Querying::PersistenceMethods do
|
|
|
415
415
|
end
|
|
416
416
|
end
|
|
417
417
|
|
|
418
|
+
it 'sends the body when connection_options[:body] is present' do
|
|
419
|
+
expected_request = stub_request(:delete, 'https://www.example.com/posts/12.json')
|
|
420
|
+
.with(body: { pseudonym: 'pseudonym' }.to_json)
|
|
421
|
+
.to_return(status: 204, body: response_body.to_json)
|
|
422
|
+
|
|
423
|
+
resource.destroy(body: { pseudonym: 'pseudonym' })
|
|
424
|
+
expect(expected_request).to have_been_requested
|
|
425
|
+
end
|
|
426
|
+
|
|
418
427
|
it 'does NOT change the given connection_options' do
|
|
419
428
|
connection_options = { headers: { 'Foo' => 'Bar' } }
|
|
420
429
|
|
|
@@ -267,7 +267,55 @@ RSpec.describe RemoteResource::Request do
|
|
|
267
267
|
let(:expected_body) { nil }
|
|
268
268
|
let(:expected_connection_options) { request.connection_options }
|
|
269
269
|
|
|
270
|
-
it 'makes a DELETE request
|
|
270
|
+
it 'makes a DELETE request without a body' do
|
|
271
|
+
expect(connection).to receive(:delete).with(expected_request_url, params: expected_params,
|
|
272
|
+
body: expected_body, headers: expected_headers,
|
|
273
|
+
connecttimeout: 30, timeout: 120).and_call_original
|
|
274
|
+
request.perform
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
include_examples 'a conditional construct for the response'
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
context 'when the http_action is :delete with connection_options[:body]' do
|
|
281
|
+
let(:http_action) { 'delete' }
|
|
282
|
+
let(:attributes) do
|
|
283
|
+
{ id: 15 }
|
|
284
|
+
end
|
|
285
|
+
let(:connection_options) do
|
|
286
|
+
{ params: { pseudonym: 'pseudonym' }, body: { pseudonym: 'pseudonym', labels: [1, '2', 'three'] } }
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
let(:expected_request_url) { 'http://www.foobar.com/request_dummy/15.json' }
|
|
290
|
+
let(:expected_params) { RemoteResource::Util.encode_params_to_query({ pseudonym: 'pseudonym' }) }
|
|
291
|
+
let(:expected_headers) { described_class::DEFAULT_HEADERS.merge(described_class::DEFAULT_CONTENT_TYPE) }
|
|
292
|
+
let(:expected_body) { JSON.generate(connection_options[:body]) }
|
|
293
|
+
let(:expected_connection_options) { request.connection_options }
|
|
294
|
+
|
|
295
|
+
it 'makes a DELETE request with the body from connection_options[:body]' do
|
|
296
|
+
expect(connection).to receive(:delete).with(expected_request_url, params: expected_params,
|
|
297
|
+
body: expected_body, headers: expected_headers,
|
|
298
|
+
connecttimeout: 30, timeout: 120).and_call_original
|
|
299
|
+
request.perform
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
include_examples 'a conditional construct for the response'
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
context 'when the http_action is :delete without attributes' do
|
|
306
|
+
let(:http_action) { 'delete' }
|
|
307
|
+
let(:attributes) { {} }
|
|
308
|
+
let(:connection_options) do
|
|
309
|
+
{ id: 15, params: { pseudonym: 'pseudonym' } }
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
let(:expected_request_url) { 'http://www.foobar.com/request_dummy/15.json' }
|
|
313
|
+
let(:expected_params) { RemoteResource::Util.encode_params_to_query({ pseudonym: 'pseudonym' }) }
|
|
314
|
+
let(:expected_headers) { described_class::DEFAULT_HEADERS }
|
|
315
|
+
let(:expected_body) { nil }
|
|
316
|
+
let(:expected_connection_options) { request.connection_options }
|
|
317
|
+
|
|
318
|
+
it 'makes a DELETE request without body' do
|
|
271
319
|
expect(connection).to receive(:delete).with(expected_request_url, params: expected_params,
|
|
272
320
|
body: expected_body, headers: expected_headers,
|
|
273
321
|
connecttimeout: 30, timeout: 120).and_call_original
|
|
@@ -460,6 +508,30 @@ RSpec.describe RemoteResource::Request do
|
|
|
460
508
|
expect(request.body).to be_nil
|
|
461
509
|
end
|
|
462
510
|
end
|
|
511
|
+
|
|
512
|
+
context 'when the http_action is :delete and connection_options[:body] is present' do
|
|
513
|
+
let(:http_action) { :delete }
|
|
514
|
+
let(:connection_options) do
|
|
515
|
+
{ body: { pseudonym: 'pseudonym', labels: [1, '2', 'three'] } }
|
|
516
|
+
end
|
|
517
|
+
|
|
518
|
+
let(:expected_body) do
|
|
519
|
+
'{"pseudonym":"pseudonym","labels":[1,"2","three"]}'
|
|
520
|
+
end
|
|
521
|
+
|
|
522
|
+
it 'returns the JSON-encoded connection_options[:body]' do
|
|
523
|
+
expect(request.body).to eql expected_body
|
|
524
|
+
end
|
|
525
|
+
end
|
|
526
|
+
|
|
527
|
+
context 'when the http_action is :delete and connection_options[:body] is not present' do
|
|
528
|
+
let(:http_action) { :delete }
|
|
529
|
+
|
|
530
|
+
it 'returns nil' do
|
|
531
|
+
expect(request.body).to be_nil
|
|
532
|
+
end
|
|
533
|
+
end
|
|
534
|
+
|
|
463
535
|
end
|
|
464
536
|
|
|
465
537
|
describe '#attributes' do
|
metadata
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ddy_remote_resource
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Digidentity
|
|
8
8
|
- Johnny Dongelmans
|
|
9
9
|
- Jan van der Pas
|
|
10
|
-
autorequire:
|
|
10
|
+
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2026-03-04 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: bundler
|
|
@@ -309,7 +309,7 @@ homepage: https://github.com/digidentity/ddy_remote_resource
|
|
|
309
309
|
licenses:
|
|
310
310
|
- MIT
|
|
311
311
|
metadata: {}
|
|
312
|
-
post_install_message:
|
|
312
|
+
post_install_message:
|
|
313
313
|
rdoc_options: []
|
|
314
314
|
require_paths:
|
|
315
315
|
- lib
|
|
@@ -324,8 +324,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
324
324
|
- !ruby/object:Gem::Version
|
|
325
325
|
version: '0'
|
|
326
326
|
requirements: []
|
|
327
|
-
rubygems_version: 3.
|
|
328
|
-
signing_key:
|
|
327
|
+
rubygems_version: 3.0.3.1
|
|
328
|
+
signing_key:
|
|
329
329
|
specification_version: 4
|
|
330
330
|
summary: RemoteResource, a gem to use resources with REST services.
|
|
331
331
|
test_files:
|