From: Anton Khorev Date: Sat, 1 Feb 2025 15:29:14 +0000 (+0300) Subject: Test Last-Modified header of api show element responses X-Git-Tag: live~67^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/e837727d9544c178eabd79fe2e8f37d039ccd7c5?hp=-c Test Last-Modified header of api show element responses --- e837727d9544c178eabd79fe2e8f37d039ccd7c5 diff --git a/test/controllers/api/nodes_controller_test.rb b/test/controllers/api/nodes_controller_test.rb index 2317d6be6..523498216 100644 --- a/test/controllers/api/nodes_controller_test.rb +++ b/test/controllers/api/nodes_controller_test.rb @@ -204,8 +204,13 @@ module Api 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_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 diff --git a/test/controllers/api/relations_controller_test.rb b/test/controllers/api/relations_controller_test.rb index ad7ce11b0..34953f7b7 100644 --- a/test/controllers/api/relations_controller_test.rb +++ b/test/controllers/api/relations_controller_test.rb @@ -133,13 +133,15 @@ module Api 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 + 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 diff --git a/test/controllers/api/ways_controller_test.rb b/test/controllers/api/ways_controller_test.rb index 45feef7e0..2ff5e6f29 100644 --- a/test/controllers/api/ways_controller_test.rb +++ b/test/controllers/api/ways_controller_test.rb @@ -107,8 +107,15 @@ module Api 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_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