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 let(:pipeline) do
build_stubbed(:ci_pipeline, ref: ref, project: project) build_stubbed(:ci_pipeline, ref: ref, project: project)
...@@ -14,10 +12,31 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Abilities do ...@@ -14,10 +12,31 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Abilities do
double('command', project: project, current_user: user) double('command', project: project, current_user: user)
end end
subject do let(:step) { described_class.new(pipeline, command) }
described_class.new(pipeline, command).allowed_to_create?
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 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 context 'when user is a developer' do
before do before do
project.add_developer(user) 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