From: Anton Khorev Date: Mon, 10 Feb 2025 14:58:46 +0000 (+0300) Subject: Use fewer element versions in redaction tests X-Git-Tag: live~151^2~5 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/ef9d39ece0cc0e455e9494d81cef4f9e185cafdc Use fewer element versions in redaction tests --- diff --git a/test/controllers/api/old_nodes_controller_test.rb b/test/controllers/api/old_nodes_controller_test.rb index 9aa6fdce9..bddc6bc24 100644 --- a/test/controllers/api/old_nodes_controller_test.rb +++ b/test/controllers/api/old_nodes_controller_test.rb @@ -213,11 +213,11 @@ module Api # test that, even as moderator, the current version of a node # can't be redacted. def test_redact_node_current_version - node = create(:node, :with_history, :version => 4) + node = create(:node, :with_history, :version => 2) redaction = create(:redaction) auth_header = bearer_authorization_header create(:moderator_user) - post node_version_redact_path(node, 4), :params => { :redaction => redaction.id }, :headers => auth_header + post node_version_redact_path(node, 2), :params => { :redaction => redaction.id }, :headers => auth_header assert_response :bad_request, "shouldn't be OK to redact current version as moderator." end @@ -250,17 +250,17 @@ module Api # test the redaction of an old version of a node, while being # authorised as a moderator. def test_redact_node_moderator - node = create(:node, :with_history, :version => 4) - node_v3 = node.old_nodes.find_by(:version => 3) + node = create(:node, :with_history, :version => 2) + node_v1 = node.old_nodes.find_by(:version => 1) redaction = create(:redaction) auth_header = bearer_authorization_header create(:moderator_user) - post node_version_redact_path(*node_v3.id), :params => { :redaction => redaction.id }, :headers => auth_header + post node_version_redact_path(*node_v1.id), :params => { :redaction => redaction.id }, :headers => auth_header assert_response :success, "should be OK to redact old version as moderator." - node_v3.reload - assert_predicate node_v3, :redacted? - assert_equal redaction, node_v3.redaction + node_v1.reload + assert_predicate node_v1, :redacted? + assert_equal redaction, node_v1.redaction end ## @@ -331,10 +331,10 @@ module Api private def do_redact_redactable_node(headers = {}) - node = create(:node, :with_history, :version => 4) + node = create(:node, :with_history, :version => 2) redaction = create(:redaction) - post node_version_redact_path(node, 3), :params => { :redaction => redaction.id }, :headers => headers + post node_version_redact_path(node, 1), :params => { :redaction => redaction.id }, :headers => headers end def check_not_found_id_version(id, version) diff --git a/test/controllers/api/old_relations_controller_test.rb b/test/controllers/api/old_relations_controller_test.rb index e03b55260..d7aa923ec 100644 --- a/test/controllers/api/old_relations_controller_test.rb +++ b/test/controllers/api/old_relations_controller_test.rb @@ -204,11 +204,11 @@ module Api # test that, even as moderator, the current version of a relation # can't be redacted. def test_redact_relation_current_version - relation = create(:relation, :with_history, :version => 4) + relation = create(:relation, :with_history, :version => 2) redaction = create(:redaction) auth_header = bearer_authorization_header create(:moderator_user) - post relation_version_redact_path(relation, 4), :params => { :redaction => redaction.id }, :headers => auth_header + post relation_version_redact_path(relation, 2), :params => { :redaction => redaction.id }, :headers => auth_header assert_response :bad_request, "shouldn't be OK to redact current version as moderator." end @@ -241,17 +241,17 @@ module Api # test the redaction of an old version of a relation, while being # authorised as a moderator. def test_redact_relation_moderator - relation = create(:relation, :with_history, :version => 4) - relation_v3 = relation.old_relations.find_by(:version => 3) + relation = create(:relation, :with_history, :version => 2) + relation_v1 = relation.old_relations.find_by(:version => 1) redaction = create(:redaction) auth_header = bearer_authorization_header create(:moderator_user) - post relation_version_redact_path(*relation_v3.id), :params => { :redaction => redaction.id }, :headers => auth_header + post relation_version_redact_path(*relation_v1.id), :params => { :redaction => redaction.id }, :headers => auth_header assert_response :success, "should be OK to redact old version as moderator." - relation_v3.reload - assert_predicate relation_v3, :redacted? - assert_equal redaction, relation_v3.redaction + relation_v1.reload + assert_predicate relation_v1, :redacted? + assert_equal redaction, relation_v1.redaction end ## @@ -320,10 +320,10 @@ module Api private def do_redact_redactable_relation(headers = {}) - relation = create(:relation, :with_history, :version => 4) + relation = create(:relation, :with_history, :version => 2) redaction = create(:redaction) - post relation_version_redact_path(relation, 3), :params => { :redaction => redaction.id }, :headers => headers + post relation_version_redact_path(relation, 1), :params => { :redaction => redaction.id }, :headers => headers end end end diff --git a/test/controllers/api/old_ways_controller_test.rb b/test/controllers/api/old_ways_controller_test.rb index b9c18da68..d7e6091ca 100644 --- a/test/controllers/api/old_ways_controller_test.rb +++ b/test/controllers/api/old_ways_controller_test.rb @@ -215,11 +215,11 @@ module Api # test that, even as moderator, the current version of a way # can't be redacted. def test_redact_way_current_version - way = create(:way, :with_history, :version => 4) + way = create(:way, :with_history, :version => 2) redaction = create(:redaction) auth_header = bearer_authorization_header create(:moderator_user) - post way_version_redact_path(way, 4), :params => { :redaction => redaction.id }, :headers => auth_header + post way_version_redact_path(way, 2), :params => { :redaction => redaction.id }, :headers => auth_header assert_response :bad_request, "shouldn't be OK to redact current version as moderator." end @@ -252,17 +252,17 @@ module Api # test the redaction of an old version of a way, while being # authorised as a moderator. def test_redact_way_moderator - way = create(:way, :with_history, :version => 4) - way_v3 = way.old_ways.find_by(:version => 3) + way = create(:way, :with_history, :version => 2) + way_v1 = way.old_ways.find_by(:version => 1) redaction = create(:redaction) auth_header = bearer_authorization_header create(:moderator_user) - post way_version_redact_path(*way_v3.id), :params => { :redaction => redaction.id }, :headers => auth_header + post way_version_redact_path(*way_v1.id), :params => { :redaction => redaction.id }, :headers => auth_header assert_response :success, "should be OK to redact old version as moderator." - way_v3.reload - assert_predicate way_v3, :redacted? - assert_equal redaction, way_v3.redaction + way_v1.reload + assert_predicate way_v1, :redacted? + assert_equal redaction, way_v1.redaction end ## @@ -354,10 +354,10 @@ module Api end def do_redact_redactable_way(headers = {}) - way = create(:way, :with_history, :version => 4) + way = create(:way, :with_history, :version => 2) redaction = create(:redaction) - post way_version_redact_path(way.id, 2), :params => { :redaction => redaction.id }, :headers => headers + post way_version_redact_path(way.id, 1), :params => { :redaction => redaction.id }, :headers => headers end end end