diff options
Diffstat (limited to 'spec/lib/gitlab/ci/build/rules/rule/clause/changes_spec.rb')
-rw-r--r-- | spec/lib/gitlab/ci/build/rules/rule/clause/changes_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/build/rules/rule/clause/changes_spec.rb b/spec/lib/gitlab/ci/build/rules/rule/clause/changes_spec.rb index cf52f601006..d20ea6c9202 100644 --- a/spec/lib/gitlab/ci/build/rules/rule/clause/changes_spec.rb +++ b/spec/lib/gitlab/ci/build/rules/rule/clause/changes_spec.rb @@ -13,5 +13,47 @@ RSpec.describe Gitlab::Ci::Build::Rules::Rule::Clause::Changes do subject { described_class.new(globs).satisfied_by?(pipeline, nil) } end + + context 'when using variable expansion' do + let(:pipeline) { build(:ci_pipeline) } + let(:modified_paths) { ['helm/test.txt'] } + let(:globs) { ['$HELM_DIR/**/*'] } + let(:context) { double('context') } + + subject { described_class.new(globs).satisfied_by?(pipeline, context) } + + before do + allow(pipeline).to receive(:modified_paths).and_return(modified_paths) + end + + context 'when context is nil' do + let(:context) {} + + it { is_expected.to be_falsey } + end + + context 'when context has the specified variables' do + let(:variables) do + [{ key: "HELM_DIR", value: "helm", public: true }] + end + + before do + allow(context).to receive(:variables).and_return(variables) + end + + it { is_expected.to be_truthy } + end + + context 'when variable expansion does not match' do + let(:globs) { ['path/with/$in/it/*'] } + let(:modified_paths) { ['path/with/$in/it/file.txt'] } + + before do + allow(context).to receive(:variables).and_return([]) + end + + it { is_expected.to be_truthy } + end + end end end |