finapps 5.0.34 → 5.0.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yaml +1 -7
- data/.rubocop_todo.yml +3 -94
- data/README.md +1 -0
- data/RELEASES.md +11 -0
- data/lib/finapps/rest/client.rb +6 -5
- data/lib/finapps/rest/orders.rb +26 -15
- data/lib/finapps/rest/sessions.rb +10 -8
- data/lib/finapps/utils/query_builder.rb +13 -4
- data/lib/finapps/version.rb +1 -1
- data/spec/rest/alert_definitions_spec.rb +2 -6
- data/spec/rest/client_spec.rb +32 -40
- data/spec/rest/consumers_spec.rb +221 -220
- data/spec/rest/documents_orders_notifications_spec.rb +1 -1
- data/spec/rest/documents_orders_spec.rb +1 -1
- data/spec/rest/operators_password_resets_spec.rb +49 -56
- data/spec/rest/operators_spec.rb +167 -178
- data/spec/rest/order_notifications_spec.rb +1 -1
- data/spec/rest/order_refreshes_spec.rb +2 -5
- data/spec/rest/order_reports_spec.rb +14 -14
- data/spec/rest/order_statuses_spec.rb +10 -10
- data/spec/rest/order_tokens_spec.rb +33 -32
- data/spec/rest/orders_spec.rb +78 -64
- data/spec/rest/password_resets_spec.rb +28 -28
- data/spec/rest/plaid/plaid_consumer_institutions_spec.rb +1 -1
- data/spec/rest/portfolios_alerts_spec.rb +3 -3
- data/spec/rest/portfolios_consumers_spec.rb +2 -2
- data/spec/rest/portfolios_spec.rb +6 -18
- data/spec/rest/products_spec.rb +16 -15
- data/spec/rest/sessions_spec.rb +61 -60
- data/spec/rest/signed_documents_downloads_spec.rb +8 -4
- data/spec/rest/verix/verix_documents_spec.rb +2 -2
- data/spec/rest/version_spec.rb +4 -4
- metadata +3 -3
data/spec/rest/consumers_spec.rb
CHANGED
@@ -1,308 +1,309 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'spec_helpers/client'
|
4
|
-
RSpec.describe FinApps::REST::Consumers
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
missing_public_id = ': public_id'
|
10
|
-
|
11
|
-
describe '#create' do
|
12
|
-
let(:results) { create[0] }
|
13
|
-
let(:error_messages) { create[1] }
|
14
|
-
|
15
|
-
context 'when missing params' do
|
16
|
-
it do
|
17
|
-
expect { subject.create(nil) }.to raise_error(
|
18
|
-
FinAppsCore::MissingArgumentsError
|
19
|
-
)
|
20
|
-
end
|
21
|
-
end
|
4
|
+
RSpec.describe FinApps::REST::Consumers do
|
5
|
+
context 'when initialized with valid FinApps::Client object' do
|
6
|
+
include SpecHelpers::Client
|
7
|
+
subject(:users) { described_class.new(client) }
|
22
8
|
|
23
|
-
|
24
|
-
let(:create) { subject.create(email: 'email', password: 'password') }
|
9
|
+
missing_public_id = ': public_id'
|
25
10
|
|
26
|
-
|
27
|
-
|
11
|
+
describe '#create' do
|
12
|
+
let(:results) { create[0] }
|
13
|
+
let(:error_messages) { create[1] }
|
28
14
|
|
29
|
-
|
30
|
-
|
15
|
+
context 'when missing params' do
|
16
|
+
it do
|
17
|
+
expect { users.create(nil) }.to raise_error(
|
18
|
+
FinAppsCore::MissingArgumentsError
|
19
|
+
)
|
20
|
+
end
|
31
21
|
end
|
32
22
|
|
33
|
-
|
34
|
-
|
23
|
+
context 'with valid params' do
|
24
|
+
let(:create) { subject.create(email: 'email', password: 'password') }
|
35
25
|
|
36
|
-
|
37
|
-
|
26
|
+
it { expect { create }.not_to raise_error }
|
27
|
+
it('results is a Hash') { expect(results).to be_a(Hash) }
|
38
28
|
|
39
|
-
|
40
|
-
|
29
|
+
it('performs a post and returns the response') do
|
30
|
+
expect(results).to have_key(:public_id)
|
31
|
+
end
|
41
32
|
|
42
|
-
|
43
|
-
expect(error_messages.first.downcase).to eq('invalid request body')
|
33
|
+
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
44
34
|
end
|
45
|
-
end
|
46
|
-
end
|
47
35
|
|
48
|
-
|
49
|
-
|
50
|
-
let(:results) { list[0] }
|
51
|
-
let(:error_messages) { list[1] }
|
36
|
+
context 'with invalid params' do
|
37
|
+
let(:create) { subject.create(email: 'email') }
|
52
38
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
it { expect { list }.not_to raise_error }
|
39
|
+
it { expect { create }.not_to raise_error }
|
40
|
+
it('results is nil') { expect(results).to be_nil }
|
57
41
|
|
58
|
-
|
59
|
-
|
42
|
+
it('error messages array is populated') do
|
43
|
+
expect(error_messages.first.downcase).to eq('invalid request body')
|
44
|
+
end
|
60
45
|
end
|
61
|
-
|
62
|
-
it('returns an array of records') { expect(results[:records]).to be_a(Array) }
|
63
|
-
it('returns no error messages') { expect(error_messages).to be_empty }
|
64
46
|
end
|
65
47
|
|
66
|
-
|
67
|
-
let(:
|
48
|
+
describe '#list' do
|
49
|
+
let(:list) { subject.list(params) }
|
50
|
+
let(:results) { list[0] }
|
51
|
+
let(:error_messages) { list[1] }
|
68
52
|
|
69
|
-
|
70
|
-
|
53
|
+
context 'when missing params' do
|
54
|
+
let(:params) { nil }
|
71
55
|
|
72
|
-
|
73
|
-
let(:params) do
|
74
|
-
{
|
75
|
-
page: 3,
|
76
|
-
requested: 19
|
77
|
-
}
|
78
|
-
end
|
56
|
+
it { expect { list }.not_to raise_error }
|
79
57
|
|
80
|
-
|
81
|
-
|
58
|
+
it('performs a get and returns the response') do
|
59
|
+
expect(results).to have_key(:records)
|
60
|
+
end
|
82
61
|
|
83
|
-
|
84
|
-
expect(
|
62
|
+
it('returns an array of records') { expect(results[:records]).to be_a(Array) }
|
63
|
+
it('returns no error messages') { expect(error_messages).to be_empty }
|
85
64
|
end
|
86
65
|
|
87
|
-
|
88
|
-
|
89
|
-
end
|
66
|
+
context 'when invalid params are provided' do
|
67
|
+
let(:params) { ['invalid array'] }
|
90
68
|
|
91
|
-
|
92
|
-
list
|
93
|
-
url = "#{versioned_api_path}/consumers?page=3&requested=19"
|
94
|
-
expect(WebMock).to have_requested(:get, url)
|
69
|
+
it { expect { list }.to raise_error(FinAppsCore::InvalidArgumentsError) }
|
95
70
|
end
|
96
|
-
end
|
97
71
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
}
|
106
|
-
end
|
72
|
+
context 'when including valid params without searchTerm' do
|
73
|
+
let(:params) do
|
74
|
+
{
|
75
|
+
page: 3,
|
76
|
+
requested: 19
|
77
|
+
}
|
78
|
+
end
|
107
79
|
|
108
|
-
|
109
|
-
|
80
|
+
it { expect { list }.not_to raise_error }
|
81
|
+
it('returns an array') { expect(list).to be_a(Array) }
|
110
82
|
|
111
|
-
|
112
|
-
|
113
|
-
|
83
|
+
it('performs a get and returns the response') do
|
84
|
+
expect(results).to have_key(:records)
|
85
|
+
end
|
114
86
|
|
115
|
-
|
116
|
-
|
117
|
-
|
87
|
+
it('returns no error messages') do
|
88
|
+
expect(error_messages).to be_empty
|
89
|
+
end
|
118
90
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
'%7B%22last_name%22:%22term%22%7D%5D%7D&page=2&requested=25' \
|
125
|
-
'&sort=date_created'
|
126
|
-
expect(WebMock).to have_requested(:get, url)
|
91
|
+
it 'builds query and sends proper request' do
|
92
|
+
list
|
93
|
+
url = "#{versioned_api_path}/consumers?page=3&requested=19"
|
94
|
+
expect(WebMock).to have_requested(:get, url)
|
95
|
+
end
|
127
96
|
end
|
128
97
|
|
129
|
-
context 'when
|
98
|
+
context 'when including valid params with searchTerm' do
|
130
99
|
let(:params) do
|
131
100
|
{
|
132
101
|
page: 2,
|
133
102
|
sort: 'date_created',
|
134
103
|
requested: 25,
|
135
|
-
searchTerm: '
|
104
|
+
searchTerm: 'term'
|
136
105
|
}
|
137
106
|
end
|
138
107
|
|
139
|
-
it
|
108
|
+
it { expect { list }.not_to raise_error }
|
109
|
+
it('returns an array') { expect(list).to be_a(Array) }
|
110
|
+
|
111
|
+
it('performs a get and returns the response') do
|
112
|
+
expect(results).to have_key(:records)
|
113
|
+
end
|
114
|
+
|
115
|
+
it('returns no error messages') do
|
116
|
+
expect(error_messages).to be_empty
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'builds query and sends proper request' do
|
140
120
|
list
|
141
121
|
url = "#{versioned_api_path}/consumers?"\
|
142
|
-
'filter=%7B%22$or%22:%5B%7B%22email%22:%
|
143
|
-
'%7B%22first_name%22:%
|
144
|
-
'%7B%22last_name%22:%
|
145
|
-
'
|
146
|
-
'%7B%22first_name%22:%22terms%22%7D,%7B%22last_name%22:'\
|
147
|
-
'%22terms%22%7D%5D%7D&page=2&requested=25&sort=date_created'
|
122
|
+
'filter=%7B%22$or%22:%5B%7B%22email%22:%22term%22%7D,' \
|
123
|
+
'%7B%22first_name%22:%22term%22%7D,'\
|
124
|
+
'%7B%22last_name%22:%22term%22%7D%5D%7D&page=2&requested=25' \
|
125
|
+
'&sort=date_created'
|
148
126
|
expect(WebMock).to have_requested(:get, url)
|
149
127
|
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
128
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
129
|
+
context 'when search term contains a space' do
|
130
|
+
let(:params) do
|
131
|
+
{
|
132
|
+
page: 2,
|
133
|
+
sort: 'date_created',
|
134
|
+
requested: 25,
|
135
|
+
searchTerm: 'Two terms'
|
136
|
+
}
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'treats space as start of a new query for first and last name' do
|
140
|
+
list
|
141
|
+
url = "#{versioned_api_path}/consumers?"\
|
142
|
+
'filter=%7B%22$or%22:%5B%7B%22email%22:%22Two%20terms%22%7D,'\
|
143
|
+
'%7B%22first_name%22:%22Two%20terms%22%7D,'\
|
144
|
+
'%7B%22last_name%22:%22Two%20terms%22%7D,%7B%22first_name%22:'\
|
145
|
+
'%22Two%22%7D,%7B%22last_name%22:%22Two%22%7D,'\
|
146
|
+
'%7B%22first_name%22:%22terms%22%7D,%7B%22last_name%22:'\
|
147
|
+
'%22terms%22%7D%5D%7D&page=2&requested=25&sort=date_created'
|
148
|
+
expect(WebMock).to have_requested(:get, url)
|
149
|
+
end
|
150
|
+
end
|
161
151
|
end
|
162
152
|
end
|
163
153
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
it('performs a get and returns the response') do
|
173
|
-
expect(results).to have_key(:public_id)
|
154
|
+
describe '#show' do
|
155
|
+
context 'when missing public_id' do
|
156
|
+
it do
|
157
|
+
expect { users.show(nil) }.to raise_error(
|
158
|
+
FinAppsCore::MissingArgumentsError,
|
159
|
+
missing_public_id
|
160
|
+
)
|
161
|
+
end
|
174
162
|
end
|
175
163
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
let(:show) { subject.show(:invalid_public_id) }
|
181
|
-
let(:results) { show[0] }
|
182
|
-
let(:error_messages) { show[1] }
|
183
|
-
|
184
|
-
it { expect { show }.not_to raise_error }
|
185
|
-
it('results is nil') { expect(results).to be_nil }
|
164
|
+
context 'with valid public_id' do
|
165
|
+
let(:show) { users.show(:valid_public_id) }
|
166
|
+
let(:results) { show[0] }
|
167
|
+
let(:error_messages) { show[1] }
|
186
168
|
|
187
|
-
|
188
|
-
expect(
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
describe '#update' do
|
194
|
-
context 'when missing public_id' do
|
195
|
-
it do
|
196
|
-
expect { subject.update(nil, {}) }.to raise_error(
|
197
|
-
FinAppsCore::MissingArgumentsError,
|
198
|
-
missing_public_id
|
199
|
-
)
|
200
|
-
end
|
201
|
-
end
|
169
|
+
it { expect { show }.not_to raise_error }
|
170
|
+
it('results is a Hash') { expect(results).to be_a(Hash) }
|
202
171
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
let(:results) { update[0] }
|
207
|
-
let(:error_messages) { update[1] }
|
172
|
+
it('performs a get and returns the response') do
|
173
|
+
expect(results).to have_key(:public_id)
|
174
|
+
end
|
208
175
|
|
209
|
-
it { expect { update }.not_to raise_error }
|
210
|
-
it('results is nil') { expect(results).to be_nil }
|
211
176
|
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
212
177
|
end
|
213
178
|
|
214
|
-
context '
|
215
|
-
let(:
|
216
|
-
|
217
|
-
|
218
|
-
let(:results) { update[0] }
|
219
|
-
let(:error_messages) { update[1] }
|
179
|
+
context 'with invalid token' do
|
180
|
+
let(:show) { users.show(:invalid_public_id) }
|
181
|
+
let(:results) { show[0] }
|
182
|
+
let(:error_messages) { show[1] }
|
220
183
|
|
221
|
-
it { expect {
|
184
|
+
it { expect { show }.not_to raise_error }
|
222
185
|
it('results is nil') { expect(results).to be_nil }
|
223
186
|
|
224
187
|
it('error messages array is populated') do
|
225
|
-
expect(error_messages.first.downcase).to eq(
|
226
|
-
'invalid user id specified.'
|
227
|
-
)
|
188
|
+
expect(error_messages.first.downcase).to eq('resource not found')
|
228
189
|
end
|
229
190
|
end
|
230
191
|
end
|
231
192
|
|
232
|
-
|
233
|
-
context '
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
193
|
+
describe '#update' do
|
194
|
+
context 'when missing public_id' do
|
195
|
+
it do
|
196
|
+
expect { users.update(nil, {}) }.to raise_error(
|
197
|
+
FinAppsCore::MissingArgumentsError,
|
198
|
+
missing_public_id
|
238
199
|
)
|
239
200
|
end
|
240
|
-
|
241
|
-
let(:error_messages) { update[1] }
|
201
|
+
end
|
242
202
|
|
243
|
-
|
244
|
-
|
203
|
+
context 'when updating user details' do
|
204
|
+
context 'with valid public_id' do
|
205
|
+
let(:update) { users.update(:valid_public_id, postal_code: '33021') }
|
206
|
+
let(:results) { update[0] }
|
207
|
+
let(:error_messages) { update[1] }
|
245
208
|
|
246
|
-
|
247
|
-
expect(results).to
|
209
|
+
it { expect { update }.not_to raise_error }
|
210
|
+
it('results is nil') { expect(results).to be_nil }
|
211
|
+
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
248
212
|
end
|
249
213
|
|
250
|
-
|
251
|
-
|
214
|
+
context 'with invalid public_id' do
|
215
|
+
let(:update) do
|
216
|
+
subject.update(:invalid_public_id, postal_code: '33021')
|
217
|
+
end
|
218
|
+
let(:results) { update[0] }
|
219
|
+
let(:error_messages) { update[1] }
|
220
|
+
|
221
|
+
it { expect { update }.not_to raise_error }
|
222
|
+
it('results is nil') { expect(results).to be_nil }
|
223
|
+
|
224
|
+
it('error messages array is populated') do
|
225
|
+
expect(error_messages.first.downcase).to eq(
|
226
|
+
'invalid user id specified.'
|
227
|
+
)
|
228
|
+
end
|
252
229
|
end
|
253
|
-
|
254
|
-
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
255
230
|
end
|
256
231
|
|
257
|
-
context '
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
232
|
+
context 'when updating password' do
|
233
|
+
context 'with valid public_id' do
|
234
|
+
let(:update) do
|
235
|
+
subject.update(
|
236
|
+
:valid_public_id,
|
237
|
+
password: 'Aa123456!', password_confirm: 'Aa123456!'
|
238
|
+
)
|
239
|
+
end
|
240
|
+
let(:results) { update[0] }
|
241
|
+
let(:error_messages) { update[1] }
|
242
|
+
|
243
|
+
it { expect { update }.not_to raise_error }
|
244
|
+
it('results is a Hash') { expect(results).to be_a(Hash) }
|
245
|
+
|
246
|
+
it('the public_id is on the results') do
|
247
|
+
expect(results).to have_key(:public_id)
|
248
|
+
end
|
249
|
+
|
250
|
+
it('the new token is on the results') do
|
251
|
+
expect(results).to have_key(:token)
|
252
|
+
end
|
253
|
+
|
254
|
+
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
263
255
|
end
|
264
|
-
let(:results) { update[0] }
|
265
|
-
let(:error_messages) { update[1] }
|
266
|
-
|
267
|
-
it { expect { update }.not_to raise_error }
|
268
|
-
it('results is nil') { expect(results).to be_nil }
|
269
256
|
|
270
|
-
|
271
|
-
|
257
|
+
context 'with invalid public_id' do
|
258
|
+
let(:update) do
|
259
|
+
subject.update(
|
260
|
+
:invalid_public_id,
|
261
|
+
password: 'Aa123456!', password_confirm: 'Aa123456!'
|
262
|
+
)
|
263
|
+
end
|
264
|
+
let(:results) { update[0] }
|
265
|
+
let(:error_messages) { update[1] }
|
266
|
+
|
267
|
+
it { expect { update }.not_to raise_error }
|
268
|
+
it('results is nil') { expect(results).to be_nil }
|
269
|
+
|
270
|
+
it('error messages array is populated') do
|
271
|
+
expect(error_messages.first.downcase).to eq('resource not found')
|
272
|
+
end
|
272
273
|
end
|
273
274
|
end
|
274
|
-
end
|
275
275
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
276
|
+
describe '#destroy' do
|
277
|
+
context 'when missing public_id' do
|
278
|
+
it do
|
279
|
+
expect { users.destroy(nil) }.to raise_error(
|
280
|
+
FinAppsCore::MissingArgumentsError,
|
281
|
+
missing_public_id
|
282
|
+
)
|
283
|
+
end
|
283
284
|
end
|
284
|
-
end
|
285
285
|
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
286
|
+
context 'with valid public_id' do
|
287
|
+
let(:destroy) { users.destroy(:valid_public_id) }
|
288
|
+
let(:results) { destroy[0] }
|
289
|
+
let(:error_messages) { destroy[1] }
|
290
290
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
291
|
+
it { expect { destroy }.not_to raise_error }
|
292
|
+
it('results is nil') { expect(results).to be_nil }
|
293
|
+
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
294
|
+
end
|
295
295
|
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
296
|
+
context 'with invalid token' do
|
297
|
+
let(:destroy) { subject.destroy(:invalid_public_id) }
|
298
|
+
let(:results) { destroy[0] }
|
299
|
+
let(:error_messages) { destroy[1] }
|
300
300
|
|
301
|
-
|
302
|
-
|
301
|
+
it { expect { destroy }.not_to raise_error }
|
302
|
+
it('results is nil') { expect(results).to be_nil }
|
303
303
|
|
304
|
-
|
305
|
-
|
304
|
+
it('error messages array is populated') do
|
305
|
+
expect(error_messages.first.downcase).to eq('resource not found')
|
306
|
+
end
|
306
307
|
end
|
307
308
|
end
|
308
309
|
end
|