finapps 5.0.33 → 5.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/release-drafter.yml +49 -0
- data/.github/workflows/main.yaml +38 -0
- data/.github/workflows/release-drafter.yml +15 -0
- data/.github/workflows/release.yml +43 -0
- data/.github/workflows/verify-pr-labeled.yml +14 -0
- data/.rubocop.yml +5 -12
- data/.rubocop_todo.yml +4 -95
- data/README.md +1 -0
- data/RELEASES.md +20 -0
- data/finapps.gemspec +1 -2
- data/lib/finapps.rb +2 -0
- data/lib/finapps/rest/client.rb +8 -5
- data/lib/finapps/rest/documents_orders.rb +1 -1
- data/lib/finapps/rest/documents_upload_types.rb +11 -0
- data/lib/finapps/rest/documents_uploads.rb +23 -0
- 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/documents_upload_types_spec.rb +21 -0
- data/spec/rest/documents_uploads_spec.rb +104 -0
- 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
- data/spec/support/fake_api.rb +16 -1
- data/spec/support/fixtures/upload_types.json +9 -0
- metadata +70 -79
- data/lib/tasks/releaser.rake +0 -12
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FinApps
|
4
|
+
module REST
|
5
|
+
class DocumentsUploads < FinAppsCore::REST::Resources
|
6
|
+
def show(consumer_id, doc_id, thumbnail = false)
|
7
|
+
not_blank(consumer_id, :consumer_id)
|
8
|
+
not_blank(doc_id, :doc_id)
|
9
|
+
|
10
|
+
path =
|
11
|
+
"consumers/#{ERB::Util.url_encode(consumer_id)}/"\
|
12
|
+
"documents/#{ERB::Util.url_encode(doc_id)}?thumbnail=#{thumbnail}"
|
13
|
+
super(nil, path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def destroy(order_id, doc_id)
|
17
|
+
not_blank(order_id, :order_id)
|
18
|
+
not_blank(doc_id, :doc_id)
|
19
|
+
super(nil, "documents/orders/#{order_id}/#{doc_id}")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/finapps/rest/orders.rb
CHANGED
@@ -63,22 +63,33 @@ module FinApps
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def search_query(term)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
else
|
80
|
-
{}
|
66
|
+
return {} unless term
|
67
|
+
|
68
|
+
query = search_query_object(term).concat(consumer_name_query(term))
|
69
|
+
{"$or": query}
|
70
|
+
end
|
71
|
+
|
72
|
+
def consumer_name_query(term)
|
73
|
+
search_arr = []
|
74
|
+
if /\s/.match?(term)
|
75
|
+
term.split.each do |t|
|
76
|
+
search_arr.append("applicant.first_name": t)
|
77
|
+
search_arr.append("applicant.last_name": t)
|
78
|
+
end
|
81
79
|
end
|
80
|
+
search_arr
|
81
|
+
end
|
82
|
+
|
83
|
+
def search_query_object(term)
|
84
|
+
[{"public_id": {"$regex": "^#{term}", "$options": 'i'}},
|
85
|
+
{"assignment.last_name": term},
|
86
|
+
{"applicant.first_name": term},
|
87
|
+
{"applicant.last_name": term},
|
88
|
+
{
|
89
|
+
"requestor.reference_no": {
|
90
|
+
"$regex": "^#{term}", "$options": 'i'
|
91
|
+
}
|
92
|
+
}]
|
82
93
|
end
|
83
94
|
|
84
95
|
def status_query(status)
|
@@ -15,14 +15,7 @@ module FinApps
|
|
15
15
|
begin
|
16
16
|
super params, path
|
17
17
|
rescue FinAppsCore::ApiUnauthenticatedError
|
18
|
-
(
|
19
|
-
[
|
20
|
-
nil,
|
21
|
-
[
|
22
|
-
"Invalid #{path == CONSUMER_LOGIN ? 'Consumer' : 'Operator'} Identifier or Credentials"
|
23
|
-
]
|
24
|
-
]
|
25
|
-
)
|
18
|
+
login_error(path)
|
26
19
|
end
|
27
20
|
end
|
28
21
|
|
@@ -36,6 +29,15 @@ module FinApps
|
|
36
29
|
params.key?(:email) && params[:email] && params.key?(:password) &&
|
37
30
|
params[:password]
|
38
31
|
end
|
32
|
+
|
33
|
+
def login_error(path)
|
34
|
+
[
|
35
|
+
nil,
|
36
|
+
[
|
37
|
+
"Invalid #{path == CONSUMER_LOGIN ? 'Consumer' : 'Operator'} Identifier or Credentials"
|
38
|
+
]
|
39
|
+
]
|
40
|
+
end
|
39
41
|
end
|
40
42
|
end
|
41
43
|
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
@@ -68,12 +68,8 @@ RSpec.describe FinApps::REST::AlertDefinitions do
|
|
68
68
|
|
69
69
|
it { expect { show }.not_to raise_error }
|
70
70
|
it('returns an array') { expect(show).to be_a(Array) }
|
71
|
-
|
72
|
-
it
|
73
|
-
expect(results).to have_key(:_id)
|
74
|
-
expect(results).to have_key(:rule_name)
|
75
|
-
end
|
76
|
-
|
71
|
+
it { expect(results).to have_key(:_id) }
|
72
|
+
it { expect(results).to have_key(:rule_name) }
|
77
73
|
it('returns no error messages') { expect(errors).to be_empty }
|
78
74
|
end
|
79
75
|
|
data/spec/rest/client_spec.rb
CHANGED
@@ -9,22 +9,22 @@ RSpec.describe FinApps::REST::Client do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
context 'an instance of Client' do
|
13
|
-
subject { described_class.new(:company_token) }
|
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
|
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
|