]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/api/old_ways_controller_test.rb
Move current version redaction tests above roles/scopes tests
[rails.git] / test / controllers / api / old_ways_controller_test.rb
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