mas-rad_core 0.0.35 → 0.0.36

Sign up to get free protection for your applications and to get access to all the features.
@@ -106,10 +106,6 @@ RSpec.describe FirmResult do
106
106
  expect(subject.total_advisers).to eq(1)
107
107
  end
108
108
 
109
- it 'maps the `closest_adviser`' do
110
- expect(subject.closest_adviser).to eq(0.7794549719530739)
111
- end
112
-
113
109
  it 'maps the `types_of_advice` that are greater than 0 percent' do
114
110
  expect(subject.types_of_advice).to eq(
115
111
  FirmResult::TYPES_OF_ADVICE_FIELDS - [:wills_and_probate]
@@ -136,11 +132,26 @@ RSpec.describe FirmResult do
136
132
  expect(subject.adviser_qualification_ids).to eq([3])
137
133
  end
138
134
 
139
- context 'when sorted by types of advice first' do
140
- before { data['sort'].unshift(123) }
135
+ describe '#closest_adviser' do
136
+ let(:text) { 'less than a mile away' }
137
+
138
+ before do
139
+ I18n.backend.store_translations :en,
140
+ search: { result: { miles_away_alt: text, miles_away: 'miles away' } }
141
+ end
142
+
143
+ context 'when it is less than 1 mile away' do
144
+ it 'returns `less than a mile away` localised text' do
145
+ expect(subject.closest_adviser).to eq(text)
146
+ end
147
+ end
148
+
149
+ context 'when it is a mile away or more' do
150
+ before { data['sort'] = [1.23456789] }
141
151
 
142
- it 'maps the `closest_adviser`' do
143
- expect(subject.closest_adviser).to eq(0.7794549719530739)
152
+ it 'returns the formatted distance' do
153
+ expect(subject.closest_adviser).to eq('1.2 miles away')
154
+ end
144
155
  end
145
156
  end
146
157
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mas-rad_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.35
4
+ version: 0.0.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Lovell