From: Anton Khorev Date: Sat, 1 Feb 2025 15:04:35 +0000 (+0300) Subject: Split api way show test X-Git-Tag: live~108^2~3 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/cc2677ff241b20b853ca4b5eae9627904028db0e?hp=-c Split api way show test --- cc2677ff241b20b853ca4b5eae9627904028db0e diff --git a/test/controllers/api/ways_controller_test.rb b/test/controllers/api/ways_controller_test.rb index 5bea98bbd..45feef7e0 100644 --- a/test/controllers/api/ways_controller_test.rb +++ b/test/controllers/api/ways_controller_test.rb @@ -96,18 +96,35 @@ module Api # Test showing ways. # ------------------------------------- + def test_show_not_found + get api_way_path(0) + assert_response :not_found + end + + def test_show_deleted + get api_way_path(create(:way, :deleted)) + assert_response :gone + end + def test_show - # check that a visible way is returned properly get api_way_path(create(:way)) assert_response :success + end - # check that an invisible way is not returned - get api_way_path(create(:way, :deleted)) - assert_response :gone + def test_show_json + way = create(:way_with_nodes, :nodes_count => 3) - # check chat a non-existent way is not returned - get api_way_path(0) - assert_response :not_found + get api_way_path(way, :format => "json") + + assert_response :success + + js = ActiveSupport::JSON.decode(@response.body) + assert_not_nil js + assert_equal 1, js["elements"].count + js_ways = js["elements"].filter { |e| e["type"] == "way" } + assert_equal 1, js_ways.count + assert_equal way.id, js_ways[0]["id"] + assert_equal 1, js_ways[0]["version"] end ##