]> git.openstreetmap.org Git - rails.git/commitdiff
Rename old element variables in redaction tests
authorAnton Khorev <tony29@yandex.ru>
Mon, 10 Feb 2025 15:59:18 +0000 (18:59 +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 0f7227287adc2b5e02cb0051b534cdc67830f4f2..04e76dac53cab69d20e85ffcb141a1ee2d941b35 100644 (file)
@@ -251,16 +251,16 @@ module Api
     # authorised as a moderator.
     def test_redact_node_moderator
       node = create(:node, :with_history, :version => 2)
-      node_v1 = node.old_nodes.find_by(:version => 1)
+      old_node = node.old_nodes.find_by(:version => 1)
       redaction = create(:redaction)
       auth_header = bearer_authorization_header create(:moderator_user)
 
-      post node_version_redact_path(*node_v1.id), :params => { :redaction => redaction.id }, :headers => auth_header
+      post node_version_redact_path(*old_node.id), :params => { :redaction => redaction.id }, :headers => auth_header
 
       assert_response :success, "should be OK to redact old version as moderator."
-      node_v1.reload
-      assert_predicate node_v1, :redacted?
-      assert_equal redaction, node_v1.redaction
+      old_node.reload
+      assert_predicate old_node, :redacted?
+      assert_equal redaction, old_node.redaction
     end
 
     ##
@@ -268,14 +268,14 @@ module Api
     # authorised.
     def test_unredact_node_unauthorised
       node = create(:node, :with_history, :version => 2)
-      node_v1 = node.old_nodes.find_by(:version => 1)
+      old_node = node.old_nodes.find_by(:version => 1)
       redaction = create(:redaction)
-      node_v1.redact!(redaction)
+      old_node.redact!(redaction)
 
-      post node_version_redact_path(node_v1.node_id, node_v1.version)
+      post node_version_redact_path(*old_node.id)
 
       assert_response :unauthorized, "should need to be authenticated to unredact."
-      assert_equal redaction, node_v1.reload.redaction
+      assert_equal redaction, old_node.reload.redaction
     end
 
     ##
@@ -284,15 +284,15 @@ module Api
     def test_unredact_node_normal_user
       user = create(:user)
       node = create(:node, :with_history, :version => 2)
-      node_v1 = node.old_nodes.find_by(:version => 1)
+      old_node = node.old_nodes.find_by(:version => 1)
       redaction = create(:redaction)
-      node_v1.redact!(redaction)
+      old_node.redact!(redaction)
       auth_header = bearer_authorization_header user
 
-      post node_version_redact_path(node_v1.node_id, node_v1.version), :headers => auth_header
+      post node_version_redact_path(*old_node.id), :headers => auth_header
 
       assert_response :forbidden, "should need to be moderator to unredact."
-      assert_equal redaction, node_v1.reload.redaction
+      assert_equal redaction, old_node.reload.redaction
     end
 
     ##
@@ -301,14 +301,14 @@ module Api
     def test_unredact_node_moderator
       moderator_user = create(:moderator_user)
       node = create(:node, :with_history, :version => 2)
-      node_v1 = node.old_nodes.find_by(:version => 1)
-      node_v1.redact!(create(:redaction))
+      old_node = node.old_nodes.find_by(:version => 1)
+      old_node.redact!(create(:redaction))
       auth_header = bearer_authorization_header moderator_user
 
-      post node_version_redact_path(node_v1.node_id, node_v1.version), :headers => auth_header
+      post node_version_redact_path(*old_node.id), :headers => auth_header
 
       assert_response :success, "should be OK to unredact old version as moderator."
-      assert_nil node_v1.reload.redaction
+      assert_nil old_node.reload.redaction
     end
 
     private
index a874232bdd3b4a28fcf4af7148a0235f55ad796e..8d98359ea3b7ebbedc847e2a169e0e98cf1afb83 100644 (file)
@@ -242,16 +242,16 @@ module Api
     # authorised as a moderator.
     def test_redact_relation_moderator
       relation = create(:relation, :with_history, :version => 2)
-      relation_v1 = relation.old_relations.find_by(:version => 1)
+      old_relation = relation.old_relations.find_by(:version => 1)
       redaction = create(:redaction)
       auth_header = bearer_authorization_header create(:moderator_user)
 
-      post relation_version_redact_path(*relation_v1.id), :params => { :redaction => redaction.id }, :headers => auth_header
+      post relation_version_redact_path(*old_relation.id), :params => { :redaction => redaction.id }, :headers => auth_header
 
       assert_response :success, "should be OK to redact old version as moderator."
-      relation_v1.reload
-      assert_predicate relation_v1, :redacted?
-      assert_equal redaction, relation_v1.redaction
+      old_relation.reload
+      assert_predicate old_relation, :redacted?
+      assert_equal redaction, old_relation.redaction
     end
 
     ##
@@ -259,14 +259,14 @@ module Api
     # authorised.
     def test_unredact_relation_unauthorised
       relation = create(:relation, :with_history, :version => 2)
-      relation_v1 = relation.old_relations.find_by(:version => 1)
+      old_relation = relation.old_relations.find_by(:version => 1)
       redaction = create(:redaction)
-      relation_v1.redact!(redaction)
+      old_relation.redact!(redaction)
 
-      post relation_version_redact_path(relation_v1.relation_id, relation_v1.version)
+      post relation_version_redact_path(*old_relation.id)
 
       assert_response :unauthorized, "should need to be authenticated to unredact."
-      assert_equal redaction, relation_v1.reload.redaction
+      assert_equal redaction, old_relation.reload.redaction
     end
 
     ##
@@ -274,15 +274,15 @@ module Api
     # authorised as a normal user.
     def test_unredact_relation_normal_user
       relation = create(:relation, :with_history, :version => 2)
-      relation_v1 = relation.old_relations.find_by(:version => 1)
+      old_relation = relation.old_relations.find_by(:version => 1)
       redaction = create(:redaction)
-      relation_v1.redact!(redaction)
+      old_relation.redact!(redaction)
       auth_header = bearer_authorization_header
 
-      post relation_version_redact_path(relation_v1.relation_id, relation_v1.version), :headers => auth_header
+      post relation_version_redact_path(*old_relation.id), :headers => auth_header
 
       assert_response :forbidden, "should need to be moderator to unredact."
-      assert_equal redaction, relation_v1.reload.redaction
+      assert_equal redaction, old_relation.reload.redaction
     end
 
     ##
@@ -290,14 +290,14 @@ module Api
     # authorised as a moderator.
     def test_unredact_relation_moderator
       relation = create(:relation, :with_history, :version => 2)
-      relation_v1 = relation.old_relations.find_by(:version => 1)
-      relation_v1.redact!(create(:redaction))
+      old_relation = relation.old_relations.find_by(:version => 1)
+      old_relation.redact!(create(:redaction))
       auth_header = bearer_authorization_header create(:moderator_user)
 
-      post relation_version_redact_path(relation_v1.relation_id, relation_v1.version), :headers => auth_header
+      post relation_version_redact_path(*old_relation.id), :headers => auth_header
 
       assert_response :success, "should be OK to unredact old version as moderator."
-      assert_nil relation_v1.reload.redaction
+      assert_nil old_relation.reload.redaction
     end
 
     private
index 5dc1c9cfc56ed7ae7b650fca60b258e8b4be4fe4..95f3f2bd00efa455e69951c246d4dab9ad3874f0 100644 (file)
@@ -253,16 +253,16 @@ module Api
     # authorised as a moderator.
     def test_redact_way_moderator
       way = create(:way, :with_history, :version => 2)
-      way_v1 = way.old_ways.find_by(:version => 1)
+      old_way = way.old_ways.find_by(:version => 1)
       redaction = create(:redaction)
       auth_header = bearer_authorization_header create(:moderator_user)
 
-      post way_version_redact_path(*way_v1.id), :params => { :redaction => redaction.id }, :headers => auth_header
+      post way_version_redact_path(*old_way.id), :params => { :redaction => redaction.id }, :headers => auth_header
 
       assert_response :success, "should be OK to redact old version as moderator."
-      way_v1.reload
-      assert_predicate way_v1, :redacted?
-      assert_equal redaction, way_v1.redaction
+      old_way.reload
+      assert_predicate old_way, :redacted?
+      assert_equal redaction, old_way.redaction
     end
 
     ##
@@ -270,14 +270,14 @@ module Api
     # authorised.
     def test_unredact_way_unauthorised
       way = create(:way, :with_history, :version => 2)
-      way_v1 = way.old_ways.find_by(:version => 1)
+      old_way = way.old_ways.find_by(:version => 1)
       redaction = create(:redaction)
-      way_v1.redact!(redaction)
+      old_way.redact!(redaction)
 
-      post way_version_redact_path(way_v1.way_id, way_v1.version)
+      post way_version_redact_path(*old_way.id)
 
       assert_response :unauthorized, "should need to be authenticated to unredact."
-      assert_equal redaction, way_v1.reload.redaction
+      assert_equal redaction, old_way.reload.redaction
     end
 
     ##
@@ -285,15 +285,15 @@ module Api
     # authorised as a normal user.
     def test_unredact_way_normal_user
       way = create(:way, :with_history, :version => 2)
-      way_v1 = way.old_ways.find_by(:version => 1)
+      old_way = way.old_ways.find_by(:version => 1)
       redaction = create(:redaction)
-      way_v1.redact!(redaction)
+      old_way.redact!(redaction)
       auth_header = bearer_authorization_header
 
-      post way_version_redact_path(way_v1.way_id, way_v1.version), :headers => auth_header
+      post way_version_redact_path(*old_way.id), :headers => auth_header
 
       assert_response :forbidden, "should need to be moderator to unredact."
-      assert_equal redaction, way_v1.reload.redaction
+      assert_equal redaction, old_way.reload.redaction
     end
 
     ##
@@ -302,14 +302,14 @@ module Api
     def test_unredact_way_moderator
       moderator_user = create(:moderator_user)
       way = create(:way, :with_history, :version => 2)
-      way_v1 = way.old_ways.find_by(:version => 1)
-      way_v1.redact!(create(:redaction))
+      old_way = way.old_ways.find_by(:version => 1)
+      old_way.redact!(create(:redaction))
       auth_header = bearer_authorization_header moderator_user
 
-      post way_version_redact_path(way_v1.way_id, way_v1.version), :headers => auth_header
+      post way_version_redact_path(*old_way.id), :headers => auth_header
 
       assert_response :success, "should be OK to unredact old version as moderator."
-      assert_nil way_v1.reload.redaction
+      assert_nil old_way.reload.redaction
     end
 
     private