]> git.openstreetmap.org Git - rails.git/commitdiff
Split api way show test
authorAnton Khorev <tony29@yandex.ru>
Sat, 1 Feb 2025 15:04:35 +0000 (18:04 +0300)
committerAnton Khorev <tony29@yandex.ru>
Wed, 5 Feb 2025 17:22:16 +0000 (20:22 +0300)
test/controllers/api/ways_controller_test.rb

index 5bea98bbdb7d7df8deaa174e2a7a352c168492b0..45feef7e02802d81dd9f329cbb73660cb2245d35 100644 (file)
@@ -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
 
     ##