]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/api/old_ways_controller_test.rb
Always check changes/comments counts in single changeset tests
[rails.git] / test / controllers / api / old_ways_controller_test.rb
index d695311fcc3b99ab3cf31ec1b6818f96ecf0fe54..6946d2ab1cda8b8e24b52b70394b9875604b9ad8 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
 
@@ -307,11 +307,10 @@ module Api
     # test the unredaction of an old version of a way, while being
     # authorised as a moderator.
     def test_unredact_way_moderator
-      moderator_user = create(:moderator_user)
       way = create(:way, :with_history, :version => 2)
       old_way = way.old_ways.find_by(:version => 1)
       old_way.redact!(create(:redaction))
-      auth_header = bearer_authorization_header moderator_user
+      auth_header = bearer_authorization_header create(:moderator_user)
 
       post way_version_redact_path(*old_way.id), :headers => auth_header