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 --- lib/route_way_cost_unit_converter.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/route_way_cost_unit_converter.rb b/lib/route_way_cost_unit_converter.rb index 1aebbbb14..979e92b0c 100644 --- a/lib/route_way_cost_unit_converter.rb +++ b/lib/route_way_cost_unit_converter.rb @@ -10,8 +10,9 @@ class RouteWayCostUnitConverter private + # Round to 2 decimal places to appease JavaScript validation def self.meters_to_kilometers(num) - num / 1000.0 + (num / 1000.0).round(2) end def self.seconds_to_minutes(num) -- cgit v1.2.3