mas-rad_core 0.0.12 → 0.0.13
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/jobs/geocode_adviser_job.rb +10 -3
- data/app/models/adviser.rb +5 -7
- data/app/models/geocodable.rb +4 -0
- data/app/serializers/firm_serializer.rb +4 -0
- data/lib/mas/rad_core/version.rb +1 -1
- data/spec/dummy/log/test.log +146883 -0
- data/spec/jobs/geocode_adviser_job_spec.rb +13 -3
- data/spec/models/adviser_spec.rb +0 -18
- data/spec/serializers/firm_serializer_spec.rb +8 -4
- metadata +2 -2
@@ -7,12 +7,21 @@ RSpec.describe GeocodeAdviserJob do
|
|
7
7
|
context 'when the adviser postcode can be geocoded' do
|
8
8
|
let(:postcode) { 'EC1N 2TD' }
|
9
9
|
|
10
|
-
|
10
|
+
subject do
|
11
11
|
VCR.use_cassette('postcode-one-result') do
|
12
|
-
expect(adviser).to receive(:geocode!).with([51.5180697, -0.1085203])
|
13
12
|
job.perform(adviser)
|
14
13
|
end
|
15
14
|
end
|
15
|
+
|
16
|
+
it 'the adviser is geocoded with the coordinates' do
|
17
|
+
subject
|
18
|
+
|
19
|
+
expect(adviser.coordinates).to contain_exactly(51.51807, -0.10852)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'schedules the indexing' do
|
23
|
+
expect { subject }.to change { ActiveJob::Base.queue_adapter.enqueued_jobs.size }.by(1)
|
24
|
+
end
|
16
25
|
end
|
17
26
|
|
18
27
|
context 'when adviser postcode cannot be geocoded' do
|
@@ -20,8 +29,9 @@ RSpec.describe GeocodeAdviserJob do
|
|
20
29
|
|
21
30
|
it 'the latitude and longitude are set to nil' do
|
22
31
|
VCR.use_cassette('postcode-no-results') do
|
23
|
-
expect(adviser).to receive(:geocode!).with(nil)
|
24
32
|
job.perform(adviser)
|
33
|
+
|
34
|
+
expect(adviser.coordinates).to contain_exactly(nil, nil)
|
25
35
|
end
|
26
36
|
end
|
27
37
|
end
|
data/spec/models/adviser_spec.rb
CHANGED
@@ -13,24 +13,6 @@ RSpec.describe Adviser do
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
describe 'scheduling the parent firm for indexing' do
|
17
|
-
context 'when the adviser has not been geocoded' do
|
18
|
-
it 'does not schedule the job' do
|
19
|
-
expect do
|
20
|
-
create(:adviser, latitude: nil, longitude: nil)
|
21
|
-
end.not_to change { ActiveJob::Base.queue_adapter.enqueued_jobs.size }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'when the adviser has been geocoded' do
|
26
|
-
it 'schedules the job' do
|
27
|
-
expect do
|
28
|
-
create(:adviser)
|
29
|
-
end.to change { ActiveJob::Base.queue_adapter.enqueued_jobs.size }.by(1)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
16
|
describe 'before validation' do
|
35
17
|
context 'when a reference number is present' do
|
36
18
|
let(:attributes) { attributes_for(:adviser) }
|
@@ -16,10 +16,6 @@ RSpec.describe FirmSerializer do
|
|
16
16
|
expect(subject[:postcode_searchable]).to eql(firm.postcode_searchable?)
|
17
17
|
end
|
18
18
|
|
19
|
-
it 'exposes the `advisers` association' do
|
20
|
-
expect(subject[:advisers]).to be
|
21
|
-
end
|
22
|
-
|
23
19
|
it 'exposes `options_when_paying_for_care`' do
|
24
20
|
expect(subject[:options_when_paying_for_care]).to be
|
25
21
|
end
|
@@ -40,5 +36,13 @@ RSpec.describe FirmSerializer do
|
|
40
36
|
expect(subject[:other_advice_methods]).
|
41
37
|
to eql(firm.other_advice_method_ids)
|
42
38
|
end
|
39
|
+
|
40
|
+
describe 'advisers' do
|
41
|
+
before { create(:adviser, firm: firm, latitude: nil, longitude: nil) }
|
42
|
+
|
43
|
+
it 'only includes geocoded records' do
|
44
|
+
expect(subject[:advisers].count).to eq(1)
|
45
|
+
end
|
46
|
+
end
|
43
47
|
end
|
44
48
|
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.13
|
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-03-
|
11
|
+
date: 2015-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|