mas-rad_core 0.0.95 → 0.0.96

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,6 +13,7 @@ FactoryGirl.define do
13
13
  latitude { Faker::Address.latitude.to_f.round(6) }
14
14
  longitude { Faker::Address.longitude.to_f.round(6) }
15
15
  firm factory: :firm_without_advisers
16
+ bypass_reference_number_check false
16
17
 
17
18
  after(:build) do |a, evaluator|
18
19
  if a.reference_number? && evaluator.create_linked_lookup_advisor
@@ -1,10 +1,4 @@
1
1
  RSpec.describe Adviser do
2
- include QueueSpecHelper
3
-
4
- before do
5
- clear_job_queue
6
- end
7
-
8
2
  describe 'before validation' do
9
3
  context 'when a reference number is present' do
10
4
  let(:attributes) { attributes_for(:adviser) }
@@ -17,10 +11,24 @@ RSpec.describe Adviser do
17
11
  )
18
12
  end
19
13
 
20
- it 'assigns #name from the lookup Adviser data' do
21
- adviser.validate
14
+ context 'when a name is not present' do
15
+ before do
16
+ adviser.name = nil
17
+ end
18
+
19
+ it 'assigns #name from the lookup Adviser data' do
20
+ adviser.validate
21
+
22
+ expect(adviser.name).to eq('Mr. Welp')
23
+ end
24
+ end
25
+
26
+ context 'when a name is present' do
27
+ it 'does not override the existing name' do
28
+ adviser.validate
22
29
 
23
- expect(adviser.name).to eq('Mr. Welp')
30
+ expect(adviser.name).not_to eq('Mr. Welp')
31
+ end
24
32
  end
25
33
  end
26
34
  end
@@ -57,39 +65,47 @@ RSpec.describe Adviser do
57
65
  end
58
66
 
59
67
  describe 'reference number' do
60
- it 'is required' do
61
- expect(build(:adviser, reference_number: nil)).to_not be_valid
68
+ context 'when `bypass_reference_number_check` is true' do
69
+ it 'is not required' do
70
+ expect(build(:adviser, bypass_reference_number_check: true, reference_number: nil)).to be_valid
71
+ end
62
72
  end
63
73
 
64
- it 'must be three characters and five digits exactly' do
65
- %w(badtimes ABCDEFGH 8008135! 12345678).each do |bad|
66
- Lookup::Adviser.create!(reference_number: bad, name: 'Mr. Derp')
67
-
68
- expect(build(:adviser,
69
- reference_number: bad,
70
- create_linked_lookup_advisor: false)).to_not be_valid
74
+ context 'when `bypass_reference_number_check` is false' do
75
+ it 'is required' do
76
+ expect(build(:adviser, reference_number: nil)).to_not be_valid
71
77
  end
72
- end
73
78
 
74
- it 'must be matched to the lookup data' do
75
- build(:adviser, reference_number: 'ABC12345').tap do |a|
76
- Lookup::Adviser.delete_all
79
+ it 'must be three characters and five digits exactly' do
80
+ %w(badtimes ABCDEFGH 8008135! 12345678).each do |bad|
81
+ Lookup::Adviser.create!(reference_number: bad, name: 'Mr. Derp')
77
82
 
78
- expect(a).to_not be_valid
83
+ expect(build(:adviser,
84
+ reference_number: bad,
85
+ create_linked_lookup_advisor: false)).to_not be_valid
86
+ end
79
87
  end
80
- end
81
88
 
82
- context 'when an adviser with the same reference number already exists' do
83
- let(:reference_number) { 'ABC12345' }
89
+ it 'must be matched to the lookup data' do
90
+ build(:adviser, reference_number: 'ABC12345').tap do |a|
91
+ Lookup::Adviser.delete_all
84
92
 
85
- before do
86
- create(:adviser, reference_number: reference_number)
93
+ expect(a).to_not be_valid
94
+ end
87
95
  end
88
96
 
89
- it 'must not be valid' do
90
- expect(build(:adviser,
91
- reference_number: reference_number,
92
- create_linked_lookup_advisor: false)).to_not be_valid
97
+ context 'when an adviser with the same reference number already exists' do
98
+ let(:reference_number) { 'ABC12345' }
99
+
100
+ before do
101
+ create(:adviser, reference_number: reference_number)
102
+ end
103
+
104
+ it 'must not be valid' do
105
+ expect(build(:adviser,
106
+ reference_number: reference_number,
107
+ create_linked_lookup_advisor: false)).to_not be_valid
108
+ end
93
109
  end
94
110
  end
95
111
  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.95
4
+ version: 0.0.96
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-11-20 00:00:00.000000000 Z
11
+ date: 2016-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -307,6 +307,7 @@ files:
307
307
  - db/migrate/20151102113518_add_default_value_to_minimum_fixed_fee.rb
308
308
  - db/migrate/20151103161642_add_latitude_and_longitude_to_office.rb
309
309
  - db/migrate/20151111132037_remove_latitude_and_longitude_from_firm.rb
310
+ - db/migrate/20160205150033_add_bypass_reference_number_check_to_advisers.rb
310
311
  - lib/mas/adviser_result.rb
311
312
  - lib/mas/elastic_search_client.rb
312
313
  - lib/mas/firm_indexer.rb
@@ -356,6 +357,8 @@ files:
356
357
  - spec/dummy/config/routes.rb
357
358
  - spec/dummy/config/secrets.yml
358
359
  - spec/dummy/db/schema.rb
360
+ - spec/dummy/log/development.log
361
+ - spec/dummy/log/test.log
359
362
  - spec/dummy/public/404.html
360
363
  - spec/dummy/public/422.html
361
364
  - spec/dummy/public/500.html
@@ -480,6 +483,8 @@ test_files:
480
483
  - spec/dummy/config/secrets.yml
481
484
  - spec/dummy/config.ru
482
485
  - spec/dummy/db/schema.rb
486
+ - spec/dummy/log/development.log
487
+ - spec/dummy/log/test.log
483
488
  - spec/dummy/public/404.html
484
489
  - spec/dummy/public/422.html
485
490
  - spec/dummy/public/500.html