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

46 lines
1.1 KiB
Ruby
Raw Normal View History

2018-05-09 12:01:36 +05:30
require 'spec_helper'
describe DeployTokenPolicy do
let(:current_user) { create(:user) }
let(:project) { create(:project) }
let(:deploy_token) { create(:deploy_token, projects: [project]) }
subject { described_class.new(current_user, deploy_token) }
describe 'creating a deploy key' do
2018-11-18 11:00:15 +05:30
context 'when user is maintainer' do
2018-05-09 12:01:36 +05:30
before do
2018-11-18 11:00:15 +05:30
project.add_maintainer(current_user)
2018-05-09 12:01:36 +05:30
end
it { is_expected.to be_allowed(:create_deploy_token) }
end
2018-11-18 11:00:15 +05:30
context 'when user is not maintainer' do
2018-05-09 12:01:36 +05:30
before do
project.add_developer(current_user)
end
it { is_expected.to be_disallowed(:create_deploy_token) }
end
end
describe 'updating a deploy key' do
2018-11-18 11:00:15 +05:30
context 'when user is maintainer' do
2018-05-09 12:01:36 +05:30
before do
2018-11-18 11:00:15 +05:30
project.add_maintainer(current_user)
2018-05-09 12:01:36 +05:30
end
it { is_expected.to be_allowed(:update_deploy_token) }
end
2018-11-18 11:00:15 +05:30
context 'when user is not maintainer' do
2018-05-09 12:01:36 +05:30
before do
project.add_developer(current_user)
end
it { is_expected.to be_disallowed(:update_deploy_token) }
end
end
end