ddy_remote_resource 1.3.4 → 1.3.6
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/.github/workflows/ci.yml +14 -7
- data/CHANGELOG.md +12 -0
- data/Gemfile +6 -0
- data/lib/remote_resource/request.rb +3 -0
- data/lib/remote_resource/version.rb +1 -1
- data/remote_resource.gemspec +2 -2
- 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: 8273653a4fe09403fe198cfb937445a648215aa38ae612f324ce857cd8055e08
|
|
4
|
+
data.tar.gz: d97d4bddfcefc828c6ff8103b15a1293f2297f64ab29b2c47bf5bd6bb62fac2b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 78224b326ee6fbeb1d7867e1621dbf056c45be06d6b261f75b0938d341802b66fb7f166933f4e4c60f9b5b10e543ea928f2a13f29b60eb7482a8217095c992fc
|
|
7
|
+
data.tar.gz: ca454a2eb321319a36bdb3f2dd99dde405945f33e66e8d36d40e88cea20a51eb6bfe1ee3f693b408ffd48ef21e197eb0e93d80c1178aade40fe864bec50d43d9
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -14,21 +14,28 @@ jobs:
|
|
|
14
14
|
runs-on: ubuntu-latest
|
|
15
15
|
|
|
16
16
|
strategy:
|
|
17
|
+
fail-fast: false
|
|
17
18
|
matrix:
|
|
18
|
-
ruby-version: [3.1, 3.2, 3.3]
|
|
19
|
+
ruby-version: ['3.1', '3.2', '3.3', '3.4']
|
|
20
|
+
rails-version: ['7.2.3', '8.0.5']
|
|
21
|
+
exclude:
|
|
22
|
+
- ruby-version: '3.1' # Rails 8 requires Ruby >= 3.2
|
|
23
|
+
rails-version: '8.0.5'
|
|
24
|
+
|
|
25
|
+
name: Ruby ${{ matrix.ruby-version }} / Rails ${{ matrix.rails-version }}
|
|
26
|
+
|
|
27
|
+
env:
|
|
28
|
+
RAILS_VERSION: ${{ matrix.rails-version }}
|
|
19
29
|
|
|
20
30
|
steps:
|
|
21
31
|
- name: Check out code
|
|
22
|
-
uses: actions/checkout@
|
|
32
|
+
uses: actions/checkout@v4
|
|
23
33
|
|
|
24
34
|
- name: Set up Ruby
|
|
25
35
|
uses: ruby/setup-ruby@v1
|
|
26
36
|
with:
|
|
27
|
-
ruby-version: ${{ matrix.ruby-version }}
|
|
28
|
-
bundler-cache: true
|
|
29
|
-
|
|
30
|
-
- name: Install dependencies
|
|
31
|
-
run: bundle install
|
|
37
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
38
|
+
bundler-cache: true
|
|
32
39
|
|
|
33
40
|
- name: Run tests
|
|
34
41
|
run: bundle exec rake spec
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [1.3.6] - 2026-11-05
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Allow Rails 8.0 (`activesupport` and `activemodel` `< 8.1`).
|
|
10
|
+
|
|
11
|
+
## [1.3.5] - 2026-02-24
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Enrich DELETE action with body params
|
|
16
|
+
|
|
5
17
|
## [1.3.4] - 2024-10-29
|
|
6
18
|
|
|
7
19
|
### Added
|
data/Gemfile
CHANGED
|
@@ -2,3 +2,9 @@ source 'https://rubygems.org'
|
|
|
2
2
|
|
|
3
3
|
# Specify your gem's dependencies in remote_resource.gemspec
|
|
4
4
|
gemspec
|
|
5
|
+
|
|
6
|
+
# CI runs the suite against each supported Rails line (see .github/workflows/ci.yml).
|
|
7
|
+
if (rails_version = ENV['RAILS_VERSION'])
|
|
8
|
+
gem 'activesupport', "~> #{rails_version}"
|
|
9
|
+
gem 'activemodel', "~> #{rails_version}"
|
|
10
|
+
end
|
|
@@ -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
|
data/remote_resource.gemspec
CHANGED
|
@@ -27,8 +27,8 @@ Gem::Specification.new do |spec|
|
|
|
27
27
|
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
|
28
28
|
spec.add_development_dependency 'terminal-notifier-guard', '~> 1.6'
|
|
29
29
|
|
|
30
|
-
spec.add_runtime_dependency 'activesupport', '>= 4.1', '< 8'
|
|
31
|
-
spec.add_runtime_dependency 'activemodel', '>= 4.1', '< 8'
|
|
30
|
+
spec.add_runtime_dependency 'activesupport', '>= 4.1', '< 8.1'
|
|
31
|
+
spec.add_runtime_dependency 'activemodel', '>= 4.1', '< 8.1'
|
|
32
32
|
spec.add_runtime_dependency 'virtus', '~> 1.0', '>= 1.0.4'
|
|
33
33
|
spec.add_runtime_dependency 'mime-types', '~> 3.0'
|
|
34
34
|
spec.add_runtime_dependency 'ethon'
|
|
@@ -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,7 +1,7 @@
|
|
|
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.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Digidentity
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2026-11-05 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: bundler
|
|
@@ -133,7 +133,7 @@ dependencies:
|
|
|
133
133
|
version: '4.1'
|
|
134
134
|
- - "<"
|
|
135
135
|
- !ruby/object:Gem::Version
|
|
136
|
-
version: '8'
|
|
136
|
+
version: '8.1'
|
|
137
137
|
type: :runtime
|
|
138
138
|
prerelease: false
|
|
139
139
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -143,7 +143,7 @@ dependencies:
|
|
|
143
143
|
version: '4.1'
|
|
144
144
|
- - "<"
|
|
145
145
|
- !ruby/object:Gem::Version
|
|
146
|
-
version: '8'
|
|
146
|
+
version: '8.1'
|
|
147
147
|
- !ruby/object:Gem::Dependency
|
|
148
148
|
name: activemodel
|
|
149
149
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -153,7 +153,7 @@ dependencies:
|
|
|
153
153
|
version: '4.1'
|
|
154
154
|
- - "<"
|
|
155
155
|
- !ruby/object:Gem::Version
|
|
156
|
-
version: '8'
|
|
156
|
+
version: '8.1'
|
|
157
157
|
type: :runtime
|
|
158
158
|
prerelease: false
|
|
159
159
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -163,7 +163,7 @@ dependencies:
|
|
|
163
163
|
version: '4.1'
|
|
164
164
|
- - "<"
|
|
165
165
|
- !ruby/object:Gem::Version
|
|
166
|
-
version: '8'
|
|
166
|
+
version: '8.1'
|
|
167
167
|
- !ruby/object:Gem::Dependency
|
|
168
168
|
name: virtus
|
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|