]> git.openstreetmap.org Git - rails.git/commitdiff
Move current version redaction tests above roles/scopes tests
authorAnton Khorev <tony29@yandex.ru>
Tue, 11 Feb 2025 02:41:18 +0000 (05:41 +0300)
committerAnton Khorev <tony29@yandex.ru>
Tue, 11 Feb 2025 02:41:18 +0000 (05:41 +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 fb1ee16bc6058014dd5c8d7f9b778df209ec231f..7bea5d9d37906fd35b3eb09b88d5264269b72c3b 100644 (file)
@@ -194,31 +194,31 @@ module Api
     end
 
     ##
-    # test the redaction of an old version of a node, while not being
-    # authorised.
-    def test_redact_node_unauthorised
+    # 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 => 2)
-      old_node = node.old_nodes.find_by(:version => 1)
+      old_node = node.old_nodes.find_by(:version => 2)
       redaction = create(:redaction)
+      auth_header = bearer_authorization_header create(:moderator_user)
 
-      post node_version_redact_path(*old_node.id), :params => { :redaction => redaction.id }
+      post node_version_redact_path(*old_node.id), :params => { :redaction => redaction.id }, :headers => auth_header
 
-      assert_response :unauthorized, "should need to be authenticated to redact."
+      assert_response :bad_request, "shouldn't be OK to redact current version as moderator."
       assert_nil old_node.reload.redaction
     end
 
     ##
-    # test that, even as moderator, the current version of a node
-    # can't be redacted.
-    def test_redact_node_current_version
+    # test the redaction of an old version of a node, while not being
+    # authorised.
+    def test_redact_node_unauthorised
       node = create(:node, :with_history, :version => 2)
-      old_node = node.old_nodes.find_by(:version => 2)
+      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(*old_node.id), :params => { :redaction => redaction.id }, :headers => auth_header
+      post node_version_redact_path(*old_node.id), :params => { :redaction => redaction.id }
 
-      assert_response :bad_request, "shouldn't be OK to redact current version as moderator."
+      assert_response :unauthorized, "should need to be authenticated to redact."
       assert_nil old_node.reload.redaction
     end
 
index ecd9107b45875badda58e7249f225917c6f2e521..603499503b20eafef0411adbde301ccd8543f6ea 100644 (file)
@@ -185,31 +185,31 @@ module Api
     end
 
     ##
-    # test the redaction of an old version of a relation, while not being
-    # authorised.
-    def test_redact_relation_unauthorised
+    # 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 => 2)
-      old_relation = relation.old_relations.find_by(:version => 1)
+      old_relation = relation.old_relations.find_by(:version => 2)
       redaction = create(:redaction)
+      auth_header = bearer_authorization_header create(:moderator_user)
 
-      post relation_version_redact_path(*old_relation.id), :params => { :redaction => redaction.id }
+      post relation_version_redact_path(*old_relation.id), :params => { :redaction => redaction.id }, :headers => auth_header
 
-      assert_response :unauthorized, "should need to be authenticated to redact."
+      assert_response :bad_request, "shouldn't be OK to redact current version as moderator."
       assert_nil old_relation.reload.redaction
     end
 
     ##
-    # test that, even as moderator, the current version of a relation
-    # can't be redacted.
-    def test_redact_relation_current_version
+    # test the redaction of an old version of a relation, while not being
+    # authorised.
+    def test_redact_relation_unauthorised
       relation = create(:relation, :with_history, :version => 2)
-      old_relation = relation.old_relations.find_by(:version => 2)
+      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(*old_relation.id), :params => { :redaction => redaction.id }, :headers => auth_header
+      post relation_version_redact_path(*old_relation.id), :params => { :redaction => redaction.id }
 
-      assert_response :bad_request, "shouldn't be OK to redact current version as moderator."
+      assert_response :unauthorized, "should need to be authenticated to redact."
       assert_nil old_relation.reload.redaction
     end
 
index d695311fcc3b99ab3cf31ec1b6818f96ecf0fe54..e879c42a962acad6b0765995b25511e825544dc9 100644 (file)
@@ -196,31 +196,31 @@ module Api
     end
 
     ##
-    # test the redaction of an old version of a way, while not being
-    # authorised.
-    def test_redact_way_unauthorised
+    # 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 => 2)
-      old_way = way.old_ways.find_by(:version => 1)
+      old_way = way.old_ways.find_by(:version => 2)
       redaction = create(:redaction)
+      auth_header = bearer_authorization_header create(:moderator_user)
 
-      post way_version_redact_path(*old_way.id), :params => { :redaction => redaction.id }
+      post way_version_redact_path(*old_way.id), :params => { :redaction => redaction.id }, :headers => auth_header
 
-      assert_response :unauthorized, "should need to be authenticated to redact."
+      assert_response :bad_request, "shouldn't be OK to redact current version as moderator."
       assert_nil old_way.reload.redaction
     end
 
     ##
-    # test that, even as moderator, the current version of a way
-    # can't be redacted.
-    def test_redact_way_current_version
+    # test the redaction of an old version of a way, while not being
+    # authorised.
+    def test_redact_way_unauthorised
       way = create(:way, :with_history, :version => 2)
-      old_way = way.old_ways.find_by(:version => 2)
+      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(*old_way.id), :params => { :redaction => redaction.id }, :headers => auth_header
+      post way_version_redact_path(*old_way.id), :params => { :redaction => redaction.id }
 
-      assert_response :bad_request, "shouldn't be OK to redact current version as moderator."
+      assert_response :unauthorized, "should need to be authenticated to redact."
       assert_nil old_way.reload.redaction
     end