1 # frozen_string_literal: true
5 class ApiAbilityTest < ActiveSupport::TestCase
8 class GuestApiAbilityTest < ApiAbilityTest
9 test "note permissions for a guest" do
10 ability = ApiAbility.new nil
12 [:index, :create, :comment, :feed, :show, :search].each do |action|
13 assert ability.can?(action, Note), "should be able to #{action} Notes"
16 [:close, :reopen, :destroy].each do |action|
17 assert ability.cannot?(action, Note), "should not be able to #{action} Notes"
22 class UserApiAbilityTest < ApiAbilityTest
23 test "Note permissions" do
24 ability = ApiAbility.new create(:user)
26 [:index, :create, :comment, :feed, :show, :search, :close, :reopen].each do |action|
27 assert ability.can?(action, Note), "should be able to #{action} Notes"
30 [:destroy].each do |action|
31 assert ability.cannot?(action, Note), "should not be able to #{action} Notes"
36 class ModeratorApiAbilityTest < ApiAbilityTest
37 test "Note permissions" do
38 ability = ApiAbility.new create(:moderator_user)
40 [:index, :create, :comment, :feed, :show, :search, :close, :reopen, :destroy].each do |action|
41 assert ability.can?(action, Note), "should be able to #{action} Notes"