]> git.openstreetmap.org Git - rails.git/commitdiff
Test Last-Modified header of api show element responses
authorAnton Khorev <tony29@yandex.ru>
Sat, 1 Feb 2025 15:29:14 +0000 (18:29 +0300)
committerAnton Khorev <tony29@yandex.ru>
Wed, 5 Feb 2025 17:22:16 +0000 (20:22 +0300)
test/controllers/api/nodes_controller_test.rb
test/controllers/api/relations_controller_test.rb
test/controllers/api/ways_controller_test.rb

index 2317d6be6290b54ec91305a37d2c98f232b9f97b..523498216884c42925739dddc5fda1d1e86faf14 100644 (file)
@@ -204,8 +204,13 @@ module Api
     end
 
     def test_show
     end
 
     def test_show
-      get api_node_path(create(:node))
+      node = create(:node, :timestamp => "2021-02-03T00:00:00Z")
+
+      get api_node_path(node)
+
       assert_response :success
       assert_response :success
+      assert_not_nil @response.header["Last-Modified"]
+      assert_equal "2021-02-03T00:00:00Z", Time.parse(@response.header["Last-Modified"]).utc.xmlschema
     end
 
     # Ensure the lat/lon is formatted as a decimal e.g. not 4.0e-05
     end
 
     # Ensure the lat/lon is formatted as a decimal e.g. not 4.0e-05
index ad7ce11b0f9fc74766870b0745728d5bef603de8..34953f7b7ac62841a1e27002ab383a9130393574 100644 (file)
@@ -133,13 +133,15 @@ module Api
     end
 
     def test_show
     end
 
     def test_show
-      relation = create(:relation)
-      node = create(:node)
+      relation = create(:relation, :timestamp => "2021-02-03T00:00:00Z")
+      node = create(:node, :timestamp => "2021-04-05T00:00:00Z")
       create(:relation_member, :relation => relation, :member => node)
 
       get api_relation_path(relation)
 
       assert_response :success
       create(:relation_member, :relation => relation, :member => node)
 
       get api_relation_path(relation)
 
       assert_response :success
+      assert_not_nil @response.header["Last-Modified"]
+      assert_equal "2021-02-03T00:00:00Z", Time.parse(@response.header["Last-Modified"]).utc.xmlschema
       assert_dom "node", :count => 0
       assert_dom "relation", :count => 1 do
         assert_dom "> @id", :text => relation.id.to_s
       assert_dom "node", :count => 0
       assert_dom "relation", :count => 1 do
         assert_dom "> @id", :text => relation.id.to_s
index 45feef7e02802d81dd9f329cbb73660cb2245d35..2ff5e6f29f786a94b3c7080535fcc371ce9150d3 100644 (file)
@@ -107,8 +107,15 @@ module Api
     end
 
     def test_show
     end
 
     def test_show
-      get api_way_path(create(:way))
+      way = create(:way, :timestamp => "2021-02-03T00:00:00Z")
+      node = create(:node, :timestamp => "2021-04-05T00:00:00Z")
+      create(:way_node, :way => way, :node => node)
+
+      get api_way_path(way)
+
       assert_response :success
       assert_response :success
+      assert_not_nil @response.header["Last-Modified"]
+      assert_equal "2021-02-03T00:00:00Z", Time.parse(@response.header["Last-Modified"]).utc.xmlschema
     end
 
     def test_show_json
     end
 
     def test_show_json