mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-06 05:09:40 -06:00
Make sure geocoder errors are reported
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -31,7 +31,6 @@ gem 'rexml'
|
||||
gem 'rgeo'
|
||||
gem 'rgeo-activerecord'
|
||||
gem 'rgeo-geojson'
|
||||
gem 'parallel'
|
||||
gem 'rswag-api'
|
||||
gem 'rswag-ui'
|
||||
gem 'sentry-ruby'
|
||||
|
||||
@@ -506,7 +506,6 @@ DEPENDENCIES
|
||||
kaminari
|
||||
lograge
|
||||
oj
|
||||
parallel
|
||||
pg
|
||||
prometheus_exporter
|
||||
pry-byebug
|
||||
|
||||
@@ -80,5 +80,17 @@ RSpec.describe Trips::Countries do
|
||||
expect(result.keys.first).to eq('DE')
|
||||
expect(result['DE']).to eq(2)
|
||||
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
|
||||
|
||||
@@ -4,27 +4,19 @@
|
||||
RSpec.configure do |config|
|
||||
config.before(:each) do
|
||||
# Create a generic stub for all Geocoder requests
|
||||
stub_request(:any, %r{photon\.dawarich\.app/reverse}).to_return(
|
||||
status: 200,
|
||||
body: {
|
||||
type: 'FeatureCollection',
|
||||
features: [
|
||||
{
|
||||
type: 'Feature',
|
||||
properties: {
|
||||
name: 'Test Location',
|
||||
countrycode: 'US',
|
||||
country: 'United States',
|
||||
state: 'New York'
|
||||
},
|
||||
geometry: {
|
||||
coordinates: [-73.9, 40.7],
|
||||
type: 'Point'
|
||||
allow(Geocoder).to receive(:search).and_return(
|
||||
[
|
||||
double(
|
||||
data: {
|
||||
'properties' => {
|
||||
'countrycode' => 'US',
|
||||
'country' => 'United States',
|
||||
'state' => 'New York',
|
||||
'name' => 'Test Location'
|
||||
}
|
||||
}
|
||||
]
|
||||
}.to_json,
|
||||
headers: { 'Content-Type' => 'application/json' }
|
||||
)
|
||||
]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user