Commit e45a5003 authored by Max Woolf's avatar Max Woolf

Fix built-in template import creating duplicate audit logs

Added project events are now no longer created twice on import.

Changelog: fixed
EE: true
parent e223d9e4
...@@ -16,6 +16,10 @@ module EE ...@@ -16,6 +16,10 @@ module EE
override :execute override :execute
def execute def execute
if create_from_template?
return ::Projects::CreateFromTemplateService.new(current_user, params).execute
end
limit = params.delete(:repository_size_limit) limit = params.delete(:repository_size_limit)
mirror = ::Gitlab::Utils.to_boolean(params.delete(:mirror)) mirror = ::Gitlab::Utils.to_boolean(params.delete(:mirror))
mirror_user_id = current_user.id if mirror mirror_user_id = current_user.id if mirror
......
...@@ -184,6 +184,21 @@ RSpec.describe ProjectsController do ...@@ -184,6 +184,21 @@ RSpec.describe ProjectsController do
end end
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 context 'custom project templates' do
let(:project_template) { create(:project, :repository, :public, :metrics_dashboard_enabled, namespace: group) } let(:project_template) { create(:project, :repository, :public, :metrics_dashboard_enabled, namespace: group) }
let(:templates_params) do let(:templates_params) do
......
...@@ -13,6 +13,20 @@ RSpec.describe Projects::CreateService, '#execute' do ...@@ -13,6 +13,20 @@ RSpec.describe Projects::CreateService, '#execute' do
} }
end 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 context 'with a template project ID' do
before do before do
opts.merge!( 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