restforce 4.2.0 → 4.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +2 -2
- data/CHANGELOG.md +5 -0
- data/lib/restforce.rb +6 -6
- data/lib/restforce/concerns/api.rb +1 -1
- data/lib/restforce/concerns/connection.rb +3 -3
- data/lib/restforce/middleware/authentication.rb +4 -1
- data/lib/restforce/middleware/instance_url.rb +1 -1
- data/lib/restforce/version.rb +1 -1
- data/restforce.gemspec +2 -2
- data/spec/integration/abstract_client_spec.rb +2 -2
- data/spec/unit/concerns/api_spec.rb +1 -1
- data/spec/unit/middleware/authentication_spec.rb +21 -0
- data/spec/unit/middleware/raise_error_spec.rb +10 -10
- data/spec/unit/sobject_spec.rb +2 -5
- 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: c4f7647ad705f0f4eac359a3b1e792ab4603e9ae4d177570e9369734f7ff3356
|
4
|
+
data.tar.gz: 7fc076cb9239ebd513926e068d5d1e4ebec01cbb5245e919fd165ea5bf7b841c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad1cfc119e9d3a64d5491c667254647a1e79298bebb7c036dee95f87b2a6823f0ed5fbb862dc29c6d25166399042767ecae5520498726fa4025b99b439bcd9f1
|
7
|
+
data.tar.gz: f8e0ab3e2cc1e74e4a1d8d50da2ca8b5bcb13436765993c8737582703248c1c47ca2c6ff02430f19390c02f1b5d95960e6d40e5510ef53e5b25d4e61add35ecc
|
data/.rubocop_todo.yml
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
# SupportedHashRocketStyles: key, separator, table
|
13
13
|
# SupportedColonStyles: key, separator, table
|
14
14
|
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
15
|
-
Layout/
|
15
|
+
Layout/HashAlignment:
|
16
16
|
Exclude:
|
17
17
|
- 'lib/restforce/middleware/logger.rb'
|
18
18
|
- 'restforce.gemspec'
|
@@ -23,7 +23,7 @@ Layout/AlignHash:
|
|
23
23
|
# Cop supports --auto-correct.
|
24
24
|
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
25
25
|
# SupportedStyles: special_inside_parentheses, consistent, align_braces
|
26
|
-
Layout/
|
26
|
+
Layout/FirstHashElementIndentation:
|
27
27
|
Exclude:
|
28
28
|
- 'lib/restforce/concerns/connection.rb'
|
29
29
|
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 4.2.1 (Dec 4, 2019)
|
2
|
+
|
3
|
+
* Handle empty response bodies returned with authentication errors (@sylvandor)
|
4
|
+
* Fix Faraday deprecation warning in newer Faraday versions (`v0.17.1` onwards) caused by inheriting from a deprecated class
|
5
|
+
|
1
6
|
## 4.2.0 (Oct 23, 2019)
|
2
7
|
|
3
8
|
* Add support for platform events, CDC, generic events, etc. in the Streaming API (@nathanKramer)
|
data/lib/restforce.rb
CHANGED
@@ -48,15 +48,15 @@ module Restforce
|
|
48
48
|
APIVersionError = Class.new(Error)
|
49
49
|
BatchAPIError = Class.new(Error)
|
50
50
|
|
51
|
-
# Inherit from Faraday::
|
52
|
-
# Consumers of this library that rescue and handle Faraday::
|
51
|
+
# Inherit from Faraday::ResourceNotFound for backwards-compatibility
|
52
|
+
# Consumers of this library that rescue and handle Faraday::ResourceNotFound
|
53
53
|
# can continue to do so.
|
54
|
-
NotFoundError = Class.new(Faraday::
|
54
|
+
NotFoundError = Class.new(Faraday::ResourceNotFound)
|
55
55
|
|
56
|
-
# Inherit from Faraday::
|
57
|
-
# Consumers of this library that rescue and handle Faraday::
|
56
|
+
# Inherit from Faraday::ClientError for backwards-compatibility
|
57
|
+
# Consumers of this library that rescue and handle Faraday::ClientError
|
58
58
|
# can continue to do so.
|
59
|
-
ResponseError = Class.new(Faraday::
|
59
|
+
ResponseError = Class.new(Faraday::ClientError)
|
60
60
|
MatchesMultipleError= Class.new(ResponseError)
|
61
61
|
EntityTooLargeError = Class.new(ResponseError)
|
62
62
|
|
@@ -72,9 +72,9 @@ module Restforce
|
|
72
72
|
# Internal: Faraday Connection options
|
73
73
|
def connection_options
|
74
74
|
{ request: {
|
75
|
-
|
76
|
-
|
77
|
-
},
|
75
|
+
timeout: options[:timeout],
|
76
|
+
open_timeout: options[:timeout]
|
77
|
+
},
|
78
78
|
proxy: options[:proxy_uri],
|
79
79
|
ssl: options[:ssl] }
|
80
80
|
end
|
@@ -63,7 +63,10 @@ module Restforce
|
|
63
63
|
|
64
64
|
# Internal: The parsed error response.
|
65
65
|
def error_message(response)
|
66
|
-
|
66
|
+
return response.status.to_s unless response.body
|
67
|
+
|
68
|
+
"#{response.body['error']}: #{response.body['error_description']} " \
|
69
|
+
"(#{response.status})"
|
67
70
|
end
|
68
71
|
|
69
72
|
# Featured detect form encoding.
|
data/lib/restforce/version.rb
CHANGED
data/restforce.gemspec
CHANGED
@@ -30,12 +30,12 @@ Gem::Specification.new do |gem|
|
|
30
30
|
gem.add_dependency 'json', '>= 1.7.5'
|
31
31
|
gem.add_dependency 'jwt', ['>= 1.5.6']
|
32
32
|
|
33
|
-
gem.add_dependency 'hashie',
|
33
|
+
gem.add_dependency 'hashie', '>= 1.2.0', '< 5.0'
|
34
34
|
|
35
35
|
gem.add_development_dependency 'faye' unless RUBY_PLATFORM == 'java'
|
36
36
|
gem.add_development_dependency 'rspec', '~> 2.14.0'
|
37
37
|
gem.add_development_dependency 'rspec_junit_formatter', '~> 0.4.1'
|
38
|
-
gem.add_development_dependency 'rubocop', '~> 0.
|
38
|
+
gem.add_development_dependency 'rubocop', '~> 0.77.0'
|
39
39
|
gem.add_development_dependency 'simplecov', '~> 0.17.1'
|
40
40
|
gem.add_development_dependency 'webmock', '~> 3.7.6'
|
41
41
|
end
|
@@ -125,7 +125,7 @@ shared_examples_for Restforce::AbstractClient do
|
|
125
125
|
|
126
126
|
it {
|
127
127
|
should raise_error(
|
128
|
-
Faraday::
|
128
|
+
Faraday::ResourceNotFound,
|
129
129
|
"#{error.first['errorCode']}: #{error.first['message']}"
|
130
130
|
)
|
131
131
|
}
|
@@ -239,7 +239,7 @@ shared_examples_for Restforce::AbstractClient do
|
|
239
239
|
status: 404
|
240
240
|
|
241
241
|
subject { lambda { destroy! } }
|
242
|
-
it { should raise_error Faraday::
|
242
|
+
it { should raise_error Faraday::ResourceNotFound }
|
243
243
|
end
|
244
244
|
|
245
245
|
context 'with success' do
|
@@ -274,7 +274,7 @@ describe Restforce::Concerns::API do
|
|
274
274
|
end
|
275
275
|
|
276
276
|
it 'rescues exceptions' do
|
277
|
-
[Faraday::
|
277
|
+
[Faraday::ClientError].each do |exception_klass|
|
278
278
|
client.should_receive(:"#{method}!").
|
279
279
|
with(*args).
|
280
280
|
and_raise(exception_klass.new(nil))
|
@@ -89,4 +89,25 @@ describe Restforce::Middleware::Authentication do
|
|
89
89
|
connection.ssl[:version].should eq(:TLSv1_2)
|
90
90
|
end
|
91
91
|
end
|
92
|
+
|
93
|
+
describe '.error_message' do
|
94
|
+
context 'when response.body is present' do
|
95
|
+
let(:response) {
|
96
|
+
Faraday::Response.new(
|
97
|
+
body: { 'error' => 'error', 'error_description' => 'description' },
|
98
|
+
status: 401
|
99
|
+
)
|
100
|
+
}
|
101
|
+
|
102
|
+
subject { middleware.error_message(response) }
|
103
|
+
it { should eq "error: description (401)" }
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'when response.body is nil' do
|
107
|
+
let(:response) { Faraday::Response.new(status: 401) }
|
108
|
+
|
109
|
+
subject { middleware.error_message(response) }
|
110
|
+
it { should eq "401" }
|
111
|
+
end
|
112
|
+
end
|
92
113
|
end
|
@@ -18,8 +18,8 @@ describe Restforce::Middleware::RaiseError do
|
|
18
18
|
'INVALID_FIELD: error_message'
|
19
19
|
end
|
20
20
|
|
21
|
-
it 'raises an error that inherits from Faraday::
|
22
|
-
expect { on_complete }.to raise_error Faraday::
|
21
|
+
it 'raises an error that inherits from Faraday::ResourceNotFound' do
|
22
|
+
expect { on_complete }.to raise_error Faraday::ResourceNotFound
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -31,8 +31,8 @@ describe Restforce::Middleware::RaiseError do
|
|
31
31
|
/300: The external ID provided/
|
32
32
|
end
|
33
33
|
|
34
|
-
it 'raises an error that inherits from Faraday::
|
35
|
-
expect { on_complete }.to raise_error Faraday::
|
34
|
+
it 'raises an error that inherits from Faraday::ClientError' do
|
35
|
+
expect { on_complete }.to raise_error Faraday::ClientError
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -44,8 +44,8 @@ describe Restforce::Middleware::RaiseError do
|
|
44
44
|
'INVALID_FIELD: error_message'
|
45
45
|
end
|
46
46
|
|
47
|
-
it 'raises an error that inherits from Faraday::
|
48
|
-
expect { on_complete }.to raise_error Faraday::
|
47
|
+
it 'raises an error that inherits from Faraday::ClientError' do
|
48
|
+
expect { on_complete }.to raise_error Faraday::ClientError
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -66,8 +66,8 @@ describe Restforce::Middleware::RaiseError do
|
|
66
66
|
'413: Request Entity Too Large'
|
67
67
|
end
|
68
68
|
|
69
|
-
it 'raises an error that inherits from Faraday::
|
70
|
-
expect { on_complete }.to raise_error Faraday::
|
69
|
+
it 'raises an error that inherits from Faraday::ClientError' do
|
70
|
+
expect { on_complete }.to raise_error Faraday::ClientError
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -80,8 +80,8 @@ describe Restforce::Middleware::RaiseError do
|
|
80
80
|
"(error code missing): #{body}"
|
81
81
|
end
|
82
82
|
|
83
|
-
it 'raises an error that inherits from Faraday::
|
84
|
-
expect { on_complete }.to raise_error Faraday::
|
83
|
+
it 'raises an error that inherits from Faraday::ClientError' do
|
84
|
+
expect { on_complete }.to raise_error Faraday::ClientError,
|
85
85
|
"(error code missing): #{body}"
|
86
86
|
end
|
87
87
|
end
|
data/spec/unit/sobject_spec.rb
CHANGED
@@ -45,13 +45,10 @@ describe Restforce::SObject do
|
|
45
45
|
destroy: :destroy,
|
46
46
|
destroy!: :destroy! }.each do |method, receiver|
|
47
47
|
describe ".#{method}" do
|
48
|
-
subject(:send_method) { sobject.send(method) }
|
48
|
+
subject(:send_method) { lambda { sobject.send(method) } }
|
49
49
|
|
50
50
|
context 'when an Id was not queried' do
|
51
|
-
it
|
52
|
-
expect { send_method }.to raise_error ArgumentError,
|
53
|
-
/need to query the Id for the record/
|
54
|
-
end
|
51
|
+
it { should raise_error ArgumentError, /need to query the Id for the record/ }
|
55
52
|
end
|
56
53
|
|
57
54
|
context 'when an Id is present' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restforce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric J. Holmes
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-12-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -88,7 +88,7 @@ dependencies:
|
|
88
88
|
version: 1.2.0
|
89
89
|
- - "<"
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: '
|
91
|
+
version: '5.0'
|
92
92
|
type: :runtime
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: 1.2.0
|
99
99
|
- - "<"
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: '
|
101
|
+
version: '5.0'
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: faye
|
104
104
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,14 +147,14 @@ dependencies:
|
|
147
147
|
requirements:
|
148
148
|
- - "~>"
|
149
149
|
- !ruby/object:Gem::Version
|
150
|
-
version: 0.
|
150
|
+
version: 0.77.0
|
151
151
|
type: :development
|
152
152
|
prerelease: false
|
153
153
|
version_requirements: !ruby/object:Gem::Requirement
|
154
154
|
requirements:
|
155
155
|
- - "~>"
|
156
156
|
- !ruby/object:Gem::Version
|
157
|
-
version: 0.
|
157
|
+
version: 0.77.0
|
158
158
|
- !ruby/object:Gem::Dependency
|
159
159
|
name: simplecov
|
160
160
|
requirement: !ruby/object:Gem::Requirement
|