diff options
Diffstat (limited to 'spec/policies/project_hook_policy_spec.rb')
-rw-r--r-- | spec/policies/project_hook_policy_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/policies/project_hook_policy_spec.rb b/spec/policies/project_hook_policy_spec.rb new file mode 100644 index 00000000000..cfa7b6ee4bf --- /dev/null +++ b/spec/policies/project_hook_policy_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ProjectHookPolicy do + let_it_be(:user) { create(:user) } + + let(:hook) { create(:project_hook) } + + subject(:policy) { described_class.new(user, hook) } + + context 'when the user is not a maintainer' do + before do + hook.project.add_developer(user) + end + + it "cannot read and destroy web-hooks" do + expect(policy).to be_disallowed(:read_web_hook, :destroy_web_hook) + end + end + + context 'when the user is a maintainer' do + before do + hook.project.add_maintainer(user) + end + + it "can read and destroy web-hooks" do + expect(policy).to be_allowed(:read_web_hook, :destroy_web_hook) + end + end +end |