Commit da15b388 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add specs for pipeline builder abilities validator

parent fa3fb23f
......@@ -46,9 +46,6 @@ module Ci
private
def process_pipeline_sequence
end
def commit
@commit ||= project.commit(origin_sha || origin_ref)
end
......
require 'spec_helper'
describe Gitlab::Ci::Pipeline::Chain::Validate::Abilities do
describe '#allowed_to_create?' do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:ref) { 'master' }
set(:project) { create(:project, :repository) }
set(:user) { create(:user) }
let(:pipeline) do
build_stubbed(:ci_pipeline, ref: ref, project: project)
......@@ -14,10 +12,31 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Abilities do
double('command', project: project, current_user: user)
end
subject do
described_class.new(pipeline, command).allowed_to_create?
let(:step) { described_class.new(pipeline, command) }
let(:ref) { 'master' }
context 'when users has no ability to run a pipeline' do
before do
step.perform!
end
it 'adds an error about insufficient permissions' do
expect(pipeline.errors.to_a)
.to include /Insufficient permissions/
end
it 'breaks the pipeline builder chain' do
expect(step.break?).to eq true
end
end
context 'when user has ability to create a pipeline' do
end
describe '#allowed_to_create?' do
subject { step.allowed_to_create? }
context 'when user is a developer' do
before do
project.add_developer(user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment