mas-rad_core 0.0.65 → 0.0.66
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/app/models/firm.rb +4 -0
- data/app/models/principal.rb +23 -0
- data/lib/mas/rad_core/version.rb +1 -1
- data/spec/dummy/log/development.log +1597 -0
- data/spec/dummy/log/test.log +157474 -0
- data/spec/models/firm_spec.rb +12 -0
- data/spec/models/principal_spec.rb +196 -0
- data/spec/support/shared_examples/at_least_one_remote_firm.rb +53 -0
- metadata +4 -2
data/spec/models/firm_spec.rb
CHANGED
@@ -13,6 +13,18 @@ RSpec.describe Firm do
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
describe '#registered?' do
|
17
|
+
it 'is false if the firm has no email address' do
|
18
|
+
firm.email_address = nil
|
19
|
+
expect(firm).not_to be_registered
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'is true if the firm has an email address' do
|
23
|
+
firm.email_address = 'acme@example.com'
|
24
|
+
expect(firm).to be_registered
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
16
28
|
describe '#telephone_number' do
|
17
29
|
context 'when `nil`' do
|
18
30
|
it 'returns `nil`' do
|
@@ -202,4 +202,200 @@ RSpec.describe Principal do
|
|
202
202
|
expect(Firm.where(id: firm.id)).to be_empty
|
203
203
|
end
|
204
204
|
end
|
205
|
+
|
206
|
+
describe '#next_onboarding_action' do
|
207
|
+
context 'when principal has no firms or trading names' do
|
208
|
+
before :each do
|
209
|
+
principal.firm.destroy
|
210
|
+
principal.reload
|
211
|
+
expect(principal.main_firm_with_trading_names).to be_empty
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'returns :complete_a_firm' do
|
215
|
+
expect(principal.next_onboarding_action).to eql(:complete_a_firm)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
context 'when principal only has a parent firm' do
|
220
|
+
before :each do
|
221
|
+
expect(principal.firm).not_to be_nil
|
222
|
+
expect(Firm.where(fca_number: principal.fca_number).count).to eql(1)
|
223
|
+
end
|
224
|
+
|
225
|
+
context 'and the parent firm is not registered' do
|
226
|
+
before :each do
|
227
|
+
expect(principal.firm).not_to be_registered
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'returns :complete_a_firm' do
|
231
|
+
expect(principal.next_onboarding_action).to eql(:complete_a_firm)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
context 'and the parent firm is registered' do
|
236
|
+
before :each do
|
237
|
+
principal.firm.update_column(:email_address, 'acme@example.com')
|
238
|
+
principal.reload
|
239
|
+
expect(principal.firm).to be_registered
|
240
|
+
end
|
241
|
+
|
242
|
+
context 'and the firm primarily gives remote advice' do
|
243
|
+
before :each do
|
244
|
+
principal.firm.in_person_advice_methods.destroy_all
|
245
|
+
principal.firm.other_advice_methods << create(:other_advice_method)
|
246
|
+
principal.reload
|
247
|
+
end
|
248
|
+
|
249
|
+
context 'and the firm has no advisers' do
|
250
|
+
before :each do
|
251
|
+
expect(principal.firm.advisers.any?).to eql(false)
|
252
|
+
end
|
253
|
+
|
254
|
+
it 'returns :onboarded' do
|
255
|
+
expect(principal.next_onboarding_action).to eql(:onboarded)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
context 'and the firm has advisers' do
|
260
|
+
before :each do
|
261
|
+
create(:adviser, firm: principal.firm)
|
262
|
+
principal.reload
|
263
|
+
expect(principal.firm.advisers.any?).to eql(true)
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'returns :onboarded' do
|
267
|
+
expect(principal.next_onboarding_action).to eql(:onboarded)
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
context 'and the firm primarily gives in-person advice' do
|
273
|
+
before :each do
|
274
|
+
principal.firm.in_person_advice_methods << create(:in_person_advice_method)
|
275
|
+
principal.reload
|
276
|
+
end
|
277
|
+
|
278
|
+
context 'and has at least one adviser' do
|
279
|
+
before :each do
|
280
|
+
create(:adviser, firm: principal.firm)
|
281
|
+
principal.reload
|
282
|
+
end
|
283
|
+
|
284
|
+
it 'returns :onboarded' do
|
285
|
+
expect(principal.next_onboarding_action).to eql(:onboarded)
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
context 'and does not have at least one adviser' do
|
290
|
+
before :each do
|
291
|
+
expect(principal.firm.advisers.any?).to eql(false)
|
292
|
+
end
|
293
|
+
|
294
|
+
it 'returns :complete_an_adviser' do
|
295
|
+
expect(principal.next_onboarding_action).to eql(:complete_an_adviser)
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
context 'when principal has a parent firm and a trading name' do
|
303
|
+
let(:parent_firm) { principal.firm }
|
304
|
+
let!(:trading_name) { create(:firm, registered_name: 'cabbage', parent_id: parent_firm.id, fca_number: principal.fca_number) }
|
305
|
+
|
306
|
+
before :each do
|
307
|
+
parent_firm.update_column(:email_address, 'acme@example.com')
|
308
|
+
principal.reload
|
309
|
+
expect(Firm.where(fca_number: principal.fca_number).count).to eql(2)
|
310
|
+
end
|
311
|
+
|
312
|
+
context 'and neither firm give in-person advice' do
|
313
|
+
before :each do
|
314
|
+
parent_firm.in_person_advice_methods.destroy_all
|
315
|
+
parent_firm.other_advice_methods << create(:other_advice_method)
|
316
|
+
trading_name.in_person_advice_methods.destroy_all
|
317
|
+
trading_name.other_advice_methods << create(:other_advice_method)
|
318
|
+
principal.reload
|
319
|
+
end
|
320
|
+
|
321
|
+
it_behaves_like 'at least one remote firm'
|
322
|
+
end
|
323
|
+
|
324
|
+
context 'if at least one firm gives remote advice' do
|
325
|
+
context 'parent firm gives remote advice' do
|
326
|
+
before :each do
|
327
|
+
parent_firm.in_person_advice_methods.destroy_all
|
328
|
+
parent_firm.other_advice_methods << create(:other_advice_method)
|
329
|
+
trading_name.in_person_advice_methods << create(:in_person_advice_method)
|
330
|
+
principal.reload
|
331
|
+
end
|
332
|
+
|
333
|
+
it_behaves_like 'at least one remote firm'
|
334
|
+
end
|
335
|
+
|
336
|
+
context 'trading name gives remote advice' do
|
337
|
+
before :each do
|
338
|
+
parent_firm.in_person_advice_methods << create(:in_person_advice_method)
|
339
|
+
trading_name.in_person_advice_methods.destroy_all
|
340
|
+
trading_name.other_advice_methods << create(:other_advice_method)
|
341
|
+
principal.reload
|
342
|
+
end
|
343
|
+
|
344
|
+
it_behaves_like 'at least one remote firm'
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
context 'and both firms give in-person advice' do
|
349
|
+
before :each do
|
350
|
+
parent_firm.in_person_advice_methods << create(:in_person_advice_method)
|
351
|
+
trading_name.in_person_advice_methods << create(:in_person_advice_method)
|
352
|
+
principal.reload
|
353
|
+
end
|
354
|
+
|
355
|
+
context 'and neither firm has advisers' do
|
356
|
+
before :each do
|
357
|
+
expect(parent_firm.advisers.any?).to eql(false)
|
358
|
+
expect(trading_name.advisers.any?).to eql(false)
|
359
|
+
end
|
360
|
+
|
361
|
+
it 'returns :complete_an_adviser' do
|
362
|
+
expect(principal.next_onboarding_action).to eql(:complete_an_adviser)
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
context 'and parent firm has advisers' do
|
367
|
+
before :each do
|
368
|
+
create(:adviser, firm: parent_firm)
|
369
|
+
expect(trading_name.advisers.any?).to eql(false)
|
370
|
+
end
|
371
|
+
|
372
|
+
it 'returns :onboarded' do
|
373
|
+
expect(principal.next_onboarding_action).to eql(:onboarded)
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
context 'and trading name has advisers' do
|
378
|
+
before :each do
|
379
|
+
expect(parent_firm.advisers.any?).to eql(false)
|
380
|
+
create(:adviser, firm: trading_name)
|
381
|
+
end
|
382
|
+
|
383
|
+
it 'returns :onboarded' do
|
384
|
+
expect(principal.next_onboarding_action).to eql(:onboarded)
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
context 'and both firms have advisers' do
|
389
|
+
before :each do
|
390
|
+
create(:adviser, firm: parent_firm)
|
391
|
+
create(:adviser, firm: trading_name)
|
392
|
+
end
|
393
|
+
|
394
|
+
it 'returns :onboarded' do
|
395
|
+
expect(principal.next_onboarding_action).to eql(:onboarded)
|
396
|
+
end
|
397
|
+
end
|
398
|
+
end
|
399
|
+
end
|
400
|
+
end
|
205
401
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
##
|
2
|
+
# Needs:
|
3
|
+
# principal = instance of Principal with two firms attached (parent_firm and trading_name)
|
4
|
+
# parent_firm = an instance of Firm with the same FCA Number as the Principal but no parent firm
|
5
|
+
# trading_name = an instance of Firm with the same FCA Number as the Principal and the parent_firm as the parent firm
|
6
|
+
RSpec.shared_examples 'at least one remote firm' do
|
7
|
+
context 'and neither firm has advisers' do
|
8
|
+
before :each do
|
9
|
+
expect(parent_firm.advisers.any?).to eql(false)
|
10
|
+
expect(trading_name.advisers.any?).to eql(false)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'returns :onboarded' do
|
14
|
+
expect(principal.next_onboarding_action).to eql(:onboarded)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'and the parent firm has advisers' do
|
19
|
+
before :each do
|
20
|
+
create(:adviser, firm: parent_firm)
|
21
|
+
expect(trading_name.advisers.any?).to eql(false)
|
22
|
+
principal.reload
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns :onboarded' do
|
26
|
+
expect(principal.next_onboarding_action).to eql(:onboarded)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'and the trading name has advisers' do
|
31
|
+
before :each do
|
32
|
+
expect(parent_firm.advisers.any?).to eql(false)
|
33
|
+
create(:adviser, firm: trading_name)
|
34
|
+
principal.reload
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'returns :onboarded' do
|
38
|
+
expect(principal.next_onboarding_action).to eql(:onboarded)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'and both firms have advisers' do
|
43
|
+
before :each do
|
44
|
+
create(:adviser, firm: parent_firm)
|
45
|
+
create(:adviser, firm: trading_name)
|
46
|
+
principal.reload
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'returns :onboarded' do
|
50
|
+
expect(principal.next_onboarding_action).to eql(:onboarded)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mas-rad_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.66
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Lovell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -385,6 +385,7 @@ files:
|
|
385
385
|
- spec/serializers/adviser_serializer_spec.rb
|
386
386
|
- spec/serializers/firm_serializer_spec.rb
|
387
387
|
- spec/spec_helper.rb
|
388
|
+
- spec/support/shared_examples/at_least_one_remote_firm.rb
|
388
389
|
- spec/support/shared_examples/friendly_named.rb
|
389
390
|
- spec/support/shared_examples/geocodable_examples.rb
|
390
391
|
- spec/support/shared_examples/reference_data.rb
|
@@ -504,6 +505,7 @@ test_files:
|
|
504
505
|
- spec/serializers/adviser_serializer_spec.rb
|
505
506
|
- spec/serializers/firm_serializer_spec.rb
|
506
507
|
- spec/spec_helper.rb
|
508
|
+
- spec/support/shared_examples/at_least_one_remote_firm.rb
|
507
509
|
- spec/support/shared_examples/friendly_named.rb
|
508
510
|
- spec/support/shared_examples/geocodable_examples.rb
|
509
511
|
- spec/support/shared_examples/reference_data.rb
|