diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/lib/gitlab/template | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) | |
download | gitlab-ce-a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4.tar.gz |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/lib/gitlab/template')
-rw-r--r-- | spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
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')) |