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 ...@@ -46,9 +46,6 @@ module Ci
private private
def process_pipeline_sequence
end
def commit def commit
@commit ||= project.commit(origin_sha || origin_ref) @commit ||= project.commit(origin_sha || origin_ref)
end end
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::Ci::Pipeline::Chain::Validate::Abilities do describe Gitlab::Ci::Pipeline::Chain::Validate::Abilities do
describe '#allowed_to_create?' do set(:project) { create(:project, :repository) }
let(:user) { create(:user) } set(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:ref) { 'master' } let(:pipeline) do
build_stubbed(:ci_pipeline, ref: ref, project: project)
end
let(:command) do
double('command', project: project, current_user: user)
end
let(:step) { described_class.new(pipeline, command) }
let(:pipeline) do let(:ref) { 'master' }
build_stubbed(:ci_pipeline, ref: ref, project: project)
context 'when users has no ability to run a pipeline' do
before do
step.perform!
end end
let(:command) do it 'adds an error about insufficient permissions' do
double('command', project: project, current_user: user) expect(pipeline.errors.to_a)
.to include /Insufficient permissions/
end end
subject do it 'breaks the pipeline builder chain' do
described_class.new(pipeline, command).allowed_to_create? expect(step.break?).to eq true
end 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 context 'when user is a developer' do
before do before do
......
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