debian-mirror-gitlab/spec/policies/project_hook_policy_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
709 B
Ruby
Raw Normal View History

2022-08-27 11:52:29 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-05-27 22:25:52 +05:30
RSpec.describe ProjectHookPolicy, feature_category: :integrations do
2022-08-27 11:52:29 +05:30
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
2023-05-27 22:25:52 +05:30
expect(policy).to be_disallowed(:destroy_web_hook)
2022-08-27 11:52:29 +05:30
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
2023-05-27 22:25:52 +05:30
expect(policy).to be_allowed(:destroy_web_hook)
2022-08-27 11:52:29 +05:30
end
end
end