scopes = Set.new
ability = ApiAbility.new user, scopes
- [:create, :destroy, :restore].each do |action|
- assert ability.cannot? action, ChangesetComment
- end
+ assert ability.cannot? :create, ChangesetComment
+ assert ability.cannot? :create, :changeset_comment_visibility
+ assert ability.cannot? :destroy, :changeset_comment_visibility
end
test "as a normal user with write_changeset_comments scope" do
scopes = Set.new %w[write_changeset_comments]
ability = ApiAbility.new user, scopes
- [:destroy, :restore].each do |action|
- assert ability.cannot? action, ChangesetComment
- end
-
- [:create].each do |action|
- assert ability.can? action, ChangesetComment
- end
+ assert ability.can? :create, ChangesetComment
+ assert ability.cannot? :create, :changeset_comment_visibility
+ assert ability.cannot? :destroy, :changeset_comment_visibility
end
test "as a moderator without scopes" do
scopes = Set.new
ability = ApiAbility.new user, scopes
- [:create, :destroy, :restore].each do |action|
- assert ability.cannot? action, ChangesetComment
- end
+ assert ability.cannot? :create, ChangesetComment
+ assert ability.cannot? :create, :changeset_comment_visibility
+ assert ability.cannot? :destroy, :changeset_comment_visibility
end
test "as a moderator with write_changeset_comments scope" do
scopes = Set.new %w[write_changeset_comments]
ability = ApiAbility.new user, scopes
- [:create, :destroy, :restore].each do |action|
- assert ability.can? action, ChangesetComment
- end
+ assert ability.can? :create, ChangesetComment
+ assert ability.can? :create, :changeset_comment_visibility
+ assert ability.can? :destroy, :changeset_comment_visibility
end
end