提交 460fb1fa 编写于 作者: S Stan Hu

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

上级 7d7dfee4
......@@ -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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册