diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-17 15:08:37 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-17 15:08:37 +0000 |
commit | 37eff29d5ce44899e34c7c2ac319b314f2f26d15 (patch) | |
tree | b74e1632fdb58ea10972f270bfec70a4e6ee07b0 /spec/models/ci/processable_spec.rb | |
parent | 9411a664118a3247d0a56baf7e7ef4549c1201c3 (diff) | |
download | gitlab-ce-37eff29d5ce44899e34c7c2ac319b314f2f26d15.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/ci/processable_spec.rb')
-rw-r--r-- | spec/models/ci/processable_spec.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/models/ci/processable_spec.rb b/spec/models/ci/processable_spec.rb new file mode 100644 index 00000000000..87dbcbf870e --- /dev/null +++ b/spec/models/ci/processable_spec.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Ci::Processable do + set(:project) { create(:project) } + set(:pipeline) { create(:ci_pipeline, project: project) } + + describe '#aggregated_needs_names' do + let(:with_aggregated_needs) { pipeline.processables.select_with_aggregated_needs(project) } + + context 'with created status' do + let!(:processable) { create(:ci_build, :created, project: project, pipeline: pipeline) } + + context 'with needs' do + before do + create(:ci_build_need, build: processable, name: 'test1') + create(:ci_build_need, build: processable, name: 'test2') + end + + it 'returns all processables' do + expect(with_aggregated_needs).to contain_exactly(processable) + end + + it 'returns all needs' do + expect(with_aggregated_needs.first.aggregated_needs_names).to contain_exactly('test1', 'test2') + end + + context 'with ci_dag_support disabled' do + before do + stub_feature_flags(ci_dag_support: false) + end + + it 'returns all processables' do + expect(with_aggregated_needs).to contain_exactly(processable) + end + + it 'returns empty needs' do + expect(with_aggregated_needs.first.aggregated_needs_names).to be_nil + end + end + end + + context 'without needs' do + it 'returns all processables' do + expect(with_aggregated_needs).to contain_exactly(processable) + end + + it 'returns empty needs' do + expect(with_aggregated_needs.first.aggregated_needs_names).to be_nil + end + end + end + end +end |