]> git.openstreetmap.org Git - rails.git/commitdiff
Use fewer element versions in redaction tests
authorAnton Khorev <tony29@yandex.ru>
Mon, 10 Feb 2025 14:58:46 +0000 (17:58 +0300)
committerAnton Khorev <tony29@yandex.ru>
Mon, 10 Feb 2025 23:08:28 +0000 (02:08 +0300)
test/controllers/api/old_nodes_controller_test.rb
test/controllers/api/old_relations_controller_test.rb
test/controllers/api/old_ways_controller_test.rb

index 9aa6fdce905933c2df2fcda18eed6a789ea20432..bddc6bc24920d2a5109184e0c8f9e15b90c71120 100644 (file)
@@ -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)
index e03b55260156ba34835af9b9ca47f21d5bf1e0e3..d7aa923ec485a57581ddf4d092dabeca6ebc1377 100644 (file)
@@ -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
index b9c18da68d37b9df13e2f344870239c8693f199d..d7e6091ca5917b0689cc365b49b0ced088dfc255 100644 (file)
@@ -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