Skip to content

Commit

Permalink
Merge pull request #23874 from code-dot-org/test-deleting-abuse
Browse files Browse the repository at this point in the history
Projects: Test deleting abuse with the project_validator? helper
  • Loading branch information
Erin007 committed Jul 24, 2018
2 parents f787ba2 + 3963fab commit 0f1b4c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion shared/middleware/channels_api.rb
Expand Up @@ -303,7 +303,7 @@ class ChannelsApi < Sinatra::Base
#
delete %r{/v3/channels/([^/]+)/abuse$} do |id|
# UserPermission::PROJECT_VALIDATOR
not_authorized unless has_permission?('project_validator')
not_authorized unless project_validator?

dont_cache
content_type :json
Expand Down
12 changes: 7 additions & 5 deletions shared/test/test_channels.rb
Expand Up @@ -301,11 +301,13 @@ def test_abuse
delete "/v3/channels/#{channel_id}/abuse"
assert last_response.unauthorized?

# Ideally we would also test that deleting abuse works when we're an admin
# but don't currently have a way to simulate admin from tests
# TODO (Erin B) confirm if this is accurate and update tests if needed.
# You might not need to be an admin, you might need project validator
# permissions.
ChannelsApi.any_instance.stubs(:project_validator?).returns(true)

delete "/v3/channels/#{channel_id}/abuse"
assert last_response.ok?
assert_equal 0, JSON.parse(last_response.body)['abuse_score']

ChannelsApi.any_instance.unstub(:project_validator?)
end

def test_disable_and_enable_content_moderation
Expand Down

0 comments on commit 0f1b4c0

Please sign in to comment.