Skip to content
Snippets Groups Projects
Commit 33360b3c authored by Robert Speicher's avatar Robert Speicher
Browse files

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

Former-commit-id: 0497d3ea
parents 431ee8b9 9dd7cf60
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment