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

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

48 lines
1.1 KiB
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
2018-05-09 12:01:36 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe DeployTokenPolicy do
2018-05-09 12:01:36 +05:30
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