diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/lib/gitlab/ci/pipeline/chain/helpers_spec.rb | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) | |
download | gitlab-ce-9dc93a4519d9d5d7be48ff274127136236a3adb3.tar.gz |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/lib/gitlab/ci/pipeline/chain/helpers_spec.rb')
-rw-r--r-- | spec/lib/gitlab/ci/pipeline/chain/helpers_spec.rb | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/chain/helpers_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/helpers_spec.rb new file mode 100644 index 00000000000..bcea6462790 --- /dev/null +++ b/spec/lib/gitlab/ci/pipeline/chain/helpers_spec.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Ci::Pipeline::Chain::Helpers do + let(:helper_class) do + Class.new do + include Gitlab::Ci::Pipeline::Chain::Helpers + + attr_accessor :pipeline, :command + + def initialize(pipeline, command) + self.pipeline = pipeline + self.command = command + end + end + end + + subject(:helper) { helper_class.new(pipeline, command) } + + let(:pipeline) { build(:ci_empty_pipeline) } + let(:command) { double(save_incompleted: true) } + let(:message) { 'message' } + + describe '.error' do + shared_examples 'error function' do + specify do + expect(pipeline).to receive(:drop!).with(drop_reason).and_call_original + expect(pipeline).to receive(:add_error_message).with(message).and_call_original + expect(pipeline).to receive(:ensure_project_iid!).twice.and_call_original + + subject.error(message, config_error: config_error, drop_reason: drop_reason) + + expect(pipeline.yaml_errors).to eq(yaml_error) + expect(pipeline.errors[:base]).to include(message) + end + end + + context 'when given a drop reason' do + context 'when config error is true' do + context 'sets the yaml error and overrides the drop reason' do + let(:drop_reason) { :config_error } + let(:config_error) { true } + let(:yaml_error) { message } + + it_behaves_like "error function" + end + end + + context 'when config error is false' do + context 'does not set the yaml error or override the drop reason' do + let(:drop_reason) { :size_limit_exceeded } + let(:config_error) { false } + let(:yaml_error) { nil } + + it_behaves_like "error function" + end + end + end + end +end |