Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/ci/config/external/file/template_spec.rb')
-rw-r--r--spec/lib/gitlab/ci/config/external/file/template_spec.rb27
1 files changed, 22 insertions, 5 deletions
diff --git a/spec/lib/gitlab/ci/config/external/file/template_spec.rb b/spec/lib/gitlab/ci/config/external/file/template_spec.rb
index 66a06de3d28..4da9a933a9f 100644
--- a/spec/lib/gitlab/ci/config/external/file/template_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/file/template_spec.rb
@@ -45,12 +45,15 @@ RSpec.describe Gitlab::Ci::Config::External::File::Template do
end
describe "#valid?" do
+ subject(:valid?) do
+ template_file.validate!
+ template_file.valid?
+ end
+
context 'when is a valid template name' do
let(:template) { 'Auto-DevOps.gitlab-ci.yml' }
- it 'returns true' do
- expect(template_file).to be_valid
- end
+ it { is_expected.to be_truthy }
end
context 'with invalid template name' do
@@ -59,7 +62,7 @@ RSpec.describe Gitlab::Ci::Config::External::File::Template do
let(:context_params) { { project: project, sha: '12345', user: user, variables: variables } }
it 'returns false' do
- expect(template_file).not_to be_valid
+ expect(valid?).to be_falsy
expect(template_file.error_message).to include('`xxxxxxxxxxxxxx.yml` is not a valid location!')
end
end
@@ -68,7 +71,7 @@ RSpec.describe Gitlab::Ci::Config::External::File::Template do
let(:template) { 'I-Do-Not-Have-This-Template.gitlab-ci.yml' }
it 'returns false' do
- expect(template_file).not_to be_valid
+ expect(valid?).to be_falsy
expect(template_file.error_message).to include('Included file `I-Do-Not-Have-This-Template.gitlab-ci.yml` is empty or does not exist!')
end
end
@@ -111,4 +114,18 @@ RSpec.describe Gitlab::Ci::Config::External::File::Template do
is_expected.to be_empty
end
end
+
+ describe '#metadata' do
+ subject(:metadata) { template_file.metadata }
+
+ it {
+ is_expected.to eq(
+ context_project: project.full_path,
+ context_sha: '12345',
+ type: :template,
+ location: template,
+ extra: {}
+ )
+ }
+ end
end