gitlab-org--gitlab-foss/spec/policies/ci/trigger_policy_spec.rb

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

54 lines
1.4 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-03-07 08:02:56 -05:00
require 'spec_helper'
RSpec.describe Ci::TriggerPolicy do
2017-03-07 08:02:56 -05:00
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:trigger) { create(:ci_trigger, project: project, owner: create(:user)) }
2017-03-07 08:02:56 -05:00
subject { described_class.new(user, trigger) }
2017-03-07 08:02:56 -05:00
describe '#rules' do
context 'when owner is an user' do
before do
trigger.update!(owner: user)
end
2017-03-07 08:02:56 -05:00
context 'when user is maintainer of the project' do
2017-03-07 08:02:56 -05:00
before do
project.add_maintainer(user)
2017-03-07 08:02:56 -05:00
end
it { is_expected.to be_allowed(:manage_trigger) }
it { is_expected.to be_allowed(:admin_trigger) }
2017-03-07 08:02:56 -05:00
end
end
context 'when owner is another user' do
context 'when user is maintainer of the project' do
2017-03-07 08:02:56 -05:00
before do
project.add_maintainer(user)
2017-03-07 08:02:56 -05:00
end
it { is_expected.to be_allowed(:manage_trigger) }
it { is_expected.not_to be_allowed(:admin_trigger) }
2017-03-07 08:02:56 -05:00
end
context 'when user is developer of the project' do
before do
project.add_developer(user)
2017-03-07 08:02:56 -05:00
end
it { is_expected.not_to be_allowed(:manage_trigger) }
it { is_expected.not_to be_allowed(:admin_trigger) }
2017-03-07 08:02:56 -05:00
end
context 'when user is not member of the project' do
it { is_expected.not_to be_allowed(:manage_trigger) }
it { is_expected.not_to be_allowed(:admin_trigger) }
2017-03-07 08:02:56 -05:00
end
end
end
end