Commit 5d17cd6e authored by Stan Hu's avatar Stan Hu

Merge branch '267000-create-from-template-inherit-integrations' into 'master'

Create a project from templates inherit integrations

See merge request gitlab-org/gitlab!44932
parents 60a14e9b 795f0c87
......@@ -165,10 +165,9 @@ module Projects
@project.create_or_update_import_data(data: @import_data[:data], credentials: @import_data[:credentials]) if @import_data
if @project.save
unless @project.gitlab_project_import?
Service.create_from_active_default_integrations(@project, :project_id, with_templates: true)
@project.create_labels
end
Service.create_from_active_default_integrations(@project, :project_id, with_templates: true)
@project.create_labels unless @project.gitlab_project_import?
unless @project.import?
raise 'Failed to create repository' unless @project.create_repository
......
---
title: Projects created from templates inherits integrations.
merge_request: 44932
author:
type: changed
......@@ -14,15 +14,30 @@ RSpec.describe Projects::CreateService, '#execute' do
}
end
it 'creates labels on Project creation if there are templates' do
Label.create!(title: "bug", template: true)
project = create_project(user, opts)
context 'with labels' do
subject(:project) { create_project(user, opts) }
before_all do
Label.create!(title: 'bug', template: true)
end
created_label = project.reload.labels.last
it 'creates labels on project creation' do
created_label = project.labels.last
expect(created_label.type).to eq('ProjectLabel')
expect(created_label.project_id).to eq(project.id)
expect(created_label.title).to eq('bug')
expect(created_label.type).to eq('ProjectLabel')
expect(created_label.project_id).to eq(project.id)
expect(created_label.title).to eq('bug')
end
context 'using gitlab project import' do
before do
opts[:import_type] = 'gitlab_project'
end
it 'does not creates labels on project creation' do
expect(project.labels.size).to eq(0)
end
end
end
context 'user namespace' do
......@@ -59,10 +74,6 @@ RSpec.describe Projects::CreateService, '#execute' do
context "admin creates project with other user's namespace_id" do
it 'sets the correct permissions' do
admin = create(:admin)
opts = {
name: 'GitLab',
namespace_id: user.namespace.id
}
project = create_project(admin, opts)
expect(project).to be_persisted
......
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