From 06cca3717a91dcc089205bda5aab30c0f10ba582 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Mon, 10 Feb 2025 18:59:18 +0300 Subject: [PATCH] Rename old element variables in redaction tests --- .../api/old_nodes_controller_test.rb | 34 +++++++++---------- .../api/old_relations_controller_test.rb | 34 +++++++++---------- .../api/old_ways_controller_test.rb | 34 +++++++++---------- 3 files changed, 51 insertions(+), 51 deletions(-) diff --git a/test/controllers/api/old_nodes_controller_test.rb b/test/controllers/api/old_nodes_controller_test.rb index 0f7227287..04e76dac5 100644 --- a/test/controllers/api/old_nodes_controller_test.rb +++ b/test/controllers/api/old_nodes_controller_test.rb @@ -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 diff --git a/test/controllers/api/old_relations_controller_test.rb b/test/controllers/api/old_relations_controller_test.rb index a874232bd..8d98359ea 100644 --- a/test/controllers/api/old_relations_controller_test.rb +++ b/test/controllers/api/old_relations_controller_test.rb @@ -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 diff --git a/test/controllers/api/old_ways_controller_test.rb b/test/controllers/api/old_ways_controller_test.rb index 5dc1c9cfc..95f3f2bd0 100644 --- a/test/controllers/api/old_ways_controller_test.rb +++ b/test/controllers/api/old_ways_controller_test.rb @@ -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 -- 2.39.5