]> git.openstreetmap.org Git - rails.git/blob - test/abilities/user_api_ability_test.rb
Merge remote-tracking branch 'upstream/pull/6787'
[rails.git] / test / abilities / user_api_ability_test.rb
1 # frozen_string_literal: true
2
3 require "test_helper"
4
5 class UserApiAbilityTest < ActiveSupport::TestCase
6   test "Note permissions" do
7     user = create(:user)
8     scopes = Set.new %w[write_notes]
9     ability = ApiAbility.new user, scopes
10
11     [:index, :create, :comment, :feed, :show, :search, :close, :reopen].each do |action|
12       assert ability.can?(action, Note), "should be able to #{action} Notes"
13     end
14
15     [:destroy].each do |action|
16       assert ability.cannot?(action, Note), "should not be able to #{action} Notes"
17     end
18   end
19 end