finapps 5.0.32 → 5.0.38
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/release-drafter.yml +49 -0
- data/.github/workflows/main.yaml +37 -0
- data/.github/workflows/release-drafter.yml +14 -0
- data/.github/workflows/verify-pr-labeled.yml +14 -0
- data/.rubocop.yml +125 -59
- data/.rubocop_todo.yml +29 -0
- data/.tmuxinator.yml +1 -0
- data/.travis.yml +3 -1
- data/README.md +1 -0
- data/RELEASES.md +20 -0
- data/finapps.gemspec +4 -4
- data/lib/finapps.rb +2 -0
- data/lib/finapps/rest/alert_definitions.rb +1 -1
- data/lib/finapps/rest/alert_occurrences.rb +1 -1
- data/lib/finapps/rest/client.rb +8 -5
- data/lib/finapps/rest/consumers.rb +5 -5
- data/lib/finapps/rest/consumers_portfolios.rb +1 -1
- data/lib/finapps/rest/documents_orders.rb +26 -25
- data/lib/finapps/rest/documents_upload_types.rb +11 -0
- data/lib/finapps/rest/documents_uploads.rb +23 -0
- data/lib/finapps/rest/operators.rb +5 -5
- data/lib/finapps/rest/operators_password_resets.rb +1 -1
- data/lib/finapps/rest/order_assignments.rb +1 -1
- data/lib/finapps/rest/order_reports.rb +1 -1
- data/lib/finapps/rest/orders.rb +33 -22
- data/lib/finapps/rest/plaid/plaid_consumer_institutions.rb +1 -1
- data/lib/finapps/rest/portfolio_reports.rb +1 -1
- data/lib/finapps/rest/portfolios.rb +1 -1
- data/lib/finapps/rest/portfolios_available_consumers.rb +1 -1
- data/lib/finapps/rest/portfolios_consumers.rb +1 -1
- data/lib/finapps/rest/sessions.rb +11 -9
- data/lib/finapps/rest/signed_documents_downloads.rb +3 -1
- data/lib/finapps/utils/query_builder.rb +13 -4
- data/lib/finapps/version.rb +1 -1
- data/spec/rest/alert_definitions_spec.rb +10 -6
- data/spec/rest/alert_occurrences_spec.rb +6 -1
- data/spec/rest/api_request.rb +1 -0
- data/spec/rest/client_spec.rb +33 -41
- data/spec/rest/consumers_portfolios_spec.rb +7 -2
- data/spec/rest/consumers_spec.rb +236 -207
- data/spec/rest/documents_orders_notifications_spec.rb +4 -2
- data/spec/rest/documents_orders_spec.rb +85 -23
- data/spec/rest/documents_upload_types_spec.rb +21 -0
- data/spec/rest/documents_uploads_spec.rb +104 -0
- data/spec/rest/esign_templates_spec.rb +2 -1
- data/spec/rest/operators_password_resets_spec.rb +50 -52
- data/spec/rest/operators_spec.rb +181 -172
- data/spec/rest/order_assignments_spec.rb +6 -1
- data/spec/rest/order_notifications_spec.rb +4 -2
- data/spec/rest/order_refreshes_spec.rb +8 -5
- data/spec/rest/order_reports_spec.rb +21 -15
- data/spec/rest/order_statuses_spec.rb +14 -10
- data/spec/rest/order_tokens_spec.rb +37 -30
- data/spec/rest/orders_spec.rb +121 -73
- data/spec/rest/password_resets_spec.rb +46 -36
- data/spec/rest/plaid/plaid_account_permissions_spec.rb +5 -4
- data/spec/rest/plaid/plaid_accounts_spec.rb +9 -4
- data/spec/rest/plaid/plaid_consumer_institutions_spec.rb +11 -11
- data/spec/rest/plaid/plaid_institution_logos_spec.rb +1 -1
- data/spec/rest/plaid/plaid_webhooks_spec.rb +3 -1
- data/spec/rest/portfolio_reports_spec.rb +7 -2
- data/spec/rest/portfolios_alerts_spec.rb +9 -4
- data/spec/rest/portfolios_available_consumers_spec.rb +7 -2
- data/spec/rest/portfolios_consumers_spec.rb +15 -4
- data/spec/rest/portfolios_spec.rb +20 -17
- data/spec/rest/products_spec.rb +17 -14
- data/spec/rest/sessions_spec.rb +63 -58
- data/spec/rest/signed_documents_downloads_spec.rb +10 -6
- data/spec/rest/tenant_app_settings_spec.rb +9 -3
- data/spec/rest/tenant_settings_spec.rb +9 -3
- data/spec/rest/verix/verix_documents_spec.rb +15 -22
- data/spec/rest/verix/verix_metadata_spec.rb +1 -1
- data/spec/rest/verix/verix_pdf_documents_spec.rb +14 -19
- data/spec/rest/verix/verix_records_spec.rb +31 -10
- data/spec/rest/version_spec.rb +6 -4
- data/spec/spec_helper.rb +2 -2
- data/spec/support/fake_api.rb +25 -4
- data/spec/support/fixtures/documents_orders_none.json +6 -0
- data/spec/support/fixtures/upload_types.json +9 -0
- data/spec/utils/query_builder_spec.rb +40 -14
- metadata +83 -70
@@ -6,8 +6,10 @@ module FinApps
|
|
6
6
|
def show(consumer_id, signature_request_id)
|
7
7
|
not_blank(consumer_id, :consumer_id)
|
8
8
|
not_blank(signature_request_id, :signature_request_id)
|
9
|
+
|
9
10
|
path =
|
10
|
-
"consumers/#{ERB::Util.url_encode(consumer_id)}/
|
11
|
+
"consumers/#{ERB::Util.url_encode(consumer_id)}/"\
|
12
|
+
"documents/#{ERB::Util.url_encode(signature_request_id)}"
|
11
13
|
super(nil, path)
|
12
14
|
end
|
13
15
|
end
|
@@ -5,15 +5,24 @@ module FinApps
|
|
5
5
|
module QueryBuilder
|
6
6
|
def build_query_path(root_url, params)
|
7
7
|
filter_obj = build_filter(params)
|
8
|
-
page = "page=#{params[:page].to_i}" if params[:page]
|
9
|
-
requested = "requested=#{params[:requested].to_i}" if params[:requested]
|
10
|
-
sort = "sort=#{ERB::Util.url_encode(params[:sort])}" if params[:sort]
|
11
8
|
filter = "filter=#{ERB::Util.url_encode(filter_obj.to_json)}" unless filter_obj.empty?
|
12
|
-
query_join(root_url, [page, requested, sort, filter])
|
9
|
+
query_join(root_url, [page(params), requested(params), sort(params), filter])
|
13
10
|
end
|
14
11
|
|
15
12
|
private
|
16
13
|
|
14
|
+
def page(params)
|
15
|
+
"page=#{params[:page].to_i}" if params[:page]
|
16
|
+
end
|
17
|
+
|
18
|
+
def requested(params)
|
19
|
+
"requested=#{params[:requested].to_i}" if params[:requested]
|
20
|
+
end
|
21
|
+
|
22
|
+
def sort(params)
|
23
|
+
"sort=#{ERB::Util.url_encode(params[:sort])}" if params[:sort]
|
24
|
+
end
|
25
|
+
|
17
26
|
def query_join(root_url, params_array)
|
18
27
|
query_string = params_array.compact.join('&')
|
19
28
|
[root_url, query_string].reject(&:empty?).join('?')
|
data/lib/finapps/version.rb
CHANGED
@@ -4,7 +4,7 @@ require 'spec_helpers/client'
|
|
4
4
|
|
5
5
|
RSpec.describe FinApps::REST::AlertDefinitions do
|
6
6
|
include SpecHelpers::Client
|
7
|
-
subject {
|
7
|
+
subject { described_class.new(client) }
|
8
8
|
|
9
9
|
describe '#list' do
|
10
10
|
let(:list) { subject.list(params) }
|
@@ -16,9 +16,11 @@ RSpec.describe FinApps::REST::AlertDefinitions do
|
|
16
16
|
|
17
17
|
it { expect { list }.not_to raise_error }
|
18
18
|
it('returns an array') { expect(list).to be_a(Array) }
|
19
|
+
|
19
20
|
it('performs a get and returns the response') do
|
20
21
|
expect(results).to have_key(:records)
|
21
22
|
end
|
23
|
+
|
22
24
|
it('returns no error messages') { expect(errors).to be_empty }
|
23
25
|
end
|
24
26
|
|
@@ -29,14 +31,17 @@ RSpec.describe FinApps::REST::AlertDefinitions do
|
|
29
31
|
end
|
30
32
|
|
31
33
|
context 'when including valid params' do
|
32
|
-
let(:params) { {
|
34
|
+
let(:params) { {page: 2, sort: '-created_date', requested: 25} }
|
33
35
|
|
34
36
|
it { expect { list }.not_to raise_error }
|
35
37
|
it('returns an array') { expect(list).to be_a(Array) }
|
38
|
+
|
36
39
|
it('performs a get and returns the response') do
|
37
40
|
expect(results).to have_key(:records)
|
38
41
|
end
|
42
|
+
|
39
43
|
it('returns no error messages') { expect(errors).to be_empty }
|
44
|
+
|
40
45
|
it 'builds query and sends proper request' do
|
41
46
|
list
|
42
47
|
url =
|
@@ -63,10 +68,8 @@ RSpec.describe FinApps::REST::AlertDefinitions do
|
|
63
68
|
|
64
69
|
it { expect { show }.not_to raise_error }
|
65
70
|
it('returns an array') { expect(show).to be_a(Array) }
|
66
|
-
it
|
67
|
-
|
68
|
-
expect(results).to have_key(:rule_name)
|
69
|
-
end
|
71
|
+
it { expect(results).to have_key(:_id) }
|
72
|
+
it { expect(results).to have_key(:rule_name) }
|
70
73
|
it('returns no error messages') { expect(errors).to be_empty }
|
71
74
|
end
|
72
75
|
|
@@ -75,6 +78,7 @@ RSpec.describe FinApps::REST::AlertDefinitions do
|
|
75
78
|
|
76
79
|
it { expect { show }.not_to raise_error }
|
77
80
|
it('results is nil') { expect(results).to be_nil }
|
81
|
+
|
78
82
|
it('error messages array is populated') do
|
79
83
|
expect(errors.first.downcase).to eq('resource not found')
|
80
84
|
end
|
@@ -4,7 +4,7 @@ require 'spec_helpers/client'
|
|
4
4
|
|
5
5
|
RSpec.describe FinApps::REST::AlertOccurrences do
|
6
6
|
include SpecHelpers::Client
|
7
|
-
subject {
|
7
|
+
subject { described_class.new(client) }
|
8
8
|
|
9
9
|
describe '#list' do
|
10
10
|
let(:list) { subject.list(params) }
|
@@ -16,9 +16,11 @@ RSpec.describe FinApps::REST::AlertOccurrences do
|
|
16
16
|
|
17
17
|
it { expect { list }.not_to raise_error }
|
18
18
|
it('returns an array') { expect(list).to be_a(Array) }
|
19
|
+
|
19
20
|
it('performs a get and returns the response') do
|
20
21
|
expect(results).to have_key(:records)
|
21
22
|
end
|
23
|
+
|
22
24
|
it('returns no error messages') { expect(errors).to be_empty }
|
23
25
|
end
|
24
26
|
|
@@ -40,10 +42,13 @@ RSpec.describe FinApps::REST::AlertOccurrences do
|
|
40
42
|
|
41
43
|
it { expect { list }.not_to raise_error }
|
42
44
|
it('returns an array') { expect(list).to be_a(Array) }
|
45
|
+
|
43
46
|
it('performs a get and returns the response') do
|
44
47
|
expect(results).to have_key(:records)
|
45
48
|
end
|
49
|
+
|
46
50
|
it('returns no error messages') { expect(errors).to be_empty }
|
51
|
+
|
47
52
|
it 'builds query and sends proper request' do
|
48
53
|
list
|
49
54
|
url =
|
data/spec/rest/api_request.rb
CHANGED
data/spec/rest/client_spec.rb
CHANGED
@@ -3,28 +3,28 @@
|
|
3
3
|
RSpec.describe FinApps::REST::Client do
|
4
4
|
describe '#new' do
|
5
5
|
it 'raises for missing company_token' do
|
6
|
-
expect {
|
6
|
+
expect { described_class.new nil }.to raise_error(
|
7
7
|
FinAppsCore::MissingArgumentsError
|
8
8
|
)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
context 'an instance of Client' do
|
13
|
-
subject {
|
12
|
+
context 'with an instance of Client' do
|
13
|
+
subject(:client) { described_class.new(:company_token) }
|
14
14
|
|
15
15
|
FinApps::REST::Client::RESOURCES.each do |method|
|
16
|
-
it("responds to #{method}") { expect(
|
16
|
+
it("responds to #{method}") { expect(client).to respond_to(method) }
|
17
17
|
|
18
18
|
it "memoizes the result of #{method}" do
|
19
|
-
first =
|
20
|
-
second =
|
19
|
+
first = client.send(method)
|
20
|
+
second = client.send(method)
|
21
21
|
expect(first.object_id).to eq(second.object_id)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe '#alert_definitions' do
|
26
26
|
it do
|
27
|
-
expect(
|
27
|
+
expect(client.alert_definitions).to be_an_instance_of(
|
28
28
|
FinApps::REST::AlertDefinitions
|
29
29
|
)
|
30
30
|
end
|
@@ -32,7 +32,7 @@ RSpec.describe FinApps::REST::Client do
|
|
32
32
|
|
33
33
|
describe '#alert_occurrences' do
|
34
34
|
it do
|
35
|
-
expect(
|
35
|
+
expect(client.alert_occurrences).to be_an_instance_of(
|
36
36
|
FinApps::REST::AlertOccurrences
|
37
37
|
)
|
38
38
|
end
|
@@ -40,41 +40,41 @@ RSpec.describe FinApps::REST::Client do
|
|
40
40
|
|
41
41
|
describe '#version' do
|
42
42
|
it do
|
43
|
-
expect(
|
43
|
+
expect(client.version).to be_an_instance_of(FinApps::REST::Version)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe '#consumers' do
|
48
48
|
it do
|
49
|
-
expect(
|
49
|
+
expect(client.consumers).to be_an_instance_of(FinApps::REST::Consumers)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
describe '#plaid_webhooks' do
|
54
54
|
it do
|
55
55
|
expect(
|
56
|
-
|
56
|
+
client.plaid_webhooks
|
57
57
|
).to be_an_instance_of FinApps::REST::PlaidWebhooks
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
describe '#sessions' do
|
62
62
|
it do
|
63
|
-
expect(
|
63
|
+
expect(client.sessions).to be_an_instance_of(FinApps::REST::Sessions)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
describe '#order_assignments' do
|
68
68
|
it do
|
69
|
-
expect(
|
69
|
+
expect(client.order_assignments).to be_an_instance_of(
|
70
70
|
FinApps::REST::OrderAssignments
|
71
71
|
)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
describe '#
|
75
|
+
describe '#order_notifications' do
|
76
76
|
it do
|
77
|
-
expect(
|
77
|
+
expect(client.order_notifications).to be_an_instance_of(
|
78
78
|
FinApps::REST::OrderNotifications
|
79
79
|
)
|
80
80
|
end
|
@@ -82,7 +82,7 @@ RSpec.describe FinApps::REST::Client do
|
|
82
82
|
|
83
83
|
describe '#order_statuses' do
|
84
84
|
it do
|
85
|
-
expect(
|
85
|
+
expect(client.order_statuses).to be_an_instance_of(
|
86
86
|
FinApps::REST::OrderStatuses
|
87
87
|
)
|
88
88
|
end
|
@@ -90,7 +90,7 @@ RSpec.describe FinApps::REST::Client do
|
|
90
90
|
|
91
91
|
describe '#order_refreshes' do
|
92
92
|
it do
|
93
|
-
expect(
|
93
|
+
expect(client.order_refreshes).to be_an_instance_of(
|
94
94
|
FinApps::REST::OrderRefreshes
|
95
95
|
)
|
96
96
|
end
|
@@ -98,7 +98,7 @@ RSpec.describe FinApps::REST::Client do
|
|
98
98
|
|
99
99
|
describe '#order_reports' do
|
100
100
|
it do
|
101
|
-
expect(
|
101
|
+
expect(client.order_reports).to be_an_instance_of(
|
102
102
|
FinApps::REST::OrderReports
|
103
103
|
)
|
104
104
|
end
|
@@ -106,19 +106,19 @@ RSpec.describe FinApps::REST::Client do
|
|
106
106
|
|
107
107
|
describe '#order_tokens' do
|
108
108
|
it do
|
109
|
-
expect(
|
109
|
+
expect(client.order_tokens).to be_an_instance_of(
|
110
110
|
FinApps::REST::OrderTokens
|
111
111
|
)
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
115
|
describe '#orders' do
|
116
|
-
it { expect(
|
116
|
+
it { expect(client.orders).to be_an_instance_of(FinApps::REST::Orders) }
|
117
117
|
end
|
118
118
|
|
119
119
|
describe '#password_resets' do
|
120
120
|
it do
|
121
|
-
expect(
|
121
|
+
expect(client.password_resets).to be_an_instance_of(
|
122
122
|
FinApps::REST::PasswordResets
|
123
123
|
)
|
124
124
|
end
|
@@ -126,7 +126,7 @@ RSpec.describe FinApps::REST::Client do
|
|
126
126
|
|
127
127
|
describe '#operators_password_resets' do
|
128
128
|
it do
|
129
|
-
expect(
|
129
|
+
expect(client.operators_password_resets).to be_an_instance_of(
|
130
130
|
FinApps::REST::OperatorsPasswordResets
|
131
131
|
)
|
132
132
|
end
|
@@ -134,19 +134,19 @@ RSpec.describe FinApps::REST::Client do
|
|
134
134
|
|
135
135
|
describe '#operators' do
|
136
136
|
it do
|
137
|
-
expect(
|
137
|
+
expect(client.operators).to be_an_instance_of(FinApps::REST::Operators)
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
141
|
describe '#products' do
|
142
142
|
it do
|
143
|
-
expect(
|
143
|
+
expect(client.products).to be_an_instance_of(FinApps::REST::Products)
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
147
|
describe '#portfolios' do
|
148
148
|
it do
|
149
|
-
expect(
|
149
|
+
expect(client.portfolios).to be_an_instance_of(
|
150
150
|
FinApps::REST::Portfolios
|
151
151
|
)
|
152
152
|
end
|
@@ -154,7 +154,7 @@ RSpec.describe FinApps::REST::Client do
|
|
154
154
|
|
155
155
|
describe '#portfolios_alerts' do
|
156
156
|
it do
|
157
|
-
expect(
|
157
|
+
expect(client.portfolios_alerts).to be_an_instance_of(
|
158
158
|
FinApps::REST::PortfoliosAlerts
|
159
159
|
)
|
160
160
|
end
|
@@ -162,7 +162,7 @@ RSpec.describe FinApps::REST::Client do
|
|
162
162
|
|
163
163
|
describe '#portfolios_available_consumers' do
|
164
164
|
it do
|
165
|
-
expect(
|
165
|
+
expect(client.portfolios_available_consumers).to be_an_instance_of(
|
166
166
|
FinApps::REST::PortfoliosAvailableConsumers
|
167
167
|
)
|
168
168
|
end
|
@@ -170,7 +170,7 @@ RSpec.describe FinApps::REST::Client do
|
|
170
170
|
|
171
171
|
describe '#portfolios_consumers' do
|
172
172
|
it do
|
173
|
-
expect(
|
173
|
+
expect(client.portfolios_consumers).to be_an_instance_of(
|
174
174
|
FinApps::REST::PortfoliosConsumers
|
175
175
|
)
|
176
176
|
end
|
@@ -178,7 +178,7 @@ RSpec.describe FinApps::REST::Client do
|
|
178
178
|
|
179
179
|
describe '#consumers_portfolios' do
|
180
180
|
it do
|
181
|
-
expect(
|
181
|
+
expect(client.consumers_portfolios).to be_an_instance_of(
|
182
182
|
FinApps::REST::ConsumersPortfolios
|
183
183
|
)
|
184
184
|
end
|
@@ -186,7 +186,7 @@ RSpec.describe FinApps::REST::Client do
|
|
186
186
|
|
187
187
|
describe '#portfolio_reports' do
|
188
188
|
it do
|
189
|
-
expect(
|
189
|
+
expect(client.portfolio_reports).to be_an_instance_of(
|
190
190
|
FinApps::REST::PortfolioReports
|
191
191
|
)
|
192
192
|
end
|
@@ -194,7 +194,7 @@ RSpec.describe FinApps::REST::Client do
|
|
194
194
|
|
195
195
|
describe '#tenant_settings' do
|
196
196
|
it do
|
197
|
-
expect(
|
197
|
+
expect(client.tenant_settings).to be_an_instance_of(
|
198
198
|
FinApps::REST::TenantSettings
|
199
199
|
)
|
200
200
|
end
|
@@ -202,23 +202,15 @@ RSpec.describe FinApps::REST::Client do
|
|
202
202
|
|
203
203
|
describe '#tenant_app_settings' do
|
204
204
|
it do
|
205
|
-
expect(
|
205
|
+
expect(client.tenant_app_settings).to be_an_instance_of(
|
206
206
|
FinApps::REST::TenantAppSettings
|
207
207
|
)
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
211
|
-
describe '#plaid_webhooks' do
|
212
|
-
it do
|
213
|
-
expect(subject.plaid_webhooks).to be_an_instance_of(
|
214
|
-
FinApps::REST::PlaidWebhooks
|
215
|
-
)
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
211
|
describe '#plaid_institution_logos' do
|
220
212
|
it do
|
221
|
-
expect(
|
213
|
+
expect(client.plaid_institution_logos).to be_an_instance_of(
|
222
214
|
FinApps::REST::PlaidInstitutionLogos
|
223
215
|
)
|
224
216
|
end
|
@@ -4,7 +4,7 @@ require 'spec_helpers/client'
|
|
4
4
|
|
5
5
|
RSpec.describe FinApps::REST::ConsumersPortfolios do
|
6
6
|
include SpecHelpers::Client
|
7
|
-
subject {
|
7
|
+
subject { described_class.new(client) }
|
8
8
|
|
9
9
|
describe '#list' do
|
10
10
|
let(:list) { subject.list(id, params) }
|
@@ -24,9 +24,11 @@ RSpec.describe FinApps::REST::ConsumersPortfolios do
|
|
24
24
|
|
25
25
|
it { expect { list }.not_to raise_error }
|
26
26
|
it('returns an array') { expect(list).to be_a(Array) }
|
27
|
+
|
27
28
|
it('performs a get and returns the response') do
|
28
29
|
expect(results).to have_key(:records)
|
29
30
|
end
|
31
|
+
|
30
32
|
it('returns no error messages') { expect(errors).to be_empty }
|
31
33
|
end
|
32
34
|
|
@@ -39,14 +41,17 @@ RSpec.describe FinApps::REST::ConsumersPortfolios do
|
|
39
41
|
|
40
42
|
context 'when including valid params' do
|
41
43
|
let(:id) { 'valid_id' }
|
42
|
-
let(:params) { {
|
44
|
+
let(:params) { {page: 2, sort: '-created_date', requested: 25} }
|
43
45
|
|
44
46
|
it { expect { list }.not_to raise_error }
|
45
47
|
it('returns an array') { expect(list).to be_a(Array) }
|
48
|
+
|
46
49
|
it('performs a get and returns the response') do
|
47
50
|
expect(results).to have_key(:records)
|
48
51
|
end
|
52
|
+
|
49
53
|
it('returns no error messages') { expect(errors).to be_empty }
|
54
|
+
|
50
55
|
it 'builds query and sends proper request' do
|
51
56
|
list
|
52
57
|
url =
|
data/spec/rest/consumers_spec.rb
CHANGED
@@ -1,280 +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
|
-
missing_public_id = ': public_id'
|
9
|
-
|
10
|
-
describe '#create' do
|
11
|
-
let(:results) { create[0] }
|
12
|
-
let(:error_messages) { create[1] }
|
13
|
-
|
14
|
-
context 'when missing params' do
|
15
|
-
it do
|
16
|
-
expect { subject.create(nil) }.to raise_error(
|
17
|
-
FinAppsCore::MissingArgumentsError
|
18
|
-
)
|
19
|
-
end
|
20
|
-
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) }
|
21
8
|
|
22
|
-
|
23
|
-
let(:create) { subject.create(email: 'email', password: 'password') }
|
9
|
+
missing_public_id = ': public_id'
|
24
10
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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 { users.create(nil) }.to raise_error(
|
18
|
+
FinAppsCore::MissingArgumentsError
|
19
|
+
)
|
20
|
+
end
|
29
21
|
end
|
30
|
-
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
31
|
-
end
|
32
22
|
|
33
|
-
|
34
|
-
|
23
|
+
context 'with valid params' do
|
24
|
+
let(:create) { subject.create(email: 'email', password: 'password') }
|
35
25
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
26
|
+
it { expect { create }.not_to raise_error }
|
27
|
+
it('results is a Hash') { expect(results).to be_a(Hash) }
|
28
|
+
|
29
|
+
it('performs a post and returns the response') do
|
30
|
+
expect(results).to have_key(:public_id)
|
31
|
+
end
|
32
|
+
|
33
|
+
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
40
34
|
end
|
41
|
-
end
|
42
|
-
end
|
43
35
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
36
|
+
context 'with invalid params' do
|
37
|
+
let(:create) { subject.create(email: 'email') }
|
38
|
+
|
39
|
+
it { expect { create }.not_to raise_error }
|
40
|
+
it('results is nil') { expect(results).to be_nil }
|
48
41
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
it('performs a get and returns the response') do
|
53
|
-
expect(results).to have_key(:records)
|
42
|
+
it('error messages array is populated') do
|
43
|
+
expect(error_messages.first.downcase).to eq('invalid request body')
|
44
|
+
end
|
54
45
|
end
|
55
|
-
it('returns an array of records') { expect(results[:records]).to be_a(Array) }
|
56
|
-
it('returns no error messages') { expect(error_messages).to be_empty }
|
57
46
|
end
|
58
47
|
|
59
|
-
|
60
|
-
let(:
|
48
|
+
describe '#list' do
|
49
|
+
let(:list) { subject.list(params) }
|
50
|
+
let(:results) { list[0] }
|
51
|
+
let(:error_messages) { list[1] }
|
61
52
|
|
62
|
-
|
63
|
-
|
53
|
+
context 'when missing params' do
|
54
|
+
let(:params) { nil }
|
64
55
|
|
65
|
-
|
66
|
-
let(:params) do
|
67
|
-
{
|
68
|
-
page: 3,
|
69
|
-
requested: 19
|
70
|
-
}
|
71
|
-
end
|
56
|
+
it { expect { list }.not_to raise_error }
|
72
57
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
expect(results).to have_key(:records)
|
77
|
-
end
|
78
|
-
it('returns no error messages') do
|
79
|
-
expect(error_messages).to be_empty
|
80
|
-
end
|
81
|
-
it 'builds query and sends proper request' do
|
82
|
-
list
|
83
|
-
url = "#{versioned_api_path}/consumers?page=3&requested=19"
|
84
|
-
expect(WebMock).to have_requested(:get, url)
|
85
|
-
end
|
86
|
-
end
|
58
|
+
it('performs a get and returns the response') do
|
59
|
+
expect(results).to have_key(:records)
|
60
|
+
end
|
87
61
|
|
88
|
-
|
89
|
-
|
90
|
-
{
|
91
|
-
page: 2,
|
92
|
-
sort: 'date_created',
|
93
|
-
requested: 25,
|
94
|
-
searchTerm: 'term'
|
95
|
-
}
|
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 }
|
96
64
|
end
|
97
65
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
expect
|
102
|
-
end
|
103
|
-
it('returns no error messages') do
|
104
|
-
expect(error_messages).to be_empty
|
105
|
-
end
|
106
|
-
it 'builds query and sends proper request' do
|
107
|
-
list
|
108
|
-
url = "#{versioned_api_path}/consumers?filter=%7B%22$or%22:%5B%7B%22email%22:%22term%22%7D," \
|
109
|
-
'%7B%22first_name%22:%22term%22%7D,%7B%22last_name%22:%22term%22%7D%5D%7D&page=2&requested=25' \
|
110
|
-
'&sort=date_created'
|
111
|
-
expect(WebMock).to have_requested(:get, url)
|
66
|
+
context 'when invalid params are provided' do
|
67
|
+
let(:params) { ['invalid array'] }
|
68
|
+
|
69
|
+
it { expect { list }.to raise_error(FinAppsCore::InvalidArgumentsError) }
|
112
70
|
end
|
113
71
|
|
114
|
-
context 'when
|
72
|
+
context 'when including valid params without searchTerm' do
|
115
73
|
let(:params) do
|
116
74
|
{
|
117
|
-
page:
|
118
|
-
|
119
|
-
requested: 25,
|
120
|
-
searchTerm: 'Two terms'
|
75
|
+
page: 3,
|
76
|
+
requested: 19
|
121
77
|
}
|
122
78
|
end
|
123
|
-
it 'treats space as start of a new query for first and last name' do
|
124
|
-
list
|
125
|
-
url = "#{versioned_api_path}/consumers?filter=%7B%22$or%22:%5B%7B%22email%22:%22Two%20terms%22%7D,"\
|
126
|
-
'%7B%22first_name%22:%22Two%20terms%22%7D,%7B%22last_name%22:%22Two%20terms%22%7D,%7B%22first_name%22:'\
|
127
|
-
'%22Two%22%7D,%7B%22last_name%22:%22Two%22%7D,%7B%22first_name%22:%22terms%22%7D,%7B%22last_name%22:'\
|
128
|
-
'%22terms%22%7D%5D%7D&page=2&requested=25&sort=date_created'
|
129
|
-
expect(WebMock).to have_requested(:get, url)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
79
|
|
135
|
-
|
136
|
-
|
137
|
-
it do
|
138
|
-
expect { subject.show(nil) }.to raise_error(
|
139
|
-
FinAppsCore::MissingArgumentsError,
|
140
|
-
missing_public_id
|
141
|
-
)
|
142
|
-
end
|
143
|
-
end
|
80
|
+
it { expect { list }.not_to raise_error }
|
81
|
+
it('returns an array') { expect(list).to be_a(Array) }
|
144
82
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
let(:error_messages) { show[1] }
|
149
|
-
|
150
|
-
it { expect { show }.not_to raise_error }
|
151
|
-
it('results is a Hash') { expect(results).to be_a(Hash) }
|
152
|
-
it('performs a get and returns the response') do
|
153
|
-
expect(results).to have_key(:public_id)
|
154
|
-
end
|
155
|
-
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
156
|
-
end
|
83
|
+
it('performs a get and returns the response') do
|
84
|
+
expect(results).to have_key(:records)
|
85
|
+
end
|
157
86
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
let(:error_messages) { show[1] }
|
87
|
+
it('returns no error messages') do
|
88
|
+
expect(error_messages).to be_empty
|
89
|
+
end
|
162
90
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
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
|
167
96
|
end
|
168
|
-
end
|
169
|
-
end
|
170
97
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
98
|
+
context 'when including valid params with searchTerm' do
|
99
|
+
let(:params) do
|
100
|
+
{
|
101
|
+
page: 2,
|
102
|
+
sort: 'date_created',
|
103
|
+
requested: 25,
|
104
|
+
searchTerm: 'term'
|
105
|
+
}
|
106
|
+
end
|
180
107
|
|
181
|
-
|
182
|
-
|
183
|
-
let(:update) { subject.update(:valid_public_id, postal_code: '33021') }
|
184
|
-
let(:results) { update[0] }
|
185
|
-
let(:error_messages) { update[1] }
|
108
|
+
it { expect { list }.not_to raise_error }
|
109
|
+
it('returns an array') { expect(list).to be_a(Array) }
|
186
110
|
|
187
|
-
it
|
188
|
-
|
189
|
-
|
190
|
-
end
|
111
|
+
it('performs a get and returns the response') do
|
112
|
+
expect(results).to have_key(:records)
|
113
|
+
end
|
191
114
|
|
192
|
-
|
193
|
-
|
194
|
-
subject.update(:invalid_public_id, postal_code: '33021')
|
115
|
+
it('returns no error messages') do
|
116
|
+
expect(error_messages).to be_empty
|
195
117
|
end
|
196
|
-
let(:results) { update[0] }
|
197
|
-
let(:error_messages) { update[1] }
|
198
118
|
|
199
|
-
it
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
'
|
204
|
-
|
119
|
+
it 'builds query and sends proper request' do
|
120
|
+
list
|
121
|
+
url = "#{versioned_api_path}/consumers?"\
|
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'
|
126
|
+
expect(WebMock).to have_requested(:get, url)
|
127
|
+
end
|
128
|
+
|
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
|
205
150
|
end
|
206
151
|
end
|
207
152
|
end
|
208
153
|
|
209
|
-
|
210
|
-
context '
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
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
|
215
160
|
)
|
216
161
|
end
|
217
|
-
|
218
|
-
let(:error_messages) { update[1] }
|
162
|
+
end
|
219
163
|
|
220
|
-
|
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] }
|
168
|
+
|
169
|
+
it { expect { show }.not_to raise_error }
|
221
170
|
it('results is a Hash') { expect(results).to be_a(Hash) }
|
222
|
-
|
171
|
+
|
172
|
+
it('performs a get and returns the response') do
|
223
173
|
expect(results).to have_key(:public_id)
|
224
174
|
end
|
225
|
-
|
226
|
-
expect(results).to have_key(:token)
|
227
|
-
end
|
175
|
+
|
228
176
|
it('error_messages array is empty') { expect(error_messages).to eq([]) }
|
229
177
|
end
|
230
178
|
|
231
|
-
context '
|
232
|
-
let(:
|
233
|
-
|
234
|
-
|
235
|
-
password: 'Aa123456!', password_confirm: 'Aa123456!'
|
236
|
-
)
|
237
|
-
end
|
238
|
-
let(:results) { update[0] }
|
239
|
-
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] }
|
240
183
|
|
241
|
-
it { expect {
|
184
|
+
it { expect { show }.not_to raise_error }
|
242
185
|
it('results is nil') { expect(results).to be_nil }
|
186
|
+
|
243
187
|
it('error messages array is populated') do
|
244
188
|
expect(error_messages.first.downcase).to eq('resource not found')
|
245
189
|
end
|
246
190
|
end
|
247
191
|
end
|
248
192
|
|
249
|
-
describe '#
|
193
|
+
describe '#update' do
|
250
194
|
context 'when missing public_id' do
|
251
195
|
it do
|
252
|
-
expect {
|
196
|
+
expect { users.update(nil, {}) }.to raise_error(
|
253
197
|
FinAppsCore::MissingArgumentsError,
|
254
198
|
missing_public_id
|
255
199
|
)
|
256
200
|
end
|
257
201
|
end
|
258
202
|
|
259
|
-
context '
|
260
|
-
|
261
|
-
|
262
|
-
|
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] }
|
263
208
|
|
264
|
-
|
265
|
-
|
266
|
-
|
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([]) }
|
212
|
+
end
|
213
|
+
|
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
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
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([]) }
|
255
|
+
end
|
256
|
+
|
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
|
273
|
+
end
|
267
274
|
end
|
268
275
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
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
|
284
|
+
end
|
273
285
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
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
|
+
|
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
|
+
|
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
|
+
|
301
|
+
it { expect { destroy }.not_to raise_error }
|
302
|
+
it('results is nil') { expect(results).to be_nil }
|
303
|
+
|
304
|
+
it('error messages array is populated') do
|
305
|
+
expect(error_messages.first.downcase).to eq('resource not found')
|
306
|
+
end
|
278
307
|
end
|
279
308
|
end
|
280
309
|
end
|