diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-12 06:09:05 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-12 06:09:05 +0000 |
commit | 8c9dc985b90c353b33cb829caf51f8320171bc15 (patch) | |
tree | 9a68886dbea1aefabddb46bbd3faf961eab22ae6 /spec/lib/gitlab/ci/build | |
parent | 500626a5c953ad81cfc3ed74bf0148c075617e58 (diff) | |
download | gitlab-ce-8c9dc985b90c353b33cb829caf51f8320171bc15.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/ci/build')
-rw-r--r-- | spec/lib/gitlab/ci/build/rules_spec.rb | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/spec/lib/gitlab/ci/build/rules_spec.rb b/spec/lib/gitlab/ci/build/rules_spec.rb index 1ebcc4f9414..31a9fa055e1 100644 --- a/spec/lib/gitlab/ci/build/rules_spec.rb +++ b/spec/lib/gitlab/ci/build/rules_spec.rb @@ -102,9 +102,9 @@ describe Gitlab::Ci::Build::Rules do end context 'with one rule without any clauses' do - let(:rule_list) { [{ when: 'manual' }] } + let(:rule_list) { [{ when: 'manual', allow_failure: true }] } - it { is_expected.to eq(described_class::Result.new('manual')) } + it { is_expected.to eq(described_class::Result.new('manual', nil, true)) } end context 'with one matching rule' do @@ -166,5 +166,51 @@ describe Gitlab::Ci::Build::Rules do end end end + + context 'with only allow_failure' do + context 'with matching rule' do + let(:rule_list) { [{ if: '$VAR == null', allow_failure: true }] } + + it { is_expected.to eq(described_class::Result.new('on_success', nil, true)) } + end + + context 'with non-matching rule' do + let(:rule_list) { [{ if: '$VAR != null', allow_failure: true }] } + + it { is_expected.to eq(described_class::Result.new('never')) } + end + end + end + + describe 'Gitlab::Ci::Build::Rules::Result' do + let(:when_value) { 'on_success' } + let(:start_in) { nil } + let(:allow_failure) { nil } + + subject { Gitlab::Ci::Build::Rules::Result.new(when_value, start_in, allow_failure) } + + describe '#build_attributes' do + it 'compacts nil values' do + expect(subject.build_attributes).to eq(options: {}, when: 'on_success') + end + end + + describe '#pass?' do + context "'when' is 'never'" do + let!(:when_value) { 'never' } + + it 'returns false' do + expect(subject.pass?).to eq(false) + end + end + + context "'when' is 'on_success'" do + let!(:when_value) { 'on_success' } + + it 'returns true' do + expect(subject.pass?).to eq(true) + end + end + end end end |