Commit 25b17a15 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '210001-project-import-double-events' into 'master'

Fix built-in template import creating duplicate audit logs

See merge request gitlab-org/gitlab!73822
parents 113c8224 e45a5003
......@@ -16,6 +16,10 @@ module EE
override :execute
def execute
if create_from_template?
return ::Projects::CreateFromTemplateService.new(current_user, params).execute
end
limit = params.delete(:repository_size_limit)
mirror = ::Gitlab::Utils.to_boolean(params.delete(:mirror))
mirror_user_id = current_user.id if mirror
......
......@@ -184,6 +184,21 @@ RSpec.describe ProjectsController do
end
end
context 'built in project templates' do
let(:templates_params) do
{
path: 'foo',
description: 'bar',
namespace_id: user.namespace.id,
template_name: 'rails'
}
end
it 'creates one audit event' do
expect { post :create, params: { project: templates_params } }.to change { AuditEvent.count }.by(1)
end
end
context 'custom project templates' do
let(:project_template) { create(:project, :repository, :public, :metrics_dashboard_enabled, namespace: group) }
let(:templates_params) do
......
......@@ -13,6 +13,20 @@ RSpec.describe Projects::CreateService, '#execute' do
}
end
context 'with a built-in template' do
before do
opts.merge!(
template_name: 'rails'
)
end
it 'creates a project using the template service' do
expect(::Projects::CreateFromTemplateService).to receive_message_chain(:new, :execute)
create_project(user, opts)
end
end
context 'with a template project ID' do
before do
opts.merge!(
......
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