From a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 16 Jun 2021 18:25:58 +0000 Subject: Add latest changes from gitlab-org/gitlab@14-0-stable-ee --- .../gitlab/template/gitlab_ci_yml_template_spec.rb | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'spec/lib/gitlab/template') diff --git a/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb b/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb index 26c83ed6793..226fdb9c948 100644 --- a/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb +++ b/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb @@ -21,6 +21,55 @@ RSpec.describe Gitlab::Template::GitlabCiYmlTemplate do end end + describe '.find' do + let_it_be(:project) { create(:project) } + let_it_be(:other_project) { create(:project) } + + described_class::TEMPLATES_WITH_LATEST_VERSION.keys.each do |key| + it "finds the latest template for #{key}" do + result = described_class.find(key, project) + expect(result.full_name).to eq("#{key}.latest.gitlab-ci.yml") + expect(result.content).to be_present + end + + context 'when `redirect_to_latest_template` feature flag is disabled' do + before do + stub_feature_flags("redirect_to_latest_template_#{key.underscore.tr('/', '_')}".to_sym => false) + end + + it "finds the stable template for #{key}" do + result = described_class.find(key, project) + expect(result.full_name).to eq("#{key}.gitlab-ci.yml") + expect(result.content).to be_present + end + end + + context 'when `redirect_to_latest_template` feature flag is enabled on the project' do + before do + stub_feature_flags("redirect_to_latest_template_#{key.underscore.tr('/', '_')}".to_sym => project) + end + + it "finds the latest template for #{key}" do + result = described_class.find(key, project) + expect(result.full_name).to eq("#{key}.latest.gitlab-ci.yml") + expect(result.content).to be_present + end + end + + context 'when `redirect_to_latest_template` feature flag is enabled on the other project' do + before do + stub_feature_flags("redirect_to_latest_template_#{key.underscore.tr('/', '_')}".to_sym => other_project) + end + + it "finds the stable template for #{key}" do + result = described_class.find(key, project) + expect(result.full_name).to eq("#{key}.gitlab-ci.yml") + expect(result.content).to be_present + end + end + end + end + describe '#content' do it 'loads the full file' do gitignore = subject.new(Rails.root.join('lib/gitlab/ci/templates/Ruby.gitlab-ci.yml')) -- cgit v1.2.1