finapps 5.0.46 → 5.3.0
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/dependabot.yml +7 -0
- data/.github/workflows/ci.yaml +47 -0
- data/.github/workflows/release.yml +42 -42
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/Guardfile +1 -1
- data/finapps.gemspec +8 -7
- data/lib/finapps.rb +1 -0
- data/lib/finapps/rest/client.rb +2 -1
- data/lib/finapps/rest/consumers.rb +6 -5
- data/lib/finapps/rest/documents_orders.rb +11 -12
- data/lib/finapps/rest/operators.rb +3 -3
- data/lib/finapps/rest/orders.rb +6 -6
- data/lib/finapps/rest/screenings.rb +71 -0
- data/lib/finapps/version.rb +1 -1
- data/spec/rest/api_request.rb +8 -0
- data/spec/rest/consumers_spec.rb +20 -12
- data/spec/rest/documents_orders_spec.rb +29 -40
- data/spec/rest/screenings_spec.rb +251 -0
- data/spec/support/fake_api.rb +9 -0
- data/spec/support/fixtures/screening.json +26 -0
- data/spec/support/fixtures/screening_invalid_update.json +5 -0
- data/spec/support/fixtures/screening_list.json +25 -0
- data/spec/support/fixtures/screenings/last_session.json +13 -0
- data/spec/support/fixtures/screenings/session_not_found_with_id.json +5 -0
- data/spec/support/fixtures/session_not_found.json +5 -0
- data/spec/support/screenings_routes.rb +72 -0
- metadata +109 -77
- data/.github/workflows/main.yaml +0 -38
data/lib/finapps/version.rb
CHANGED
data/spec/rest/api_request.rb
CHANGED
@@ -16,3 +16,11 @@ RSpec.shared_examples 'a successful request' do |_parameter|
|
|
16
16
|
expect(subject[ERROR_MESSAGES]).to be_empty
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
RSpec.shared_examples 'a request that raises an error' do |_parameter|
|
21
|
+
it do
|
22
|
+
expect { subject }.to raise_error(
|
23
|
+
FinAppsCore::MissingArgumentsError
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
data/spec/rest/consumers_spec.rb
CHANGED
@@ -118,11 +118,14 @@ RSpec.describe FinApps::REST::Consumers do
|
|
118
118
|
|
119
119
|
it 'builds query and sends proper request' do
|
120
120
|
list
|
121
|
-
|
122
|
-
'
|
123
|
-
'
|
124
|
-
'
|
125
|
-
'
|
121
|
+
filter = '{"$or":['\
|
122
|
+
'{"external_id":"term"},'\
|
123
|
+
'{"email":"term"},'\
|
124
|
+
'{"first_name":"term"},'\
|
125
|
+
'{"last_name":"term"}'\
|
126
|
+
']}'
|
127
|
+
query = "?filter=#{filter}&page=2&requested=25&sort=date_created"
|
128
|
+
url = "#{versioned_api_path}/consumers#{query}"
|
126
129
|
expect(WebMock).to have_requested(:get, url)
|
127
130
|
end
|
128
131
|
|
@@ -138,13 +141,18 @@ RSpec.describe FinApps::REST::Consumers do
|
|
138
141
|
|
139
142
|
it 'treats space as start of a new query for first and last name' do
|
140
143
|
list
|
141
|
-
|
142
|
-
'
|
143
|
-
'
|
144
|
-
'
|
145
|
-
'
|
146
|
-
'
|
147
|
-
'
|
144
|
+
filter = '{"$or":['\
|
145
|
+
'{"external_id":"Two terms"},'\
|
146
|
+
'{"email":"Two terms"},'\
|
147
|
+
'{"first_name":"Two terms"},'\
|
148
|
+
'{"last_name":"Two terms"},'\
|
149
|
+
'{"first_name":"Two"},'\
|
150
|
+
'{"last_name":"Two"},'\
|
151
|
+
'{"first_name":"terms"},'\
|
152
|
+
'{"last_name":"terms"}'\
|
153
|
+
']}'
|
154
|
+
query = "?filter=#{filter}&page=2&requested=25&sort=date_created"
|
155
|
+
url = "#{versioned_api_path}/consumers#{query}"
|
148
156
|
expect(WebMock).to have_requested(:get, url)
|
149
157
|
end
|
150
158
|
end
|
@@ -6,14 +6,6 @@ require 'rest/api_request'
|
|
6
6
|
RSpec.describe FinApps::REST::DocumentsOrders do
|
7
7
|
include SpecHelpers::Client
|
8
8
|
|
9
|
-
RSpec.shared_examples 'a request that raises an error' do |_parameter|
|
10
|
-
it do
|
11
|
-
expect { subject }.to raise_error(
|
12
|
-
FinAppsCore::MissingArgumentsError
|
13
|
-
)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
9
|
describe '#list' do
|
18
10
|
subject(:list) { described_class.new(client).list(params) }
|
19
11
|
|
@@ -60,33 +52,30 @@ RSpec.describe FinApps::REST::DocumentsOrders do
|
|
60
52
|
"#{versioned_api_path}/documents/orders?"\
|
61
53
|
'filter=%7B%22$or%22:%5B%7B%22applicant.email%22:'\
|
62
54
|
'%22term%22%7D,%7B%22applicant.first_name%22:%22term%22%7D,'\
|
63
|
-
'%7B%22applicant.last_name%22
|
64
|
-
'%22term%22%7D,%7B%22reference_no%22
|
65
|
-
'%22$options%22:%22i%22%7D%7D%5D,'\
|
66
|
-
'%22consumer_id%22:%22valid_consumer_id%22%7D&'
|
67
|
-
'page=2&requested=25&sort=tag '
|
55
|
+
'%7B%22applicant.last_name%22:%22term%22%7D,'\
|
56
|
+
'%7B%22applicant.external_id%22:%22term%22%7D,%7B%22reference_no%22:'\
|
57
|
+
'%7B%22$regex%22:%22%5Eterm%22,%22$options%22:%22i%22%7D%7D%5D,'\
|
58
|
+
'%22consumer_id%22:%22valid_consumer_id%22%7D&page=2&requested=25&sort=tag'
|
68
59
|
|
69
60
|
expect(WebMock).to have_requested(:get, url)
|
70
61
|
end
|
71
62
|
|
72
63
|
context 'with search term containing spaces' do
|
73
|
-
let(:params) { {
|
64
|
+
let(:params) { {searchTerm: 'Blue Jay', page: 2} }
|
74
65
|
|
75
66
|
it 'builds query and sends proper request' do
|
76
67
|
list
|
77
68
|
url =
|
78
69
|
"#{versioned_api_path}/documents/orders?"\
|
79
70
|
'filter=%7B%22$or%22:%5B%7B%22applicant.email%22:'\
|
80
|
-
'%22Blue%20Jay%22%7D
|
81
|
-
'%
|
82
|
-
'%7B%22applicant.
|
83
|
-
'%22Blue%20Jay%22%7D
|
84
|
-
'%
|
85
|
-
'%22
|
86
|
-
'%
|
87
|
-
'%7B%22applicant.last_name%22:%
|
88
|
-
'%7B%22applicant.first_name%22:%22Jay%22%7D,'\
|
89
|
-
'%7B%22applicant.last_name%22:%22Jay%22%7D%5D%7D&page=2'
|
71
|
+
'%22Blue%20Jay%22%7D,%7B%22applicant.first_name%22:'\
|
72
|
+
'%22Blue%20Jay%22%7D,%7B%22applicant.last_name%22:'\
|
73
|
+
'%22Blue%20Jay%22%7D,%7B%22applicant.external_id%22:'\
|
74
|
+
'%22Blue%20Jay%22%7D,%7B%22reference_no%22:%7B%22$regex%22:'\
|
75
|
+
'%22%5EBlue%20Jay%22,%22$options%22:%22i%22%7D%7D,'\
|
76
|
+
'%7B%22applicant.first_name%22:%22Blue%22%7D,%7B%22'\
|
77
|
+
'applicant.last_name%22:%22Blue%22%7D,%7B%22applicant.first_name%22:'\
|
78
|
+
'%22Jay%22%7D,%7B%22applicant.last_name%22:%22Jay%22%7D%5D%7D&page=2'
|
90
79
|
|
91
80
|
expect(WebMock).to have_requested(:get, url)
|
92
81
|
end
|
@@ -182,17 +171,17 @@ RSpec.describe FinApps::REST::DocumentsOrders do
|
|
182
171
|
context 'with valid params' do
|
183
172
|
let(:params) do
|
184
173
|
{
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
174
|
+
applicant: {
|
175
|
+
email: 'validemail@financialapps.com',
|
176
|
+
first_name: 'Emily',
|
177
|
+
last_name: 'Macs',
|
178
|
+
role: 'patient'
|
190
179
|
},
|
191
|
-
|
180
|
+
esign_documents: [
|
192
181
|
'temp-id'
|
193
182
|
],
|
194
|
-
|
195
|
-
|
183
|
+
reference_no: 'REFNO',
|
184
|
+
tag: 'new'
|
196
185
|
}
|
197
186
|
end
|
198
187
|
|
@@ -208,13 +197,13 @@ RSpec.describe FinApps::REST::DocumentsOrders do
|
|
208
197
|
context 'with invalid params' do
|
209
198
|
let(:params) do
|
210
199
|
{
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
200
|
+
applicant: {
|
201
|
+
email: 'validemail@financialapps.com',
|
202
|
+
first_name: 'Emily',
|
203
|
+
last_name: 'Macs',
|
204
|
+
role: 'patient'
|
216
205
|
},
|
217
|
-
|
206
|
+
reference_no: 'REFNO'
|
218
207
|
}
|
219
208
|
end
|
220
209
|
|
@@ -244,7 +233,7 @@ RSpec.describe FinApps::REST::DocumentsOrders do
|
|
244
233
|
let(:id) { :valid_order_id }
|
245
234
|
|
246
235
|
context 'with valid params' do
|
247
|
-
let(:params) { {
|
236
|
+
let(:params) { {tag: 'pending'} }
|
248
237
|
|
249
238
|
it_behaves_like 'an API request'
|
250
239
|
it_behaves_like 'a successful request'
|
@@ -252,7 +241,7 @@ RSpec.describe FinApps::REST::DocumentsOrders do
|
|
252
241
|
end
|
253
242
|
|
254
243
|
context 'with invalid params' do
|
255
|
-
let(:params) { {
|
244
|
+
let(:params) { {tag: 'invalid'} }
|
256
245
|
|
257
246
|
it_behaves_like 'an API request'
|
258
247
|
it('results is nil') { expect(results).to be_nil }
|
@@ -0,0 +1,251 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helpers/client'
|
4
|
+
require 'rest/api_request'
|
5
|
+
|
6
|
+
RSpec.describe FinApps::REST::Screenings do
|
7
|
+
include SpecHelpers::Client
|
8
|
+
|
9
|
+
let(:results) { subject[0] }
|
10
|
+
let(:error_messages) { subject[1] }
|
11
|
+
|
12
|
+
describe '#list' do
|
13
|
+
subject(:list) { described_class.new(client).list(params) }
|
14
|
+
|
15
|
+
context 'with valid params' do
|
16
|
+
let(:params) do
|
17
|
+
{
|
18
|
+
page: 2,
|
19
|
+
sort: 'date_created',
|
20
|
+
requested: 25,
|
21
|
+
searchTerm: 'term'
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'without searchTerm' do
|
26
|
+
let(:params) { {searchTerm: nil, page: 2} }
|
27
|
+
|
28
|
+
it_behaves_like 'an API request'
|
29
|
+
it_behaves_like 'a successful request'
|
30
|
+
it 'performs a get and returns the response' do
|
31
|
+
expect(results).to have_key(:records)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'builds query and sends proper request' do
|
35
|
+
list
|
36
|
+
url = "#{versioned_api_path}/screenings?page=2"
|
37
|
+
expect(WebMock).to have_requested(:get, url)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# rubocop:disable RSpec/ExampleLength
|
42
|
+
context 'with searchTerm' do
|
43
|
+
it_behaves_like 'an API request'
|
44
|
+
it_behaves_like 'a successful request'
|
45
|
+
it 'performs a get and returns the response' do
|
46
|
+
expect(results).to have_key(:records)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'builds query and sends proper request' do
|
50
|
+
list
|
51
|
+
url =
|
52
|
+
"#{versioned_api_path}/screenings?filter=%7B%22$or%22:%5B%7B%22" \
|
53
|
+
'consumer.public_id%22:%22term%22%7D,%7B%22consumer.email%22:%22' \
|
54
|
+
'term%22%7D%5D%7D&page=2&requested=25&sort=date_created'
|
55
|
+
|
56
|
+
expect(WebMock).to have_requested(:get, url)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
# rubocop:enable RSpec/ExampleLength
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'with invalid params' do
|
63
|
+
let(:params) { ['invalid array'] }
|
64
|
+
|
65
|
+
it { expect { list }.to raise_error(FinAppsCore::InvalidArgumentsError) }
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'with missing params' do
|
69
|
+
let(:params) { nil }
|
70
|
+
|
71
|
+
it_behaves_like 'an API request'
|
72
|
+
it_behaves_like 'a successful request'
|
73
|
+
it('performs a get and returns the response') do
|
74
|
+
expect(results).to have_key(:records)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#show' do
|
80
|
+
subject(:show) { described_class.new(client).show(id) }
|
81
|
+
|
82
|
+
context 'with valid id' do
|
83
|
+
let(:id) { :valid_id }
|
84
|
+
|
85
|
+
it_behaves_like 'an API request'
|
86
|
+
it_behaves_like 'a successful request'
|
87
|
+
it('performs a get and returns the response') do
|
88
|
+
expect(results).to have_key(:session)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'with invalid id' do
|
93
|
+
let(:id) { :invalid_id }
|
94
|
+
|
95
|
+
it { expect(results).to be_nil }
|
96
|
+
it { expect(error_messages).not_to be_empty }
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'when missing id' do
|
100
|
+
let(:id) { nil }
|
101
|
+
|
102
|
+
it_behaves_like 'a request that raises an error'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe '#last' do
|
107
|
+
subject(:last) { described_class.new(client).last(consumer_id) }
|
108
|
+
|
109
|
+
context 'with valid consumer_id' do
|
110
|
+
let(:consumer_id) { :valid_consumer_id }
|
111
|
+
|
112
|
+
it_behaves_like 'an API request'
|
113
|
+
it_behaves_like 'a successful request'
|
114
|
+
it('results have an :s_id node') do
|
115
|
+
expect(results).to have_key(:s_id)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context 'with invalid consumer_id' do
|
120
|
+
let(:consumer_id) { :invalid_consumer_id }
|
121
|
+
|
122
|
+
it { expect(results).to be_nil }
|
123
|
+
it { expect(error_messages).not_to be_empty }
|
124
|
+
end
|
125
|
+
|
126
|
+
context 'when missing consumer_id' do
|
127
|
+
let(:consumer_id) { nil }
|
128
|
+
|
129
|
+
it_behaves_like 'a request that raises an error'
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe '#create' do
|
134
|
+
subject(:create) { described_class.new(client).create(params) }
|
135
|
+
|
136
|
+
context 'with valid params' do
|
137
|
+
let(:params) do
|
138
|
+
{
|
139
|
+
email: 'validemail@financialapps.com',
|
140
|
+
first_name: 'Geo',
|
141
|
+
last_name: 'Metric',
|
142
|
+
public_id: '1234'
|
143
|
+
}
|
144
|
+
end
|
145
|
+
|
146
|
+
it_behaves_like 'an API request'
|
147
|
+
it_behaves_like 'a successful request'
|
148
|
+
it('results is a Hash') { expect(results).to be_a(Hash) }
|
149
|
+
|
150
|
+
it('performs a post and returns the response') do
|
151
|
+
expect(results).to have_key(:question)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'with invalid params' do
|
156
|
+
let(:params) { {params: 'invalid'} }
|
157
|
+
|
158
|
+
it { expect { create }.not_to raise_error }
|
159
|
+
it('results is nil') { expect(results).to be_nil }
|
160
|
+
|
161
|
+
it('error messages array is populated') do
|
162
|
+
expect(error_messages.first.downcase).to eq('invalid request body')
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
context 'with missing params' do
|
167
|
+
let(:params) { nil }
|
168
|
+
|
169
|
+
it_behaves_like 'a request that raises an error'
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe '#update' do
|
174
|
+
subject(:update) { described_class.new(client).update(id, params) }
|
175
|
+
|
176
|
+
let(:params) { {} }
|
177
|
+
|
178
|
+
context 'with valid session id' do
|
179
|
+
let(:id) { :valid_id }
|
180
|
+
|
181
|
+
context 'with valid params' do
|
182
|
+
let(:params) { {question_id: '1234'} }
|
183
|
+
|
184
|
+
it_behaves_like 'an API request'
|
185
|
+
it_behaves_like 'a successful request'
|
186
|
+
it('returns the next question') do
|
187
|
+
expect(results).to have_key(:question)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
context 'with invalid params' do
|
192
|
+
let(:params) { {question_id: 'invalid'} }
|
193
|
+
|
194
|
+
it_behaves_like 'an API request'
|
195
|
+
it('results is nil') { expect(results).to be_nil }
|
196
|
+
|
197
|
+
it('error messages array is populated') do
|
198
|
+
expect(error_messages.first.downcase).to eq('question with id (invalid) not found ')
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
context 'with invalid session id' do
|
204
|
+
let(:id) { :invalid_id }
|
205
|
+
let(:params) { {question_id: '1234'} }
|
206
|
+
|
207
|
+
it_behaves_like 'an API request'
|
208
|
+
it('results is nil') { expect(results).to be_nil }
|
209
|
+
|
210
|
+
it('error messages array is populated') do
|
211
|
+
expect(error_messages.first.downcase).to eq(
|
212
|
+
'resource not found'
|
213
|
+
)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
describe '#destroy' do
|
219
|
+
subject(:destroy) { described_class.new(client).destroy(id) }
|
220
|
+
|
221
|
+
context 'with valid session id' do
|
222
|
+
let(:id) { :valid_id }
|
223
|
+
|
224
|
+
it_behaves_like 'an API request'
|
225
|
+
it_behaves_like 'a successful request'
|
226
|
+
it('results is nil') { expect(results).to be_nil }
|
227
|
+
it('error_messages is empty') { expect(error_messages).to be_empty }
|
228
|
+
end
|
229
|
+
|
230
|
+
context 'when missing session id' do
|
231
|
+
let(:id) { nil }
|
232
|
+
|
233
|
+
it_behaves_like 'a request that raises an error'
|
234
|
+
end
|
235
|
+
|
236
|
+
context 'with invalid session id' do
|
237
|
+
let(:id) { :invalid_id }
|
238
|
+
|
239
|
+
it_behaves_like 'an API request'
|
240
|
+
it('results is nil') { expect(results).to be_nil }
|
241
|
+
|
242
|
+
it('error_messages is not empty') do
|
243
|
+
expect(error_messages).not_to be_empty
|
244
|
+
end
|
245
|
+
|
246
|
+
it('error messages array is populated') do
|
247
|
+
expect(error_messages.first.downcase).to eq('session not found')
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
data/spec/support/fake_api.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'sinatra/base'
|
4
4
|
require_relative 'documents_uploads_routes'
|
5
|
+
require_relative 'screenings_routes'
|
6
|
+
|
5
7
|
module Fake
|
6
8
|
# the FakeApi class is used to mock API requests while testing.
|
7
9
|
class FakeApi < Sinatra::Base
|
@@ -275,6 +277,9 @@ module Fake
|
|
275
277
|
# document_upload_types
|
276
278
|
get("/#{version}/documents/upload_types") { json_response 200, 'upload_types.json' }
|
277
279
|
|
280
|
+
# screenings
|
281
|
+
include ScreeningsRoutes
|
282
|
+
|
278
283
|
# consumers
|
279
284
|
get("/#{version}/consumers") do
|
280
285
|
json_response 200, 'users.json'
|
@@ -497,6 +502,10 @@ module Fake
|
|
497
502
|
|
498
503
|
private
|
499
504
|
|
505
|
+
def resource_not_found
|
506
|
+
json_response 404, 'resource_not_found.json'
|
507
|
+
end
|
508
|
+
|
500
509
|
def json_response(response_code, file_name)
|
501
510
|
http_response :json, response_code, file_name
|
502
511
|
end
|