Split api changeset comment hide fail tests
This commit is contained in:
parent
c3b0a278d8
commit
97b9d5acdb
1 changed files with 9 additions and 8 deletions
|
@ -281,30 +281,31 @@ module Api
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
def test_hide_by_unauthorized
|
||||||
# test hide comment fail
|
|
||||||
def test_hide_fail
|
|
||||||
# unauthorized
|
|
||||||
comment = create(:changeset_comment)
|
comment = create(:changeset_comment)
|
||||||
assert comment.visible
|
|
||||||
|
|
||||||
post changeset_comment_hide_path(comment)
|
post changeset_comment_hide_path(comment)
|
||||||
|
|
||||||
assert_response :unauthorized
|
assert_response :unauthorized
|
||||||
assert comment.reload.visible
|
assert comment.reload.visible
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_hide_by_normal_user
|
||||||
|
comment = create(:changeset_comment)
|
||||||
auth_header = bearer_authorization_header
|
auth_header = bearer_authorization_header
|
||||||
|
|
||||||
# not a moderator
|
|
||||||
post changeset_comment_hide_path(comment), :headers => auth_header
|
post changeset_comment_hide_path(comment), :headers => auth_header
|
||||||
|
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
assert comment.reload.visible
|
assert comment.reload.visible
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_hide_missing_comment
|
||||||
auth_header = bearer_authorization_header create(:moderator_user)
|
auth_header = bearer_authorization_header create(:moderator_user)
|
||||||
|
|
||||||
# bad comment id
|
|
||||||
post changeset_comment_hide_path(999111), :headers => auth_header
|
post changeset_comment_hide_path(999111), :headers => auth_header
|
||||||
|
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
assert comment.reload.visible
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue