]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/api/changeset_comments_controller_test.rb
Add write_changeset_comments scope
[rails.git] / test / controllers / api / changeset_comments_controller_test.rb
index 4719ce49d9f6646aaca487c53cde3a57c2b7c119..91b8ad683fd3dc29c1cf098721ec458fb902afeb 100644 (file)
@@ -281,30 +281,31 @@ module Api
       end
     end
 
-    ##
-    # test hide comment fail
-    def test_hide_fail
-      # unauthorized
+    def test_hide_by_unauthorized
       comment = create(:changeset_comment)
-      assert comment.visible
 
       post changeset_comment_hide_path(comment)
+
       assert_response :unauthorized
       assert comment.reload.visible
+    end
 
+    def test_hide_by_normal_user
+      comment = create(:changeset_comment)
       auth_header = bearer_authorization_header
 
-      # not a moderator
       post changeset_comment_hide_path(comment), :headers => auth_header
+
       assert_response :forbidden
       assert comment.reload.visible
+    end
 
+    def test_hide_missing_comment
       auth_header = bearer_authorization_header create(:moderator_user)
 
-      # bad comment id
       post changeset_comment_hide_path(999111), :headers => auth_header
+
       assert_response :not_found
-      assert comment.reload.visible
     end
 
     ##
@@ -320,30 +321,31 @@ module Api
       assert_not comment.reload.visible
     end
 
-    ##
-    # test unhide comment fail
-    def test_unhide_fail
-      # unauthorized
+    def test_unhide_by_unauthorized
       comment = create(:changeset_comment, :visible => false)
-      assert_not comment.visible
 
       post changeset_comment_unhide_path(comment)
+
       assert_response :unauthorized
       assert_not comment.reload.visible
+    end
 
+    def test_unhide_by_normal_user
+      comment = create(:changeset_comment, :visible => false)
       auth_header = bearer_authorization_header
 
-      # not a moderator
       post changeset_comment_unhide_path(comment), :headers => auth_header
+
       assert_response :forbidden
       assert_not comment.reload.visible
+    end
 
+    def test_unhide_missing_comment
       auth_header = bearer_authorization_header create(:moderator_user)
 
-      # bad comment id
       post changeset_comment_unhide_path(999111), :headers => auth_header
+
       assert_response :not_found
-      assert_not comment.reload.visible
     end
 
     ##