1 # frozen_string_literal: true
5 class NoteApiCapabilityTest < ActiveSupport::TestCase
6 test "as a normal user without scopes" do
9 ability = ApiAbility.new user, scopes
11 [:create, :comment, :close, :reopen, :destroy].each do |action|
12 assert ability.cannot? action, Note
16 test "as a normal user with write_notes scope" do
18 scopes = Set.new %w[write_notes]
19 ability = ApiAbility.new user, scopes
21 [:destroy].each do |action|
22 assert ability.cannot? action, Note
25 [:create, :comment, :close, :reopen].each do |action|
26 assert ability.can? action, Note
30 test "as a moderator without scopes" do
31 user = create(:moderator_user)
33 ability = ApiAbility.new user, scopes
35 [:destroy].each do |action|
36 assert ability.cannot? action, Note
40 test "as a moderator with write_notes scope" do
41 user = create(:moderator_user)
42 scopes = Set.new %w[write_notes]
43 ability = ApiAbility.new user, scopes
45 [:destroy].each do |action|
46 assert ability.can? action, Note