summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-03-27 14:39:43 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-03-27 14:39:43 +0200
commita745eadffb89abf74f5df0ccd57ec3c36ee054b9 (patch)
tree6136d78cb0abc78b3869d91150fd4df6b23e9034
parentb1ce3ba142d3b735eded44bb5490984042c9d2e1 (diff)
downloadgitlab-ce-a745eadffb89abf74f5df0ccd57ec3c36ee054b9.tar.gz
Improve specs for pipeline variables expressions policy
-rw-r--r--spec/lib/gitlab/ci/build/policy/variables_spec.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/spec/lib/gitlab/ci/build/policy/variables_spec.rb b/spec/lib/gitlab/ci/build/policy/variables_spec.rb
index fd259560a6d..2ce858836e3 100644
--- a/spec/lib/gitlab/ci/build/policy/variables_spec.rb
+++ b/spec/lib/gitlab/ci/build/policy/variables_spec.rb
@@ -4,7 +4,7 @@ describe Gitlab::Ci::Build::Policy::Variables do
set(:project) { create(:project) }
let(:pipeline) do
- build(:ci_empty_pipeline, project: project, ref: 'master')
+ build(:ci_empty_pipeline, project: project, ref: 'master', source: :push)
end
let(:ci_build) do
@@ -18,7 +18,7 @@ describe Gitlab::Ci::Build::Policy::Variables do
end
describe '#satisfied_by?' do
- it 'is satisfied by a defined and existing variable' do
+ it 'is satisfied by at least one matching statement' do
policy = described_class.new(['$CI_PROJECT_ID', '$UNDEFINED'])
expect(policy).to be_satisfied_by(pipeline, seed)
@@ -31,7 +31,7 @@ describe Gitlab::Ci::Build::Policy::Variables do
end
it 'is satisfied by a truthy pipeline expression' do
- policy = described_class.new([%($CI_PIPELINE_SOURCE == "#{pipeline.source}")])
+ policy = described_class.new([%($CI_PIPELINE_SOURCE == "push")])
expect(policy).to be_satisfied_by(pipeline, seed)
end
@@ -43,11 +43,17 @@ describe Gitlab::Ci::Build::Policy::Variables do
end
it 'is satisfied by a truthy expression using undefined variable' do
- policy = described_class.new(['$UNDEFINED', '$UNDEFINED == null'])
+ policy = described_class.new(['$UNDEFINED == null'])
expect(policy).to be_satisfied_by(pipeline, seed)
end
+ it 'is not satisfied by a falsy expression using undefined variable' do
+ policy = described_class.new(['$UNDEFINED'])
+
+ expect(policy).not_to be_satisfied_by(pipeline, seed)
+ end
+
it 'allows to evaluate regular secret variables' do
create(:ci_variable, project: project, key: 'SECRET', value: 'my secret')