Commit c3a03de7 authored by Robert Speicher's avatar Robert Speicher Committed by Felipe Artur

Merge branch 'sh-improve-logging-for-bad-creations' into 'master'

Improve error messages when a record is unable to be created for a project

See merge request !10696
parent 07061046
......@@ -58,6 +58,9 @@ module Projects
fail(error: @project.errors.full_messages.join(', '))
end
@project
rescue ActiveRecord::RecordInvalid => e
message = "Unable to save #{e.record.type}: #{e.record.errors.full_messages.join(", ")} "
fail(error: message)
rescue => e
fail(error: e.message)
end
......
......@@ -144,6 +144,20 @@ describe Projects::CreateService, '#execute', services: true do
end
end
context 'when a bad service template is created' do
before do
create(:service, type: 'DroneCiService', project: nil, template: true, active: true)
end
it 'reports an error in the imported project' do
opts[:import_url] = 'http://www.gitlab.com/gitlab-org/gitlab-ce'
project = create_project(user, opts)
expect(project.errors.full_messages_for(:base).first).to match /Unable to save project. Error: Unable to save DroneCiService/
expect(project.services.count).to eq 0
end
end
def create_project(user, opts)
Projects::CreateService.new(user, opts).execute
end
......
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