mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Make sure geocoder errors are reported
This commit is contained in:
parent
556af7fd02
commit
5fbc1fb884
4 changed files with 23 additions and 21 deletions
1
Gemfile
1
Gemfile
|
|
@ -31,7 +31,6 @@ gem 'rexml'
|
||||||
gem 'rgeo'
|
gem 'rgeo'
|
||||||
gem 'rgeo-activerecord'
|
gem 'rgeo-activerecord'
|
||||||
gem 'rgeo-geojson'
|
gem 'rgeo-geojson'
|
||||||
gem 'parallel'
|
|
||||||
gem 'rswag-api'
|
gem 'rswag-api'
|
||||||
gem 'rswag-ui'
|
gem 'rswag-ui'
|
||||||
gem 'sentry-ruby'
|
gem 'sentry-ruby'
|
||||||
|
|
|
||||||
|
|
@ -506,7 +506,6 @@ DEPENDENCIES
|
||||||
kaminari
|
kaminari
|
||||||
lograge
|
lograge
|
||||||
oj
|
oj
|
||||||
parallel
|
|
||||||
pg
|
pg
|
||||||
prometheus_exporter
|
prometheus_exporter
|
||||||
pry-byebug
|
pry-byebug
|
||||||
|
|
|
||||||
|
|
@ -80,5 +80,17 @@ RSpec.describe Trips::Countries do
|
||||||
expect(result.keys.first).to eq('DE')
|
expect(result.keys.first).to eq('DE')
|
||||||
expect(result['DE']).to eq(2)
|
expect(result['DE']).to eq(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when an error occurs' do
|
||||||
|
before do
|
||||||
|
allow(Geocoder).to receive(:search).and_raise(Geocoder::Error, 'Error')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'calls the exception reporter' do
|
||||||
|
expect(ExceptionReporter).to receive(:call).with(Geocoder::Error).at_least(3).times
|
||||||
|
|
||||||
|
described_class.new(trip).call
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,27 +4,19 @@
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.before(:each) do
|
config.before(:each) do
|
||||||
# Create a generic stub for all Geocoder requests
|
# Create a generic stub for all Geocoder requests
|
||||||
stub_request(:any, %r{photon\.dawarich\.app/reverse}).to_return(
|
allow(Geocoder).to receive(:search).and_return(
|
||||||
status: 200,
|
[
|
||||||
body: {
|
double(
|
||||||
type: 'FeatureCollection',
|
data: {
|
||||||
features: [
|
'properties' => {
|
||||||
{
|
'countrycode' => 'US',
|
||||||
type: 'Feature',
|
'country' => 'United States',
|
||||||
properties: {
|
'state' => 'New York',
|
||||||
name: 'Test Location',
|
'name' => 'Test Location'
|
||||||
countrycode: 'US',
|
|
||||||
country: 'United States',
|
|
||||||
state: 'New York'
|
|
||||||
},
|
|
||||||
geometry: {
|
|
||||||
coordinates: [-73.9, 40.7],
|
|
||||||
type: 'Point'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
)
|
||||||
]
|
]
|
||||||
}.to_json,
|
|
||||||
headers: { 'Content-Type' => 'application/json' }
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue