diff options
| author | Alban Peignier | 2018-05-16 15:42:24 +0200 | 
|---|---|---|
| committer | GitHub | 2018-05-16 15:42:24 +0200 | 
| commit | 223d988ef59e562b201cac8391c397630c8953e5 (patch) | |
| tree | ecb43cdf1e461e621f8e5c22c5e5fdc2cd70b18d /spec/services | |
| parent | 6f4d2a1954fa3b127785127e30f757f654fe20c7 (diff) | |
| parent | 9c442cd66c7d12266ba53e85949f775f6b842d2d (diff) | |
| download | chouette-core-223d988ef59e562b201cac8391c397630c8953e5.tar.bz2 | |
Merge pull request #553 from af83/6884-tomtom-matrix--handle-error-when-response-doesn,t-inclu
Handle API error(s) in Tomtom matrix. Fixes #6884
Diffstat (limited to 'spec/services')
| -rw-r--r-- | spec/services/route_way_cost_calculator_spec.rb | 25 | 
1 files changed, 25 insertions, 0 deletions
| diff --git a/spec/services/route_way_cost_calculator_spec.rb b/spec/services/route_way_cost_calculator_spec.rb index d11db2950..aa6195196 100644 --- a/spec/services/route_way_cost_calculator_spec.rb +++ b/spec/services/route_way_cost_calculator_spec.rb @@ -31,5 +31,30 @@ RSpec.describe RouteWayCostCalculator do        expect(route.costs).not_to be_nil        expect { JSON.parse(JSON.dump(route.costs)) }.not_to raise_error      end + +    it "doesn't update route costs when there is a server error" do +      route = create(:route) + +      stub_request( +        :post, +        "https://api.tomtom.com/routing/1/matrix/json?key&routeType=shortest&travelMode=bus" +      ) +        .with( +          headers: { +            'Accept'=>'*/*', +            'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', +            'Content-Type'=>'application/json', +            'User-Agent'=>'Faraday v0.9.2' +          }) +        .to_return( +          status: 200, +          body: "{\"formatVersion\":\"0.0.1\",\"error\":{\"description\":\"Outputformat:csvisunsupported.\"}}", +          headers: {} +        ) + +      RouteWayCostCalculator.new(route).calculate! + +      expect(route.costs).to be_nil +    end    end  end | 
