restforce 5.0.5 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +9 -9
- data/.github/dependabot.yml +19 -0
- data/.rubocop.yml +2 -2
- data/CHANGELOG.md +23 -0
- data/Gemfile +10 -6
- data/README.md +53 -4
- data/lib/restforce/abstract_client.rb +1 -0
- data/lib/restforce/collection.rb +15 -1
- data/lib/restforce/concerns/api.rb +1 -1
- data/lib/restforce/concerns/base.rb +2 -2
- data/lib/restforce/concerns/composite_api.rb +104 -0
- data/lib/restforce/concerns/picklists.rb +1 -1
- data/lib/restforce/error_code.rb +27 -9
- data/lib/restforce/middleware/logger.rb +5 -5
- data/lib/restforce/version.rb +1 -1
- data/lib/restforce.rb +2 -0
- data/restforce.gemspec +2 -12
- data/spec/integration/abstract_client_spec.rb +25 -28
- data/spec/integration/data/client_spec.rb +6 -2
- data/spec/spec_helper.rb +10 -0
- data/spec/support/client_integration.rb +7 -7
- data/spec/support/concerns.rb +1 -1
- data/spec/support/middleware.rb +1 -2
- data/spec/unit/collection_spec.rb +4 -4
- data/spec/unit/concerns/api_spec.rb +11 -11
- data/spec/unit/concerns/authentication_spec.rb +6 -6
- data/spec/unit/concerns/composite_api_spec.rb +143 -0
- data/spec/unit/concerns/streaming_spec.rb +3 -3
- data/spec/unit/config_spec.rb +1 -1
- data/spec/unit/middleware/authentication/jwt_bearer_spec.rb +4 -4
- data/spec/unit/middleware/authentication/password_spec.rb +2 -2
- data/spec/unit/middleware/authentication/token_spec.rb +2 -2
- data/spec/unit/middleware/gzip_spec.rb +2 -2
- data/spec/unit/middleware/raise_error_spec.rb +20 -10
- metadata +12 -92
@@ -129,18 +129,15 @@ shared_examples_for Restforce::AbstractClient do
|
|
129
129
|
JSON.parse(fixture('sobject/delete_error_response'))
|
130
130
|
end
|
131
131
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
end
|
132
|
+
it "raises Faraday::ResourceNotFound" do
|
133
|
+
expect { client.update!('Account', Id: '001D000000INjVe', Name: 'Foobar') }.
|
134
|
+
to raise_error do |exception|
|
135
|
+
expect(exception).to be_a(Faraday::ResourceNotFound)
|
137
136
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
)
|
143
|
-
}
|
137
|
+
expect(exception.message).
|
138
|
+
to start_with("#{error.first['errorCode']}: #{error.first['message']}")
|
139
|
+
end
|
140
|
+
end
|
144
141
|
end
|
145
142
|
end
|
146
143
|
|
@@ -158,7 +155,7 @@ shared_examples_for Restforce::AbstractClient do
|
|
158
155
|
fixture: 'sobject/delete_error_response'
|
159
156
|
|
160
157
|
subject { client.update('Account', Id: '001D000000INjVe', Name: 'Foobar') }
|
161
|
-
it { should
|
158
|
+
it { should be false }
|
162
159
|
end
|
163
160
|
|
164
161
|
context 'with success' do
|
@@ -172,7 +169,7 @@ shared_examples_for Restforce::AbstractClient do
|
|
172
169
|
client.update('Account', key => '001D000000INjVe', :Name => 'Foobar')
|
173
170
|
end
|
174
171
|
|
175
|
-
it { should
|
172
|
+
it { should be true }
|
176
173
|
end
|
177
174
|
end
|
178
175
|
end
|
@@ -191,7 +188,7 @@ shared_examples_for Restforce::AbstractClient do
|
|
191
188
|
Name: 'Foobar')
|
192
189
|
end
|
193
190
|
|
194
|
-
it { should
|
191
|
+
it { should be true }
|
195
192
|
end
|
196
193
|
|
197
194
|
context 'with string external Id key' do
|
@@ -200,7 +197,7 @@ shared_examples_for Restforce::AbstractClient do
|
|
200
197
|
'Name' => 'Foobar')
|
201
198
|
end
|
202
199
|
|
203
|
-
it { should
|
200
|
+
it { should be true }
|
204
201
|
end
|
205
202
|
end
|
206
203
|
|
@@ -257,14 +254,14 @@ shared_examples_for Restforce::AbstractClient do
|
|
257
254
|
context 'with success' do
|
258
255
|
requests 'sobjects/Account/001D000000INjVe', method: :delete
|
259
256
|
|
260
|
-
it { should
|
257
|
+
it { should be true }
|
261
258
|
end
|
262
259
|
|
263
260
|
context 'with a space in the id' do
|
264
261
|
subject(:destroy!) { client.destroy!('Account', '001D000000 INjVe') }
|
265
262
|
requests 'sobjects/Account/001D000000%20INjVe', method: :delete
|
266
263
|
|
267
|
-
it { should
|
264
|
+
it { should be true }
|
268
265
|
end
|
269
266
|
end
|
270
267
|
|
@@ -277,13 +274,13 @@ shared_examples_for Restforce::AbstractClient do
|
|
277
274
|
method: :delete,
|
278
275
|
status: 404
|
279
276
|
|
280
|
-
it { should
|
277
|
+
it { should be false }
|
281
278
|
end
|
282
279
|
|
283
280
|
context 'with success' do
|
284
281
|
requests 'sobjects/Account/001D000000INjVe', method: :delete
|
285
282
|
|
286
|
-
it { should
|
283
|
+
it { should be true }
|
287
284
|
end
|
288
285
|
end
|
289
286
|
|
@@ -368,8 +365,8 @@ shared_examples_for Restforce::AbstractClient do
|
|
368
365
|
before do
|
369
366
|
@request = stub_login_request(
|
370
367
|
with_body: "grant_type=password&client_id=client_id" \
|
371
|
-
|
372
|
-
|
368
|
+
"&client_secret=client_secret&username=foo" \
|
369
|
+
"&password=barsecurity_token"
|
373
370
|
).to_return(status: 200, body: fixture(:auth_success_response))
|
374
371
|
end
|
375
372
|
|
@@ -420,8 +417,8 @@ shared_examples_for Restforce::AbstractClient do
|
|
420
417
|
|
421
418
|
@query_request = stub_login_request(
|
422
419
|
with_body: "grant_type=password&client_id=client_id" \
|
423
|
-
|
424
|
-
|
420
|
+
"&client_secret=client_secret&username=foo&" \
|
421
|
+
"password=barsecurity_token"
|
425
422
|
).to_return(status: 200, body: fixture(:auth_success_response))
|
426
423
|
end
|
427
424
|
|
@@ -437,15 +434,15 @@ shared_examples_for Restforce::AbstractClient do
|
|
437
434
|
@query = stub_api_request('query\?q=SELECT%20some,%20fields%20FROM%20object').
|
438
435
|
with(headers: { 'Authorization' => "OAuth #{oauth_token}" }).
|
439
436
|
to_return(status: 401,
|
440
|
-
|
441
|
-
|
437
|
+
body: fixture('expired_session_response'),
|
438
|
+
headers: { 'Content-Type' => 'application/json' }).then.
|
442
439
|
to_return(status: 200,
|
443
|
-
|
444
|
-
|
440
|
+
body: fixture('sobject/query_success_response'),
|
441
|
+
headers: { 'Content-Type' => 'application/json' })
|
445
442
|
|
446
443
|
@login = stub_login_request(
|
447
444
|
with_body: "grant_type=password&client_id=client_id&client_secret=" \
|
448
|
-
|
445
|
+
"client_secret&username=foo&password=barsecurity_token"
|
449
446
|
).to_return(status: 200, body: fixture(:auth_success_response))
|
450
447
|
end
|
451
448
|
|
@@ -98,17 +98,21 @@ shared_examples_for Restforce::Data::Client do
|
|
98
98
|
end
|
99
99
|
|
100
100
|
describe '.subscribe', event_machine: true do
|
101
|
+
let(:faye_double) { double('Faye') }
|
102
|
+
|
101
103
|
context 'when given a single pushtopic' do
|
102
104
|
it 'subscribes to the pushtopic' do
|
103
|
-
|
105
|
+
faye_double.should_receive(:subscribe).with(['/topic/PushTopic'])
|
106
|
+
client.stub faye: faye_double
|
104
107
|
client.subscribe('PushTopic')
|
105
108
|
end
|
106
109
|
end
|
107
110
|
|
108
111
|
context 'when given an array of pushtopics' do
|
109
112
|
it 'subscribes to each pushtopic' do
|
110
|
-
|
113
|
+
faye_double.should_receive(:subscribe).with(['/topic/PushTopic1',
|
111
114
|
'/topic/PushTopic2'])
|
115
|
+
client.stub faye: faye_double
|
112
116
|
client.subscribe(%w[PushTopic1 PushTopic2])
|
113
117
|
end
|
114
118
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,6 +8,8 @@ Bundler.require :default, :test
|
|
8
8
|
require 'faye' unless RUBY_PLATFORM == 'java'
|
9
9
|
|
10
10
|
require 'webmock/rspec'
|
11
|
+
require 'rspec/collection_matchers'
|
12
|
+
require 'rspec/its'
|
11
13
|
|
12
14
|
WebMock.disable_net_connect!
|
13
15
|
|
@@ -27,6 +29,14 @@ RSpec.configure do |config|
|
|
27
29
|
$stderr = original_stderr
|
28
30
|
$stdout = original_stdout
|
29
31
|
end
|
32
|
+
|
33
|
+
config.expect_with :rspec do |expectations|
|
34
|
+
expectations.syntax = %i[expect should]
|
35
|
+
end
|
36
|
+
|
37
|
+
config.mock_with :rspec do |mocks|
|
38
|
+
mocks.syntax = %i[expect should]
|
39
|
+
end
|
30
40
|
end
|
31
41
|
|
32
42
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
@@ -5,7 +5,7 @@ module ClientIntegrationExampleGroup
|
|
5
5
|
base.class_eval do
|
6
6
|
let(:oauth_token) do
|
7
7
|
'00Dx0000000BV7z!AR8AQAxo9UfVkh8AlV0Gomt9Czx9LjHnSSpwBMmbRcgKFmxOtvxjTrKW19ye6P' \
|
8
|
-
|
8
|
+
'E3Ds1eQz3z8jr3W7_VbWmEu4Q8TVGSTHxs'
|
9
9
|
end
|
10
10
|
|
11
11
|
let(:refresh_token) { 'refresh' }
|
@@ -39,13 +39,13 @@ module ClientIntegrationExampleGroup
|
|
39
39
|
end
|
40
40
|
|
41
41
|
RSpec.configure do |config|
|
42
|
+
describes = lambda do |described|
|
43
|
+
described <= Restforce::AbstractClient
|
44
|
+
end
|
45
|
+
|
42
46
|
config.include self,
|
43
|
-
|
44
|
-
|
45
|
-
described <= Restforce::AbstractClient
|
46
|
-
end,
|
47
|
-
file_path: %r{spec/integration}
|
48
|
-
}
|
47
|
+
file_path: %r{spec/integration},
|
48
|
+
describes: describes
|
49
49
|
|
50
50
|
config.before mashify: false do
|
51
51
|
base_options.merge!(mashify: false)
|
data/spec/support/concerns.rb
CHANGED
data/spec/support/middleware.rb
CHANGED
@@ -13,7 +13,7 @@ describe Restforce::Collection do
|
|
13
13
|
|
14
14
|
it { should respond_to :each }
|
15
15
|
its(:size) { should eq 1 }
|
16
|
-
its(:has_next_page?) { should
|
16
|
+
its(:has_next_page?) { should be false }
|
17
17
|
it { should have_client client }
|
18
18
|
its(:page_size) { should eq 1 }
|
19
19
|
|
@@ -56,7 +56,7 @@ describe Restforce::Collection do
|
|
56
56
|
should(be_all { |page| expect(page).to be_a Restforce::Collection })
|
57
57
|
end
|
58
58
|
|
59
|
-
its(:has_next_page?) { should
|
59
|
+
its(:has_next_page?) { should be true }
|
60
60
|
it { should(be_all { |record| expect(record).to be_a Restforce::SObject }) }
|
61
61
|
its(:next_page) { should be_a Restforce::Collection }
|
62
62
|
end
|
@@ -71,13 +71,13 @@ describe Restforce::Collection do
|
|
71
71
|
context 'with size 1' do
|
72
72
|
let(:sobject_fixture) { 'sobject/query_success_response' }
|
73
73
|
|
74
|
-
it { should
|
74
|
+
it { should be false }
|
75
75
|
end
|
76
76
|
|
77
77
|
context 'with size 0' do
|
78
78
|
let(:sobject_fixture) { 'sobject/query_empty_response' }
|
79
79
|
|
80
|
-
it { should
|
80
|
+
it { should be true }
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
@@ -11,7 +11,7 @@ describe Restforce::Concerns::API do
|
|
11
11
|
it 'returns the user info from identity url' do
|
12
12
|
identity_url = double('identity_url')
|
13
13
|
response.body.stub(:identity).and_return(identity_url)
|
14
|
-
client.should_receive(:api_get).with.and_return(response)
|
14
|
+
client.should_receive(:api_get).with(no_args).and_return(response)
|
15
15
|
|
16
16
|
identity = double('identity')
|
17
17
|
identity.stub(:body).and_return(identity)
|
@@ -268,7 +268,7 @@ describe Restforce::Concerns::API do
|
|
268
268
|
|
269
269
|
it "delegates to :#{method}!" do
|
270
270
|
client.should_receive(:"#{method}!").
|
271
|
-
with(
|
271
|
+
with(no_args).
|
272
272
|
and_return(response)
|
273
273
|
expect(result).to eq response
|
274
274
|
end
|
@@ -276,7 +276,7 @@ describe Restforce::Concerns::API do
|
|
276
276
|
it 'rescues exceptions' do
|
277
277
|
[Faraday::ClientError].each do |exception_klass|
|
278
278
|
client.should_receive(:"#{method}!").
|
279
|
-
with(
|
279
|
+
with(no_args).
|
280
280
|
and_raise(exception_klass.new(nil))
|
281
281
|
expect(result).to eq false
|
282
282
|
end
|
@@ -314,7 +314,7 @@ describe Restforce::Concerns::API do
|
|
314
314
|
it 'sends an HTTP PATCH, and returns true' do
|
315
315
|
client.should_receive(:api_patch).
|
316
316
|
with('sobjects/Whizbang/1234', StageName: "Call Scheduled")
|
317
|
-
expect(result).to
|
317
|
+
expect(result).to be true
|
318
318
|
end
|
319
319
|
end
|
320
320
|
|
@@ -324,7 +324,7 @@ describe Restforce::Concerns::API do
|
|
324
324
|
it 'sends an HTTP PATCH, and encodes the ID' do
|
325
325
|
client.should_receive(:api_patch).
|
326
326
|
with('sobjects/Whizbang/1234%2F%3Fabc', StageName: "Call Scheduled")
|
327
|
-
expect(result).to
|
327
|
+
expect(result).to be true
|
328
328
|
end
|
329
329
|
end
|
330
330
|
|
@@ -348,7 +348,7 @@ describe Restforce::Concerns::API do
|
|
348
348
|
client.should_receive(:api_patch).
|
349
349
|
with('sobjects/Whizbang/External_ID__c/1234', {}).
|
350
350
|
and_return(response)
|
351
|
-
expect(result).to
|
351
|
+
expect(result).to be true
|
352
352
|
end
|
353
353
|
|
354
354
|
context 'and the response body is a string' do
|
@@ -357,7 +357,7 @@ describe Restforce::Concerns::API do
|
|
357
357
|
client.should_receive(:api_patch).
|
358
358
|
with('sobjects/Whizbang/External_ID__c/1234', {}).
|
359
359
|
and_return(response)
|
360
|
-
expect(result).to
|
360
|
+
expect(result).to be true
|
361
361
|
end
|
362
362
|
end
|
363
363
|
end
|
@@ -431,7 +431,7 @@ describe Restforce::Concerns::API do
|
|
431
431
|
client.should_receive(:api_patch).
|
432
432
|
with('sobjects/Whizbang/External_ID__c/%E3%81%82', {}).
|
433
433
|
and_return(response)
|
434
|
-
expect(result).to
|
434
|
+
expect(result).to be true
|
435
435
|
end
|
436
436
|
end
|
437
437
|
end
|
@@ -448,7 +448,7 @@ describe Restforce::Concerns::API do
|
|
448
448
|
client.should_receive(:api_patch).
|
449
449
|
with('sobjects/Whizbang/External_ID__c/1234', {}).
|
450
450
|
and_return(response)
|
451
|
-
expect(result).to
|
451
|
+
expect(result).to be true
|
452
452
|
end
|
453
453
|
end
|
454
454
|
end
|
@@ -462,7 +462,7 @@ describe Restforce::Concerns::API do
|
|
462
462
|
it 'sends and HTTP delete, and returns true' do
|
463
463
|
client.should_receive(:api_delete).
|
464
464
|
with('sobjects/Whizbang/1234')
|
465
|
-
expect(result).to
|
465
|
+
expect(result).to be true
|
466
466
|
end
|
467
467
|
|
468
468
|
context 'when the id field contains special characters' do
|
@@ -471,7 +471,7 @@ describe Restforce::Concerns::API do
|
|
471
471
|
it 'sends an HTTP delete, and encodes the ID' do
|
472
472
|
client.should_receive(:api_delete).
|
473
473
|
with('sobjects/Whizbang/1234%2F%3Fabc')
|
474
|
-
expect(result).to
|
474
|
+
expect(result).to be true
|
475
475
|
end
|
476
476
|
end
|
477
477
|
end
|
@@ -80,11 +80,11 @@ describe Restforce::Concerns::Authentication do
|
|
80
80
|
client_secret: 'secret' }
|
81
81
|
end
|
82
82
|
|
83
|
-
it { should
|
83
|
+
it { should be_truthy }
|
84
84
|
end
|
85
85
|
|
86
86
|
context 'when username and password options are not provided' do
|
87
|
-
it { should_not
|
87
|
+
it { should_not be_truthy }
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -103,11 +103,11 @@ describe Restforce::Concerns::Authentication do
|
|
103
103
|
client_secret: 'secret' }
|
104
104
|
end
|
105
105
|
|
106
|
-
it { should
|
106
|
+
it { should be_truthy }
|
107
107
|
end
|
108
108
|
|
109
109
|
context 'when oauth options are not provided' do
|
110
|
-
it { should_not
|
110
|
+
it { should_not be true }
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -128,11 +128,11 @@ describe Restforce::Concerns::Authentication do
|
|
128
128
|
client_id: 'client' }
|
129
129
|
end
|
130
130
|
|
131
|
-
it { should
|
131
|
+
it { should be_truthy }
|
132
132
|
end
|
133
133
|
|
134
134
|
context 'when jwt options are not provided' do
|
135
|
-
it { should_not
|
135
|
+
it { should_not be true }
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Restforce::Concerns::CompositeAPI do
|
6
|
+
let(:endpoint) { 'composite' }
|
7
|
+
|
8
|
+
before do
|
9
|
+
client.should_receive(:options).and_return(api_version: 38.0)
|
10
|
+
end
|
11
|
+
|
12
|
+
shared_examples_for 'composite requests' do
|
13
|
+
it '#create' do
|
14
|
+
client.
|
15
|
+
should_receive(:api_post).
|
16
|
+
with(endpoint, { compositeRequest: [
|
17
|
+
{
|
18
|
+
method: 'POST',
|
19
|
+
url: '/services/data/v38.0/sobjects/Object',
|
20
|
+
body: { name: 'test' },
|
21
|
+
referenceId: 'create_ref'
|
22
|
+
}
|
23
|
+
], allOrNone: all_or_none, collateSubrequests: false }.to_json).
|
24
|
+
and_return(response)
|
25
|
+
|
26
|
+
client.send(method) do |subrequests|
|
27
|
+
subrequests.create('Object', 'create_ref', name: 'test')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it '#update' do
|
32
|
+
client.
|
33
|
+
should_receive(:api_post).
|
34
|
+
with(endpoint, { compositeRequest: [
|
35
|
+
{
|
36
|
+
method: 'PATCH',
|
37
|
+
url: '/services/data/v38.0/sobjects/Object/123',
|
38
|
+
body: { name: 'test' },
|
39
|
+
referenceId: 'update_ref'
|
40
|
+
}
|
41
|
+
], allOrNone: all_or_none, collateSubrequests: false }.to_json).
|
42
|
+
and_return(response)
|
43
|
+
|
44
|
+
client.send(method) do |subrequests|
|
45
|
+
subrequests.update('Object', 'update_ref', id: '123', name: 'test')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it '#destroy' do
|
50
|
+
client.
|
51
|
+
should_receive(:api_post).
|
52
|
+
with(endpoint, { compositeRequest: [
|
53
|
+
{
|
54
|
+
method: 'DELETE',
|
55
|
+
url: '/services/data/v38.0/sobjects/Object/123',
|
56
|
+
referenceId: 'destroy_ref'
|
57
|
+
}
|
58
|
+
], allOrNone: all_or_none, collateSubrequests: false }.to_json).
|
59
|
+
and_return(response)
|
60
|
+
|
61
|
+
client.send(method) do |subrequests|
|
62
|
+
subrequests.destroy('Object', 'destroy_ref', '123')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it '#upsert' do
|
67
|
+
client.
|
68
|
+
should_receive(:api_post).
|
69
|
+
with(endpoint, { compositeRequest: [
|
70
|
+
{
|
71
|
+
method: 'PATCH',
|
72
|
+
url: '/services/data/v38.0/sobjects/Object/extIdField__c/456',
|
73
|
+
body: { name: 'test' },
|
74
|
+
referenceId: 'upsert_ref'
|
75
|
+
}
|
76
|
+
], allOrNone: all_or_none, collateSubrequests: false }.to_json).
|
77
|
+
and_return(response)
|
78
|
+
|
79
|
+
client.send(method) do |subrequests|
|
80
|
+
subrequests.upsert('Object', 'upsert_ref', 'extIdField__c',
|
81
|
+
extIdField__c: '456', name: 'test')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'multiple subrequests' do
|
86
|
+
client.
|
87
|
+
should_receive(:api_post).
|
88
|
+
with(endpoint, { compositeRequest: [
|
89
|
+
{
|
90
|
+
method: 'POST',
|
91
|
+
url: '/services/data/v38.0/sobjects/Object',
|
92
|
+
body: { name: 'test' },
|
93
|
+
referenceId: 'create_ref'
|
94
|
+
},
|
95
|
+
{
|
96
|
+
method: 'PATCH',
|
97
|
+
url: '/services/data/v38.0/sobjects/Object/123',
|
98
|
+
body: { name: 'test' },
|
99
|
+
referenceId: 'update_ref'
|
100
|
+
},
|
101
|
+
{
|
102
|
+
method: 'DELETE',
|
103
|
+
url: '/services/data/v38.0/sobjects/Object/123',
|
104
|
+
referenceId: 'destroy_ref'
|
105
|
+
}
|
106
|
+
], allOrNone: all_or_none, collateSubrequests: false }.to_json).
|
107
|
+
and_return(response)
|
108
|
+
|
109
|
+
client.send(method) do |subrequests|
|
110
|
+
subrequests.create('Object', 'create_ref', name: 'test')
|
111
|
+
subrequests.update('Object', 'update_ref', id: '123', name: 'test')
|
112
|
+
subrequests.destroy('Object', 'destroy_ref', '123')
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'fails if more than 25 requests' do
|
117
|
+
expect do
|
118
|
+
client.send(method) do |subrequests|
|
119
|
+
26.times do |i|
|
120
|
+
subrequests.upsert('Object', "upsert_ref_#{i}", 'extIdField__c',
|
121
|
+
extIdField__c: '456', name: 'test')
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end.to raise_error(ArgumentError)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe '#composite' do
|
129
|
+
let(:method) { :composite }
|
130
|
+
let(:all_or_none) { false }
|
131
|
+
let(:response) { double('Faraday::Response', body: { 'CompositeResponse' => [] }) }
|
132
|
+
it_behaves_like 'composite requests'
|
133
|
+
end
|
134
|
+
|
135
|
+
describe '#composite!' do
|
136
|
+
let(:method) { :composite! }
|
137
|
+
let(:all_or_none) { true }
|
138
|
+
let(:response) do
|
139
|
+
double('Faraday::Response', body: { 'CompositeResponse' => [] })
|
140
|
+
end
|
141
|
+
it_behaves_like 'composite requests'
|
142
|
+
end
|
143
|
+
end
|
@@ -13,10 +13,10 @@ describe Restforce::Concerns::Streaming, event_machine: true do
|
|
13
13
|
it 'subscribes to the topics with faye' do
|
14
14
|
faye_double.
|
15
15
|
should_receive(:subscribe).
|
16
|
-
with(channels
|
16
|
+
with(channels)
|
17
17
|
client.stub faye: faye_double
|
18
18
|
|
19
|
-
client.subscription(channels
|
19
|
+
client.subscription(channels)
|
20
20
|
end
|
21
21
|
|
22
22
|
context "replay_handlers" do
|
@@ -110,7 +110,7 @@ describe Restforce::Concerns::Streaming, event_machine: true do
|
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
|
-
describe
|
113
|
+
describe "ReplayExtension" do
|
114
114
|
let(:handlers) { {} }
|
115
115
|
let(:extension) { Restforce::Concerns::Streaming::ReplayExtension.new(handlers) }
|
116
116
|
|
data/spec/unit/config_spec.rb
CHANGED
@@ -17,14 +17,14 @@ describe Restforce::Middleware::Authentication::JWTBearer do
|
|
17
17
|
let(:success_request) do
|
18
18
|
stub_login_request(
|
19
19
|
body: "grant_type=grant_type—urn:ietf:params:oauth:grant-type:jwt-bearer&" \
|
20
|
-
|
20
|
+
"assertion=abc1234567890"
|
21
21
|
).to_return(status: 200, body: fixture(:auth_success_response))
|
22
22
|
end
|
23
23
|
|
24
24
|
let(:fail_request) do
|
25
25
|
stub_login_request(
|
26
26
|
body: "grant_type=grant_type—urn:ietf:params:oauth:grant-type:jwt-bearer&" \
|
27
|
-
|
27
|
+
"assertion=abc1234567890"
|
28
28
|
).to_return(status: 400, body: fixture(:refresh_error_response))
|
29
29
|
end
|
30
30
|
end
|
@@ -47,14 +47,14 @@ describe Restforce::Middleware::Authentication::JWTBearer do
|
|
47
47
|
let(:success_request) do
|
48
48
|
stub_login_request(
|
49
49
|
body: "grant_type=grant_type—urn:ietf:params:oauth:grant-type:jwt-bearer&" \
|
50
|
-
|
50
|
+
"assertion=abc1234567890"
|
51
51
|
).to_return(status: 200, body: fixture(:auth_success_response))
|
52
52
|
end
|
53
53
|
|
54
54
|
let(:fail_request) do
|
55
55
|
stub_login_request(
|
56
56
|
body: "grant_type=grant_type—urn:ietf:params:oauth:grant-type:jwt-bearer&" \
|
57
|
-
|
57
|
+
"assertion=abc1234567890"
|
58
58
|
).to_return(status: 400, body: fixture(:refresh_error_response))
|
59
59
|
end
|
60
60
|
end
|
@@ -17,14 +17,14 @@ describe Restforce::Middleware::Authentication::Password do
|
|
17
17
|
let(:success_request) do
|
18
18
|
stub_login_request(
|
19
19
|
body: "grant_type=password&client_id=client_id&client_secret=client_secret" \
|
20
|
-
|
20
|
+
"&username=foo&password=barsecurity_token"
|
21
21
|
).to_return(status: 200, body: fixture(:auth_success_response))
|
22
22
|
end
|
23
23
|
|
24
24
|
let(:fail_request) do
|
25
25
|
stub_login_request(
|
26
26
|
body: "grant_type=password&client_id=client_id&client_secret=client_secret" \
|
27
|
-
|
27
|
+
"&username=foo&password=barsecurity_token"
|
28
28
|
).to_return(status: 400, body: fixture(:auth_error_response))
|
29
29
|
end
|
30
30
|
end
|
@@ -15,14 +15,14 @@ describe Restforce::Middleware::Authentication::Token do
|
|
15
15
|
let(:success_request) do
|
16
16
|
stub_login_request(
|
17
17
|
body: "grant_type=refresh_token&refresh_token=refresh_token&" \
|
18
|
-
|
18
|
+
"client_id=client_id&client_secret=client_secret"
|
19
19
|
).to_return(status: 200, body: fixture(:auth_success_response))
|
20
20
|
end
|
21
21
|
|
22
22
|
let(:fail_request) do
|
23
23
|
stub_login_request(
|
24
24
|
body: "grant_type=refresh_token&refresh_token=refresh_token&" \
|
25
|
-
|
25
|
+
"client_id=client_id&client_secret=client_secret"
|
26
26
|
).to_return(status: 400, body: fixture(:refresh_error_response))
|
27
27
|
end
|
28
28
|
end
|
@@ -58,11 +58,11 @@ describe Restforce::Middleware::Gzip do
|
|
58
58
|
env[:response_headers]['Content-Encoding'] = 'gzip'
|
59
59
|
end
|
60
60
|
|
61
|
-
it { should
|
61
|
+
it { should be true }
|
62
62
|
end
|
63
63
|
|
64
64
|
context 'when not gzipped' do
|
65
|
-
it { should
|
65
|
+
it { should be false }
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|