Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/ci/config/entry/need_spec.rb')
-rw-r--r--spec/lib/gitlab/ci/config/entry/need_spec.rb86
1 files changed, 81 insertions, 5 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/need_spec.rb b/spec/lib/gitlab/ci/config/entry/need_spec.rb
index 983e95fae42..a0a5dd52ad4 100644
--- a/spec/lib/gitlab/ci/config/entry/need_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/need_spec.rb
@@ -23,7 +23,17 @@ RSpec.describe ::Gitlab::Ci::Config::Entry::Need do
describe '#value' do
it 'returns job needs configuration' do
- expect(need.value).to eq(name: 'job_name', artifacts: true)
+ expect(need.value).to eq(name: 'job_name', artifacts: true, optional: false)
+ end
+
+ context 'when the FF ci_needs_optional is disabled' do
+ before do
+ stub_feature_flags(ci_needs_optional: false)
+ end
+
+ it 'returns job needs configuration without `optional`' do
+ expect(need.value).to eq(name: 'job_name', artifacts: true)
+ end
end
end
@@ -58,7 +68,7 @@ RSpec.describe ::Gitlab::Ci::Config::Entry::Need do
describe '#value' do
it 'returns job needs configuration' do
- expect(need.value).to eq(name: 'job_name', artifacts: true)
+ expect(need.value).to eq(name: 'job_name', artifacts: true, optional: false)
end
end
@@ -74,7 +84,7 @@ RSpec.describe ::Gitlab::Ci::Config::Entry::Need do
describe '#value' do
it 'returns job needs configuration' do
- expect(need.value).to eq(name: 'job_name', artifacts: false)
+ expect(need.value).to eq(name: 'job_name', artifacts: false, optional: false)
end
end
@@ -90,7 +100,7 @@ RSpec.describe ::Gitlab::Ci::Config::Entry::Need do
describe '#value' do
it 'returns job needs configuration' do
- expect(need.value).to eq(name: 'job_name', artifacts: true)
+ expect(need.value).to eq(name: 'job_name', artifacts: true, optional: false)
end
end
@@ -106,11 +116,77 @@ RSpec.describe ::Gitlab::Ci::Config::Entry::Need do
describe '#value' do
it 'returns job needs configuration' do
- expect(need.value).to eq(name: 'job_name', artifacts: true)
+ expect(need.value).to eq(name: 'job_name', artifacts: true, optional: false)
+ end
+ end
+
+ it_behaves_like 'job type'
+ end
+
+ context 'with job name and optional true' do
+ let(:config) { { job: 'job_name', optional: true } }
+
+ it { is_expected.to be_valid }
+
+ it_behaves_like 'job type'
+
+ describe '#value' do
+ it 'returns job needs configuration' do
+ expect(need.value).to eq(name: 'job_name', artifacts: true, optional: true)
+ end
+
+ context 'when the FF ci_needs_optional is disabled' do
+ before do
+ stub_feature_flags(ci_needs_optional: false)
+ end
+
+ it 'returns job needs configuration without `optional`' do
+ expect(need.value).to eq(name: 'job_name', artifacts: true)
+ end
end
end
+ end
+
+ context 'with job name and optional false' do
+ let(:config) { { job: 'job_name', optional: false } }
+
+ it { is_expected.to be_valid }
it_behaves_like 'job type'
+
+ describe '#value' do
+ it 'returns job needs configuration' do
+ expect(need.value).to eq(name: 'job_name', artifacts: true, optional: false)
+ end
+ end
+ end
+
+ context 'with job name and optional nil' do
+ let(:config) { { job: 'job_name', optional: nil } }
+
+ it { is_expected.to be_valid }
+
+ it_behaves_like 'job type'
+
+ describe '#value' do
+ it 'returns job needs configuration' do
+ expect(need.value).to eq(name: 'job_name', artifacts: true, optional: false)
+ end
+ end
+ end
+
+ context 'without optional key' do
+ let(:config) { { job: 'job_name' } }
+
+ it { is_expected.to be_valid }
+
+ it_behaves_like 'job type'
+
+ describe '#value' do
+ it 'returns job needs configuration' do
+ expect(need.value).to eq(name: 'job_name', artifacts: true, optional: false)
+ end
+ end
end
context 'when job name is empty' do