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.rb44
1 files changed, 43 insertions, 1 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/trigger_spec.rb b/spec/lib/gitlab/ci/config/entry/trigger_spec.rb
index d0116c961d7..f47923af45a 100644
--- a/spec/lib/gitlab/ci/config/entry/trigger_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/trigger_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Gitlab::Ci::Config::Entry::Trigger do
+RSpec.describe Gitlab::Ci::Config::Entry::Trigger, feature_category: :pipeline_authoring do
subject { described_class.new(config) }
context 'when trigger config is a non-empty string' do
@@ -35,6 +35,48 @@ RSpec.describe Gitlab::Ci::Config::Entry::Trigger do
end
context 'when trigger is a hash - cross-project' do
+ context 'when project is a string' do
+ context 'when project is a non-empty string' do
+ let(:config) { { project: 'some/project' } }
+
+ it 'is valid' do
+ expect(subject).to be_valid
+ end
+ end
+
+ context 'when project is an empty string' do
+ let(:config) { { project: '' } }
+
+ it 'returns error' do
+ expect(subject).not_to be_valid
+ expect(subject.errors.first)
+ .to match /project can't be blank/
+ end
+ end
+ end
+
+ context 'when project is not a string' do
+ context 'when project is an array' do
+ let(:config) { { project: ['some/project'] } }
+
+ it 'returns error' do
+ expect(subject).not_to be_valid
+ expect(subject.errors.first)
+ .to match /should be a string/
+ end
+ end
+
+ context 'when project is a boolean' do
+ let(:config) { { project: true } }
+
+ it 'returns error' do
+ expect(subject).not_to be_valid
+ expect(subject.errors.first)
+ .to match /should be a string/
+ end
+ end
+ end
+
context 'when branch is provided' do
let(:config) { { project: 'some/project', branch: 'feature' } }