mas-rad_core 0.0.53 → 0.0.54

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.
@@ -30,8 +30,10 @@ FactoryGirl.define do
30
30
  latitude { Faker::Address.latitude.to_f.round(6) }
31
31
  longitude { Faker::Address.longitude.to_f.round(6) }
32
32
 
33
- factory :subsidiary do
33
+ factory :trading_name do
34
34
  parent factory: Firm
35
+
36
+ factory :subsidiary
35
37
  end
36
38
 
37
39
  factory :firm_with_no_business_split do
@@ -48,8 +50,10 @@ FactoryGirl.define do
48
50
  advisers { create_list(:adviser, 3) }
49
51
  end
50
52
 
51
- factory :firm_with_subsidiaries do
52
- subsidiaries { create_list(:subsidiary, 3, fca_number: fca_number) }
53
+ factory :firm_with_trading_names do
54
+ subsidiaries { create_list(:trading_name, 3, fca_number: fca_number) }
55
+
56
+ factory :firm_with_subsidiaries
53
57
  end
54
58
 
55
59
  factory :firm_with_principal do
@@ -284,7 +284,7 @@ RSpec.describe Firm do
284
284
  end
285
285
 
286
286
  context 'when the firm has subsidiaries' do
287
- let(:firm) { create(:firm_with_subsidiaries) }
287
+ let(:firm) { create(:firm_with_trading_names) }
288
288
 
289
289
  it 'cascades destroy to subsidiaries' do
290
290
  subsidiary = firm.subsidiaries.first
@@ -297,11 +297,11 @@ RSpec.describe Firm do
297
297
  context 'when the firm has a principal' do
298
298
  let(:firm) { create(:firm_with_principal) }
299
299
 
300
- it 'cascades destroy to principal' do
300
+ it 'does not destroy the principal' do
301
301
  principal = firm.principal
302
302
  firm.destroy
303
303
  firm.run_callbacks(:commit)
304
- expect(Principal.where(token: principal.id)).to be_empty
304
+ expect(Principal.where(token: principal.id)).not_to be_empty
305
305
  end
306
306
  end
307
307
 
@@ -204,4 +204,12 @@ RSpec.describe Principal do
204
204
  expect(principal.field_order).to contain_exactly(*fields)
205
205
  end
206
206
  end
207
+
208
+ describe '#destroy' do
209
+ it 'cascades to the firm' do
210
+ firm = principal.firm
211
+ principal.destroy
212
+ expect(Firm.where(id: firm.id)).to be_empty
213
+ end
214
+ end
207
215
  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.53
4
+ version: 0.0.54
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-06-02 00:00:00.000000000 Z
11
+ date: 2015-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails