Commit 7ba8f3fe authored by Stan Hu's avatar Stan Hu

Fix instance project templates no longer working

The introduction of group project templates in
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/7391
caused instance project templates to stop working. The
frontend submits an empty `group_with_project_templates_id`
parameter, which is interpreted as an actual value to search.
We fix this by ignoring blank parameters.

Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/9038
parent 52fafda0
......@@ -28,10 +28,14 @@ module EE
def template_project
strong_memoize(:template_project) do
current_user.available_custom_project_templates(search: template_name, subgroup_id: params[:group_with_project_templates_id])
current_user.available_custom_project_templates(search: template_name, subgroup_id: subgroup_id)
.first
end
end
def subgroup_id
params[:group_with_project_templates_id].presence
end
end
end
end
---
title: Fix instance project templates no longer working
merge_request: 9019
author:
type: fixed
......@@ -69,9 +69,10 @@ describe Projects::CreateFromTemplateService do
end
end
context 'creates project from custom template' do
shared_examples 'creates project from custom template' do |subgroup_id|
# If we move the project inside a let block it throws a SEGFAULT error
before do
project_params[:group_with_project_templates_id] = subgroup_id
@project = subject.execute
end
......@@ -91,6 +92,9 @@ describe Projects::CreateFromTemplateService do
end
end
it_behaves_like 'creates project from custom template', nil
it_behaves_like 'creates project from custom template', ''
describe 'creating project from a Group project template', :postgresql do
let(:project_name) { project_template.name }
let(:group_with_project_templates_id) { subgroup_1.id }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment