diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-09-26 13:00:29 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-09-26 13:00:29 +0200 |
commit | da15b38850d8d345a17862754285c34a2fbf08b6 (patch) | |
tree | bc5811a90a1a6728842592f97f1fa05a591ae430 /spec/lib/gitlab/ci | |
parent | fa3fb23fb18ddea694ea54013059178fe7892c91 (diff) | |
download | gitlab-ce-da15b38850d8d345a17862754285c34a2fbf08b6.tar.gz |
Add specs for pipeline builder abilities validator
Diffstat (limited to 'spec/lib/gitlab/ci')
-rw-r--r-- | spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb index 9e217102886..e6decde475a 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb @@ -1,22 +1,41 @@ 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) + end + + let(:command) do + double('command', project: project, current_user: user) + end + + let(:step) { described_class.new(pipeline, command) } - let(:pipeline) do - build_stubbed(:ci_pipeline, ref: ref, project: project) + let(:ref) { 'master' } + + context 'when users has no ability to run a pipeline' do + before do + step.perform! end - let(:command) do - double('command', project: project, current_user: user) + it 'adds an error about insufficient permissions' do + expect(pipeline.errors.to_a) + .to include /Insufficient permissions/ end - subject do - described_class.new(pipeline, command).allowed_to_create? + 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 |