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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1eb25f3f88951d1770c5850c41a9d673d3b0406a76d0c35e54288d52ee5dc00
4
- data.tar.gz: 51af3a7a4a1e701a4f5e8a79c21452ca5417581aa889188e7f5b5e010fb8f39a
3
+ metadata.gz: c4f7647ad705f0f4eac359a3b1e792ab4603e9ae4d177570e9369734f7ff3356
4
+ data.tar.gz: 7fc076cb9239ebd513926e068d5d1e4ebec01cbb5245e919fd165ea5bf7b841c
5
5
  SHA512:
6
- metadata.gz: eabc94739d7bbdb2e88fcf3b2ff4bfb3c0b4272f74f50d6fef3f549ca559cd52ab212b5fbd6988da0237257aef7d092b4f654e275a797beb28947b268263f07d
7
- data.tar.gz: 56ac8e739182f941a45cffe4c8b28364d8b99243128c8c7864820e15e752785af3938c8f99377e3428dcc9a61ac98a72703850675455cc88effe5b68bdca454b
6
+ metadata.gz: ad1cfc119e9d3a64d5491c667254647a1e79298bebb7c036dee95f87b2a6823f0ed5fbb862dc29c6d25166399042767ecae5520498726fa4025b99b439bcd9f1
7
+ data.tar.gz: f8e0ab3e2cc1e74e4a1d8d50da2ca8b5bcb13436765993c8737582703248c1c47ca2c6ff02430f19390c02f1b5d95960e6d40e5510ef53e5b25d4e61add35ecc
@@ -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/AlignHash:
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/IndentFirstHashElement:
26
+ Layout/FirstHashElementIndentation:
27
27
  Exclude:
28
28
  - 'lib/restforce/concerns/connection.rb'
29
29
 
@@ -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)
@@ -48,15 +48,15 @@ module Restforce
48
48
  APIVersionError = Class.new(Error)
49
49
  BatchAPIError = Class.new(Error)
50
50
 
51
- # Inherit from Faraday::Error::ResourceNotFound for backwards-compatibility
52
- # Consumers of this library that rescue and handle Faraday::Error::ResourceNotFound
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::Error::ResourceNotFound)
54
+ NotFoundError = Class.new(Faraday::ResourceNotFound)
55
55
 
56
- # Inherit from Faraday::Error::ClientError for backwards-compatibility
57
- # Consumers of this library that rescue and handle Faraday::Error::ClientError
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::Error::ClientError)
59
+ ResponseError = Class.new(Faraday::ClientError)
60
60
  MatchesMultipleError= Class.new(ResponseError)
61
61
  EntityTooLargeError = Class.new(ResponseError)
62
62
 
@@ -510,7 +510,7 @@ module Restforce
510
510
 
511
511
  # Internal: Errors that should be rescued from in non-bang methods
512
512
  def exceptions
513
- [Faraday::Error::ClientError]
513
+ [Faraday::ClientError]
514
514
  end
515
515
  end
516
516
  end
@@ -72,9 +72,9 @@ module Restforce
72
72
  # Internal: Faraday Connection options
73
73
  def connection_options
74
74
  { request: {
75
- timeout: options[:timeout],
76
- open_timeout: options[:timeout]
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
- "#{response.body['error']}: #{response.body['error_description']}"
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.
@@ -14,7 +14,7 @@ module Restforce
14
14
  end
15
15
 
16
16
  def url_prefix_set?
17
- !!(connection.url_prefix&.host)
17
+ !!connection.url_prefix&.host
18
18
  end
19
19
  end
20
20
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Restforce
4
- VERSION = '4.2.0'
4
+ VERSION = '4.2.1'
5
5
  end
@@ -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', ['>= 1.2.0', '< 4.0']
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.75.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::Error::ResourceNotFound,
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::Error::ResourceNotFound }
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::Error::ClientError].each do |exception_klass|
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::Error::ResourceNotFound' do
22
- expect { on_complete }.to raise_error Faraday::Error::ResourceNotFound
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::Error::ClientError' do
35
- expect { on_complete }.to raise_error Faraday::Error::ClientError
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::Error::ClientError' do
48
- expect { on_complete }.to raise_error Faraday::Error::ClientError
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::Error::ClientError' do
70
- expect { on_complete }.to raise_error Faraday::Error::ClientError
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::Error::ClientError' do
84
- expect { on_complete }.to raise_error Faraday::Error::ClientError,
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
@@ -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 "raises an error" do
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.0
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-10-23 00:00:00.000000000 Z
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: '4.0'
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: '4.0'
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.75.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.75.0
157
+ version: 0.77.0
158
158
  - !ruby/object:Gem::Dependency
159
159
  name: simplecov
160
160
  requirement: !ruby/object:Gem::Requirement