restforce 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of restforce might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/restforce/concerns/connection.rb +2 -2
- data/lib/restforce/middleware/caching.rb +1 -1
- data/lib/restforce/middleware/raise_error.rb +9 -2
- data/lib/restforce/version.rb +1 -1
- data/spec/integration/abstract_client_spec.rb +22 -10
- data/spec/support/mock_cache.rb +8 -0
- data/spec/unit/middleware/raise_error_spec.rb +11 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 307702db9af787319aab32acd6a4d2d6969be792
|
4
|
+
data.tar.gz: b62523a1931297c0598f7c52043b5e4dbf0afe0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8a11572c3132c5f223ddc6d3159908957c4a250b4fb7805a4156c7f258e5789b30a58c6ce93a07f23c86d8b1068741a041326c8d5c8dcaad7f7c7bee4c7ba35
|
7
|
+
data.tar.gz: 17d37b8a1b9546fd3b90e211c73baa7ae6bb3cd7c429a22dd8f062c3e90a59bbfe5fe20aa36e86ed70ba8d10895c0b01f952edb099ebe52da69d2de6fa11f53e
|
data/README.md
CHANGED
@@ -483,6 +483,8 @@ created/updated.
|
|
483
483
|
|
484
484
|
_See also: [Force.com Streaming API docs](http://www.salesforce.com/us/developer/docs/api_streaming/index.htm)_
|
485
485
|
|
486
|
+
*Note:* Restforce's streaming implementation is known to be compatible with version `0.8.9` of the faye gem.
|
487
|
+
|
486
488
|
* * *
|
487
489
|
|
488
490
|
### Caching
|
@@ -601,4 +603,4 @@ Using the scripts in `./script` instead of `bundle exec rspec`, `bundle console`
|
|
601
603
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
602
604
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
603
605
|
4. Push to the branch (`git push origin my-new-feature`)
|
604
|
-
5. Create new Pull Request
|
606
|
+
5. Create new Pull Request
|
@@ -38,14 +38,14 @@ module Restforce
|
|
38
38
|
builder.use Restforce::Middleware::Authorization, self, options
|
39
39
|
# Ensures the instance url is set.
|
40
40
|
builder.use Restforce::Middleware::InstanceURL, self, options
|
41
|
-
# Parses returned JSON response into a hash.
|
42
|
-
builder.response :json, content_type: /\bjson$/
|
43
41
|
# Caches GET requests.
|
44
42
|
builder.use Restforce::Middleware::Caching, cache, options if cache
|
45
43
|
# Follows 30x redirects.
|
46
44
|
builder.use FaradayMiddleware::FollowRedirects
|
47
45
|
# Raises errors for 40x responses.
|
48
46
|
builder.use Restforce::Middleware::RaiseError
|
47
|
+
# Parses returned JSON response into a hash.
|
48
|
+
builder.response :json, content_type: /\bjson$/
|
49
49
|
# Log request/responses
|
50
50
|
builder.use Restforce::Middleware::Logger,
|
51
51
|
Restforce.configuration.logger,
|
@@ -16,11 +16,18 @@ module Restforce
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def message
|
19
|
-
"#{body
|
19
|
+
"#{body['errorCode']}: #{body['message']}"
|
20
20
|
end
|
21
21
|
|
22
22
|
def body
|
23
|
-
|
23
|
+
@body = (@env[:body].respond_to?(:first) ? @env[:body].first : @env[:body])
|
24
|
+
|
25
|
+
case @body
|
26
|
+
when Hash
|
27
|
+
@body
|
28
|
+
else
|
29
|
+
{ 'errorCode' => '(error code missing)', 'message' => @body }
|
30
|
+
end
|
24
31
|
end
|
25
32
|
|
26
33
|
def response_values
|
data/lib/restforce/version.rb
CHANGED
@@ -100,13 +100,22 @@ shared_examples_for Restforce::AbstractClient do
|
|
100
100
|
status: 404,
|
101
101
|
fixture: 'sobject/delete_error_response'
|
102
102
|
|
103
|
+
let(:error) do
|
104
|
+
JSON.parse(fixture('sobject/delete_error_response'))
|
105
|
+
end
|
106
|
+
|
103
107
|
subject do
|
104
108
|
lambda do
|
105
109
|
client.update!('Account', Id: '001D000000INjVe', Name: 'Foobar')
|
106
110
|
end
|
107
111
|
end
|
108
112
|
|
109
|
-
it {
|
113
|
+
it {
|
114
|
+
should raise_error(
|
115
|
+
Faraday::Error::ResourceNotFound,
|
116
|
+
"#{error.first['errorCode']}: #{error.first['message']}"
|
117
|
+
)
|
118
|
+
}
|
110
119
|
end
|
111
120
|
end
|
112
121
|
|
@@ -317,17 +326,20 @@ shared_examples_for Restforce::AbstractClient do
|
|
317
326
|
end
|
318
327
|
|
319
328
|
describe '.without_caching' do
|
320
|
-
|
321
|
-
fixture: 'sobject/query_success_response'
|
329
|
+
let(:cache) { MockCache.new }
|
322
330
|
|
323
|
-
before do
|
324
|
-
|
325
|
-
|
331
|
+
it 'deletes the cached value before querying the API' do
|
332
|
+
stub = stub_api_request(
|
333
|
+
'query\?q=SELECT%20some,%20fields%20FROM%20object',
|
334
|
+
fixture: 'sobject/query_success_response'
|
335
|
+
)
|
336
|
+
client.query('SELECT some, fields FROM object')
|
337
|
+
|
338
|
+
expect(cache).to receive(:delete).and_call_original.ordered
|
339
|
+
expect(cache).to receive(:read).and_call_original.ordered
|
340
|
+
client.without_caching { client.query('SELECT some, fields FROM object') }
|
341
|
+
expect(stub).to have_been_requested.twice
|
326
342
|
end
|
327
|
-
|
328
|
-
let(:cache) { MockCache.new }
|
329
|
-
subject { client.without_caching { client.query('SELECT some, fields FROM object') } }
|
330
|
-
it { should be_an Enumerable }
|
331
343
|
end
|
332
344
|
|
333
345
|
describe 'authentication retries' do
|
data/spec/support/mock_cache.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Restforce::Middleware::RaiseError do
|
4
|
-
let(:body) { fixture('sobject/query_error_response') }
|
4
|
+
let(:body) { JSON.parse(fixture('sobject/query_error_response')) }
|
5
5
|
let(:env) { { status: status, body: body } }
|
6
6
|
let(:middleware) { described_class.new app }
|
7
7
|
|
@@ -37,12 +37,21 @@ describe Restforce::Middleware::RaiseError do
|
|
37
37
|
|
38
38
|
context 'when the status code is 413' do
|
39
39
|
let(:status) { 413 }
|
40
|
-
let(:body) { '' } # Zero length response
|
41
40
|
|
42
41
|
it "raises an error" do
|
43
42
|
expect { on_complete }.to raise_error Faraday::Error::ClientError,
|
44
43
|
'HTTP 413 - Request Entity Too Large'
|
45
44
|
end
|
46
45
|
end
|
46
|
+
|
47
|
+
context 'when status is 400+ and body is a string' do
|
48
|
+
let(:body) { 'An error occured' }
|
49
|
+
let(:status) { 404 }
|
50
|
+
|
51
|
+
it 'raises an error with a non-existing error code' do
|
52
|
+
expect { on_complete }.to raise_error Faraday::Error::ClientError,
|
53
|
+
"(error code missing): #{body}"
|
54
|
+
end
|
55
|
+
end
|
47
56
|
end
|
48
57
|
end
|
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: 2.1.
|
4
|
+
version: 2.1.2
|
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: 2015-
|
12
|
+
date: 2015-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|