1 # frozen_string_literal: true
5 class ChangesetCommentApiCapabilityTest < ActiveSupport::TestCase
6 test "as a normal user without scopes" do
9 ability = ApiAbility.new user, scopes
11 assert ability.cannot? :create, ChangesetComment
12 assert ability.cannot? :create, :changeset_comment_visibility
13 assert ability.cannot? :destroy, :changeset_comment_visibility
16 test "as a normal user with write_changeset_comments scope" do
18 scopes = Set.new %w[write_changeset_comments]
19 ability = ApiAbility.new user, scopes
21 assert ability.can? :create, ChangesetComment
22 assert ability.cannot? :create, :changeset_comment_visibility
23 assert ability.cannot? :destroy, :changeset_comment_visibility
26 test "as a moderator without scopes" do
27 user = create(:moderator_user)
29 ability = ApiAbility.new user, scopes
31 assert ability.cannot? :create, ChangesetComment
32 assert ability.cannot? :create, :changeset_comment_visibility
33 assert ability.cannot? :destroy, :changeset_comment_visibility
36 test "as a moderator with write_changeset_comments scope" do
37 user = create(:moderator_user)
38 scopes = Set.new %w[write_changeset_comments]
39 ability = ApiAbility.new user, scopes
41 assert ability.can? :create, ChangesetComment
42 assert ability.can? :create, :changeset_comment_visibility
43 assert ability.can? :destroy, :changeset_comment_visibility