summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/config/entry/trigger_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/ci/config/entry/trigger_spec.rb')
-rw-r--r--spec/lib/gitlab/ci/config/entry/trigger_spec.rb92
1 files changed, 62 insertions, 30 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/trigger_spec.rb b/spec/lib/gitlab/ci/config/entry/trigger_spec.rb
index 5b4289741f3..d0116c961d7 100644
--- a/spec/lib/gitlab/ci/config/entry/trigger_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/trigger_spec.rb
@@ -34,7 +34,7 @@ RSpec.describe Gitlab::Ci::Config::Entry::Trigger do
end
end
- context 'when trigger is a hash' do
+ context 'when trigger is a hash - cross-project' do
context 'when branch is provided' do
let(:config) { { project: 'some/project', branch: 'feature' } }
@@ -82,52 +82,84 @@ RSpec.describe Gitlab::Ci::Config::Entry::Trigger do
end
end
- describe '#include' do
- context 'with simple include' do
- let(:config) { { include: 'path/to/config.yml' } }
+ context 'when config contains unknown keys' do
+ let(:config) { { project: 'some/project', unknown: 123 } }
- it { is_expected.to be_valid }
+ describe '#valid?' do
+ it { is_expected.not_to be_valid }
+ end
- it 'returns a trigger configuration hash' do
- expect(subject.value).to eq(include: 'path/to/config.yml' )
+ describe '#errors' do
+ it 'returns an error about unknown config key' do
+ expect(subject.errors.first)
+ .to match /config contains unknown keys: unknown/
end
end
+ end
- context 'with project' do
- let(:config) { { project: 'some/project', include: 'path/to/config.yml' } }
+ context 'with forward' do
+ let(:config) { { project: 'some/project', forward: { pipeline_variables: true } } }
- it { is_expected.not_to be_valid }
+ before do
+ subject.compose!
+ end
- it 'returns an error' do
- expect(subject.errors.first)
- .to match /config contains unknown keys: project/
- end
+ it { is_expected.to be_valid }
+
+ it 'returns a trigger configuration hash' do
+ expect(subject.value).to eq(
+ project: 'some/project', forward: { pipeline_variables: true }
+ )
end
+ end
+ end
- context 'with branch' do
- let(:config) { { branch: 'feature', include: 'path/to/config.yml' } }
+ context 'when trigger is a hash - parent-child' do
+ context 'with simple include' do
+ let(:config) { { include: 'path/to/config.yml' } }
- it { is_expected.not_to be_valid }
+ it { is_expected.to be_valid }
- it 'returns an error' do
- expect(subject.errors.first)
- .to match /config contains unknown keys: branch/
- end
+ it 'returns a trigger configuration hash' do
+ expect(subject.value).to eq(include: 'path/to/config.yml' )
end
end
- context 'when config contains unknown keys' do
- let(:config) { { project: 'some/project', unknown: 123 } }
+ context 'with project' do
+ let(:config) { { project: 'some/project', include: 'path/to/config.yml' } }
- describe '#valid?' do
- it { is_expected.not_to be_valid }
+ it { is_expected.not_to be_valid }
+
+ it 'returns an error' do
+ expect(subject.errors.first)
+ .to match /config contains unknown keys: project/
end
+ end
- describe '#errors' do
- it 'returns an error about unknown config key' do
- expect(subject.errors.first)
- .to match /config contains unknown keys: unknown/
- end
+ context 'with branch' do
+ let(:config) { { branch: 'feature', include: 'path/to/config.yml' } }
+
+ it { is_expected.not_to be_valid }
+
+ it 'returns an error' do
+ expect(subject.errors.first)
+ .to match /config contains unknown keys: branch/
+ end
+ end
+
+ context 'with forward' do
+ let(:config) { { include: 'path/to/config.yml', forward: { yaml_variables: false } } }
+
+ before do
+ subject.compose!
+ end
+
+ it { is_expected.to be_valid }
+
+ it 'returns a trigger configuration hash' do
+ expect(subject.value).to eq(
+ include: 'path/to/config.yml', forward: { yaml_variables: false }
+ )
end
end
end