This instance will be upgraded to Heptapod 0.31.0 (final) on 2022-05-24 at 14:00 UTC+2 (a few minutes of down time)

Commit 8f035cdd authored by Tiago Botelho's avatar Tiago Botelho
Browse files

Project creation does not fail silently on DB related changes

parent d9265dc16b0b
......@@ -90,9 +90,6 @@ def after_create_actions
unless @project.gitlab_project_import?
@project.write_repository_config
@project.create_wiki unless skip_wiki?
create_services_from_active_templates(@project)
@project.create_labels
end
event_service.create_project(@project, current_user)
......@@ -121,21 +118,27 @@ def save_project_and_import_data(import_data)
Project.transaction do
@project.create_or_update_import_data(data: import_data[:data], credentials: import_data[:credentials]) if import_data
if @project.save && !@project.import?
raise 'Failed to create repository' unless @project.create_repository
if @project.save
unless @project.gitlab_project_import?
create_services_from_active_templates(@project)
@project.create_labels
end
unless @project.import?
raise 'Failed to create repository' unless @project.create_repository
end
end
end
end
def fail(error:)
message = "Unable to save project. Error: #{error}"
message << "Project ID: #{@project.id}" if @project && @project.id
Rails.logger.error(message)
if @project && @project.import?
if @project
@project.errors.add(:base, message)
@project.mark_import_as_failed(message)
@project.mark_import_as_failed(message) if @project.import?
end
@project
......
---
title: Project creation will now raise an error if a service template is invalid
merge_request: 18013
author:
type: fixed
......@@ -70,6 +70,16 @@
opts[:default_branch] = 'master'
expect(create_project(user, opts)).to eq(nil)
end
it 'handles invalid service' do
create(:service, type: 'JiraService', project: nil, template: true, active: true)
project = create_project(user, opts)
expect(project).not_to be_persisted
expect(project.errors.full_messages_for(:base).first).to match(/Unable to save project. Error: Unable to save JiraService/)
expect(project.services.count).to eq 0
end
end
context 'wiki_enabled creates repository directory' do
......
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