Offline routing phase 2: route panel, /api/route via Valhalla, vehicle profile, save a route to the library

This commit is contained in:
randy committed 2026-11-13 22:34:47 +01:00
1 parent d93c77727f
commit 3146478c23
11 files changed
+577 -12

No files matched your search

+15
View File
@@ -230,6 +230,21 @@ class AppTest < Minitest::Test
assert_equal 409, request.patch("/api/library/folder/Van", params: { name: "Bus" }, **logged_in_env).status
end
def test_routing_without_a_valhalla_service_says_so
assert_equal 503, request.post("/api/route", input: JSON.generate(locations: [[17.1, 48.1], [17.2, 48.2]]), "CONTENT_TYPE" => "application/json").status
assert_equal 400, request.post("/api/route", input: JSON.generate(locations: "x"), "CONTENT_TYPE" => "application/json").status
end
def test_the_vehicle_is_readable_by_anyone_but_saved_only_when_logged_in
assert_equal 3.0, json_body(request.get("/api/vehicle"))["height"]
vehicle = { height: 3.3, width: 2.3, length: 7, weight: 3.5 }
assert_equal 401, request.put("/api/vehicle", params: vehicle).status
assert_equal 3.3, json_body(request.put("/api/vehicle", params: vehicle, **logged_in_env))["height"]
assert_equal 400, request.put("/api/vehicle", params: vehicle.merge(weight: 0), **logged_in_env).status
ensure
FileUtils.rm_f(File.join(Maptool::App::DATA_DIR, "vehicle.json"))
end
def test_invalid_folder_path_is_rejected
assert_equal 400, request.post("/api/library/folder?path=..%2F..%2Fescape", **logged_in_env).status
end