restforce 6.1.0 → 6.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +1 -1
- data/.github/workflows/faraday.yml +1 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile +3 -3
- data/README.md +1 -1
- data/lib/restforce/concerns/composite_api.rb +1 -1
- data/lib/restforce/version.rb +1 -1
- data/lib/restforce.rb +1 -1
- data/restforce.gemspec +1 -1
- data/spec/integration/abstract_client_spec.rb +6 -3
- data/spec/unit/concerns/base_spec.rb +1 -1
- data/spec/unit/concerns/composite_api_spec.rb +26 -0
- data/spec/unit/middleware/authentication_spec.rb +3 -3
- data/spec/unit/middleware/authorization_spec.rb +5 -1
- data/spec/unit/middleware/custom_headers_spec.rb +6 -2
- data/spec/unit/middleware/gzip_spec.rb +12 -3
- data/spec/unit/middleware/instance_url_spec.rb +2 -2
- data/spec/unit/middleware/logger_spec.rb +1 -1
- data/spec/unit/sobject_spec.rb +9 -5
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f7a29ac5ff461f9db1f386570aceebfa30244ec519ccd26320e6255cdaddc57
|
4
|
+
data.tar.gz: 556b7407db043fe2a3d5e9fe9183be767693cacacd31fe8ac492aca9fd195194
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0585185aed0e16fea289b78ccb16122306186901195daa5d2b323dedcbb4999e5760910e5d8ceb7966424b8e4d636d20c92f61bcc283f1fe75de3857ca35d68b'
|
7
|
+
data.tar.gz: b17650d7d7984b0b412c2c678a49d61d8d69fc961454aad313c4a8c1ed25ea49f04d68b1d658bb4464b4514f81118f1e69392465a541f0431571d60096e9d9c0
|
data/.github/workflows/build.yml
CHANGED
@@ -10,7 +10,7 @@ jobs:
|
|
10
10
|
# For v2.0.x, we test v2.0.0 and v2.0.1 because v2.0.0 has a special behaviour where
|
11
11
|
# the Net::HTTP adapter is not included. See
|
12
12
|
# https://github.com/lostisland/faraday/blob/main/UPGRADING.md#faraday-20.
|
13
|
-
faraday_version: ['1.1.0', '1.2.0', '1.3.1', '1.4.1', '1.5.1', '1.6.0', '1.7.2', '1.8.0', '1.9.3', '1.10.0', '2.0.0', '2.0.1', '2.1.0', '2.2.0', '2.3.0', '2.4.0', '2.5.0', '2.6.0']
|
13
|
+
faraday_version: ['1.1.0', '1.2.0', '1.3.1', '1.4.1', '1.5.1', '1.6.0', '1.7.2', '1.8.0', '1.9.3', '1.10.0', '2.0.0', '2.0.1', '2.1.0', '2.2.0', '2.3.0', '2.4.0', '2.5.0', '2.6.0', '2.7.0']
|
14
14
|
env:
|
15
15
|
FARADAY_VERSION: ~> ${{ matrix.faraday_version }}
|
16
16
|
steps:
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
faraday_version = ENV.fetch('FARADAY_VERSION', '~>
|
6
|
+
faraday_version = ENV.fetch('FARADAY_VERSION', '~> 2.7.3')
|
7
7
|
|
8
8
|
# Enable us to explicitly pick a Faraday version when running tests
|
9
9
|
gem 'faraday', faraday_version
|
@@ -17,6 +17,6 @@ gem 'rspec', '~> 3.12.0'
|
|
17
17
|
gem 'rspec-collection_matchers', '~> 1.2.0'
|
18
18
|
gem 'rspec-its', '~> 1.3.0'
|
19
19
|
gem 'rspec_junit_formatter', '~> 0.6.0'
|
20
|
-
gem 'rubocop', '~> 1.
|
21
|
-
gem 'simplecov', '~> 0.
|
20
|
+
gem 'rubocop', '~> 1.43.0'
|
21
|
+
gem 'simplecov', '~> 0.22.0'
|
22
22
|
gem 'webmock', '~> 3.18.1'
|
data/README.md
CHANGED
@@ -29,7 +29,7 @@ module Restforce
|
|
29
29
|
if all_or_none && has_errors
|
30
30
|
last_error_index = results.rindex { |result| result['httpStatusCode'] != 412 }
|
31
31
|
last_error = results[last_error_index]
|
32
|
-
raise CompositeAPIError
|
32
|
+
raise CompositeAPIError.new(last_error['body'][0]['errorCode'], response)
|
33
33
|
end
|
34
34
|
|
35
35
|
results
|
data/lib/restforce/version.rb
CHANGED
data/lib/restforce.rb
CHANGED
@@ -49,7 +49,6 @@ module Restforce
|
|
49
49
|
UnauthorizedError = Class.new(Faraday::ClientError)
|
50
50
|
APIVersionError = Class.new(Error)
|
51
51
|
BatchAPIError = Class.new(Error)
|
52
|
-
CompositeAPIError = Class.new(Error)
|
53
52
|
|
54
53
|
# Inherit from Faraday::ResourceNotFound for backwards-compatibility
|
55
54
|
# Consumers of this library that rescue and handle Faraday::ResourceNotFound
|
@@ -60,6 +59,7 @@ module Restforce
|
|
60
59
|
# Consumers of this library that rescue and handle Faraday::ClientError
|
61
60
|
# can continue to do so.
|
62
61
|
ResponseError = Class.new(Faraday::ClientError)
|
62
|
+
CompositeAPIError = Class.new(ResponseError)
|
63
63
|
MatchesMultipleError= Class.new(ResponseError)
|
64
64
|
EntityTooLargeError = Class.new(ResponseError)
|
65
65
|
|
data/restforce.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |gem|
|
|
24
24
|
|
25
25
|
gem.required_ruby_version = '>= 2.7'
|
26
26
|
|
27
|
-
gem.add_dependency 'faraday', '< 2.
|
27
|
+
gem.add_dependency 'faraday', '< 2.8.0', '>= 1.1.0'
|
28
28
|
gem.add_dependency 'faraday-follow_redirects', '<= 0.3.0', '< 1.0.0'
|
29
29
|
gem.add_dependency 'faraday-multipart', '>= 1.0.0', '< 2.0.0'
|
30
30
|
gem.add_dependency 'faraday-net_http', '< 4.0.0'
|
@@ -144,7 +144,10 @@ shared_examples_for Restforce::AbstractClient do
|
|
144
144
|
describe '.update' do
|
145
145
|
context 'with missing Id' do
|
146
146
|
subject { lambda { client.update('Account', Name: 'Foobar') } }
|
147
|
-
it {
|
147
|
+
it {
|
148
|
+
expect { subject.call }.
|
149
|
+
to raise_error ArgumentError, 'ID field missing from provided attributes'
|
150
|
+
}
|
148
151
|
end
|
149
152
|
|
150
153
|
context 'with invalid Id' do
|
@@ -248,7 +251,7 @@ shared_examples_for Restforce::AbstractClient do
|
|
248
251
|
status: 404
|
249
252
|
|
250
253
|
subject { lambda { destroy! } }
|
251
|
-
it {
|
254
|
+
it { expect { subject.call }.to raise_error Faraday::ResourceNotFound }
|
252
255
|
end
|
253
256
|
|
254
257
|
context 'with success' do
|
@@ -431,7 +434,7 @@ shared_examples_for Restforce::AbstractClient do
|
|
431
434
|
end
|
432
435
|
|
433
436
|
subject { lambda { client.query('SELECT some, fields FROM object') } }
|
434
|
-
it {
|
437
|
+
it { expect { subject.call }.to raise_error Restforce::UnauthorizedError }
|
435
438
|
end
|
436
439
|
end
|
437
440
|
|
@@ -123,6 +123,32 @@ describe Restforce::Concerns::CompositeAPI do
|
|
123
123
|
end
|
124
124
|
end.to raise_error(ArgumentError)
|
125
125
|
end
|
126
|
+
|
127
|
+
it 'has response in CompositeAPIError' do
|
128
|
+
response = double('Faraday::Response',
|
129
|
+
body: { 'compositeResponse' =>
|
130
|
+
[{ 'httpStatusCode' => 400,
|
131
|
+
'body' => [{ 'errorCode' =>
|
132
|
+
'DUPLICATE_VALUE' }] }] })
|
133
|
+
client.
|
134
|
+
should_receive(:api_post).
|
135
|
+
with(endpoint, { compositeRequest: [
|
136
|
+
{
|
137
|
+
method: 'POST',
|
138
|
+
url: '/services/data/v38.0/sobjects/Object',
|
139
|
+
body: { name: 'test' },
|
140
|
+
referenceId: 'create_ref'
|
141
|
+
}
|
142
|
+
], allOrNone: true, collateSubrequests: false }.to_json).
|
143
|
+
and_return(response)
|
144
|
+
arg = method == :composite ? { all_or_none: true } : {}
|
145
|
+
expect do
|
146
|
+
client.send(method, **arg) do |subrequests|
|
147
|
+
subrequests.create('Object', 'create_ref', name: 'test')
|
148
|
+
end
|
149
|
+
end.to raise_error(an_instance_of(Restforce::CompositeAPIError).
|
150
|
+
and(having_attributes(response: response)))
|
151
|
+
end
|
126
152
|
end
|
127
153
|
|
128
154
|
describe '#composite' do
|
@@ -15,7 +15,7 @@ describe Restforce::Middleware::Authentication do
|
|
15
15
|
|
16
16
|
describe '.authenticate!' do
|
17
17
|
subject { lambda { middleware.authenticate! } }
|
18
|
-
it {
|
18
|
+
it { expect { subject.call }.to raise_error NotImplementedError }
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '.call' do
|
@@ -26,7 +26,7 @@ describe Restforce::Middleware::Authentication do
|
|
26
26
|
app.should_receive(:call).once
|
27
27
|
end
|
28
28
|
|
29
|
-
it {
|
29
|
+
it { expect { subject.call }.not_to raise_error }
|
30
30
|
end
|
31
31
|
|
32
32
|
context 'when an exception is thrown' do
|
@@ -37,7 +37,7 @@ describe Restforce::Middleware::Authentication do
|
|
37
37
|
and_raise(Restforce::UnauthorizedError.new('something bad'))
|
38
38
|
end
|
39
39
|
|
40
|
-
it {
|
40
|
+
it { expect { subject.call }.to raise_error Restforce::UnauthorizedError }
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -8,6 +8,10 @@ describe Restforce::Middleware::Authorization do
|
|
8
8
|
describe '.call' do
|
9
9
|
subject { lambda { middleware.call(env) } }
|
10
10
|
|
11
|
-
it {
|
11
|
+
it {
|
12
|
+
expect { subject.call }.to change {
|
13
|
+
env[:request_headers]['Authorization']
|
14
|
+
}.to eq 'OAuth token'
|
15
|
+
}
|
12
16
|
end
|
13
17
|
end
|
@@ -9,13 +9,17 @@ describe Restforce::Middleware::CustomHeaders do
|
|
9
9
|
context 'when :request_headers are a Hash' do
|
10
10
|
let(:options) { { request_headers: { 'x-test-header' => 'Test Value' } } }
|
11
11
|
|
12
|
-
it {
|
12
|
+
it {
|
13
|
+
expect { subject.call }.to change {
|
14
|
+
env[:request_headers]['x-test-header']
|
15
|
+
}.to eq 'Test Value'
|
16
|
+
}
|
13
17
|
end
|
14
18
|
|
15
19
|
context 'when :request_headers are not a Hash' do
|
16
20
|
let(:options) { { request_headers: 'bad header' } }
|
17
21
|
|
18
|
-
it {
|
22
|
+
it { expect { subject.call }.not_to(change { env[:request_headers] }) }
|
19
23
|
end
|
20
24
|
end
|
21
25
|
end
|
@@ -27,11 +27,16 @@ describe Restforce::Middleware::Gzip do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'decompresses the body' do
|
30
|
-
|
30
|
+
expect { subject.call }.to change {
|
31
|
+
env[:body]
|
32
|
+
}.to(fixture('sobject/query_success_response'))
|
31
33
|
end
|
32
34
|
|
33
35
|
context 'when :compress is false' do
|
34
|
-
it {
|
36
|
+
it {
|
37
|
+
expect { subject.call }.
|
38
|
+
not_to(change { env[:request_headers]['Accept-Encoding'] })
|
39
|
+
}
|
35
40
|
end
|
36
41
|
|
37
42
|
context 'when :compress is true' do
|
@@ -39,7 +44,11 @@ describe Restforce::Middleware::Gzip do
|
|
39
44
|
options[:compress] = true
|
40
45
|
end
|
41
46
|
|
42
|
-
it {
|
47
|
+
it {
|
48
|
+
expect { subject.call }.to change {
|
49
|
+
env[:request_headers]['Accept-Encoding']
|
50
|
+
}.to('gzip')
|
51
|
+
}
|
43
52
|
end
|
44
53
|
end
|
45
54
|
|
@@ -11,7 +11,7 @@ describe Restforce::Middleware::InstanceURL do
|
|
11
11
|
client.stub_chain :connection, url_prefix: URI.parse('http:/')
|
12
12
|
end
|
13
13
|
|
14
|
-
it {
|
14
|
+
it { expect { subject.call }.to raise_error Restforce::UnauthorizedError }
|
15
15
|
end
|
16
16
|
|
17
17
|
context 'when the instance url is set' do
|
@@ -20,7 +20,7 @@ describe Restforce::Middleware::InstanceURL do
|
|
20
20
|
app.should_receive(:call).once
|
21
21
|
end
|
22
22
|
|
23
|
-
it {
|
23
|
+
it { expect { subject.call }.not_to raise_error }
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/spec/unit/sobject_spec.rb
CHANGED
@@ -48,7 +48,11 @@ describe Restforce::SObject do
|
|
48
48
|
subject(:send_method) { lambda { sobject.send(method) } }
|
49
49
|
|
50
50
|
context 'when an Id was not queried' do
|
51
|
-
it {
|
51
|
+
it {
|
52
|
+
expect do
|
53
|
+
subject.call
|
54
|
+
end.to raise_error ArgumentError, /need to query the Id for the record/
|
55
|
+
}
|
52
56
|
end
|
53
57
|
|
54
58
|
context 'when an Id is present' do
|
@@ -57,7 +61,7 @@ describe Restforce::SObject do
|
|
57
61
|
client.should_receive(receiver)
|
58
62
|
end
|
59
63
|
|
60
|
-
it {
|
64
|
+
it { expect { subject.call }.not_to raise_error }
|
61
65
|
end
|
62
66
|
end
|
63
67
|
end
|
@@ -69,7 +73,7 @@ describe Restforce::SObject do
|
|
69
73
|
client.should_receive(:describe).with('Whizbang')
|
70
74
|
end
|
71
75
|
|
72
|
-
it {
|
76
|
+
it { expect { subject.call }.not_to raise_error }
|
73
77
|
end
|
74
78
|
|
75
79
|
describe '.describe_layouts' do
|
@@ -80,13 +84,13 @@ describe Restforce::SObject do
|
|
80
84
|
client.should_receive(:describe_layouts).with('Whizbang', layout_id)
|
81
85
|
end
|
82
86
|
|
83
|
-
it {
|
87
|
+
it { expect { subject.call }.not_to raise_error }
|
84
88
|
|
85
89
|
context 'when a layout Id is specified' do
|
86
90
|
let(:layout_id) { '012E0000000RHEp' }
|
87
91
|
subject { lambda { sobject.describe_layouts(layout_id) } }
|
88
92
|
|
89
|
-
it {
|
93
|
+
it { expect { subject.call }.not_to raise_error }
|
90
94
|
end
|
91
95
|
end
|
92
96
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restforce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Rogers
|
8
8
|
- Eric J. Holmes
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-01-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -17,7 +17,7 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "<"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 2.
|
20
|
+
version: 2.8.0
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 1.1.0
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
requirements:
|
28
28
|
- - "<"
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: 2.
|
30
|
+
version: 2.8.0
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.1.0
|
@@ -278,7 +278,7 @@ metadata:
|
|
278
278
|
source_code_uri: https://github.com/restforce/restforce
|
279
279
|
changelog_uri: https://github.com/restforce/restforce/blob/master/CHANGELOG.md
|
280
280
|
rubygems_mfa_required: 'true'
|
281
|
-
post_install_message:
|
281
|
+
post_install_message:
|
282
282
|
rdoc_options: []
|
283
283
|
require_paths:
|
284
284
|
- lib
|
@@ -293,8 +293,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
293
293
|
- !ruby/object:Gem::Version
|
294
294
|
version: '0'
|
295
295
|
requirements: []
|
296
|
-
rubygems_version: 3.1
|
297
|
-
signing_key:
|
296
|
+
rubygems_version: 3.4.1
|
297
|
+
signing_key:
|
298
298
|
specification_version: 4
|
299
299
|
summary: A lightweight Ruby client for the Salesforce REST API
|
300
300
|
test_files: []
|