From 1a9656e9d69d598cd1239c372f1002d21ec73d09 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 15 Mar 2018 17:40:17 +0100 Subject: RouteWayCostUnitConverter: Round kilometres to 2 decimal places The JavaScript validation doesn't pass if we have more than two decimal places (I think because it uses a number field step value of 0.01). Round the values to allow them to pass frontend validation. Refs #6203 --- spec/lib/route_way_cost_unit_converter_spec.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'spec/lib') diff --git a/spec/lib/route_way_cost_unit_converter_spec.rb b/spec/lib/route_way_cost_unit_converter_spec.rb index 33fb1d9aa..624ef5052 100644 --- a/spec/lib/route_way_cost_unit_converter_spec.rb +++ b/spec/lib/route_way_cost_unit_converter_spec.rb @@ -1,6 +1,7 @@ RSpec.describe RouteWayCostUnitConverter do describe ".convert" do - it "converts distance from meters to km and time from seconds to minutes" do + it "converts distance from meters to km and time from seconds to minutes " \ + "and rounds to two decimal places" do costs = { '1-2' => { 'distance' => 35223, @@ -16,11 +17,11 @@ RSpec.describe RouteWayCostUnitConverter do RouteWayCostUnitConverter.convert(costs) ).to eq({ '1-2' => { - 'distance' => 35.223, + 'distance' => 35.22, 'time' => 93 }, '94435-97513' => { - 'distance' => 35.919, + 'distance' => 35.92, 'time' => 102 } }) -- cgit v1.2.3