Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
460fb1fa
Commit
460fb1fa
authored
Apr 13, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve error messages when a record is unable to be created for a project
parent
7d7dfee4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
app/services/projects/create_service.rb
app/services/projects/create_service.rb
+3
-0
spec/services/projects/create_service_spec.rb
spec/services/projects/create_service_spec.rb
+14
-0
No files found.
app/services/projects/create_service.rb
View file @
460fb1fa
...
@@ -58,6 +58,9 @@ module Projects
...
@@ -58,6 +58,9 @@ module Projects
fail
(
error:
@project
.
errors
.
full_messages
.
join
(
', '
))
fail
(
error:
@project
.
errors
.
full_messages
.
join
(
', '
))
end
end
@project
@project
rescue
ActiveRecord
::
RecordInvalid
=>
e
message
=
"Unable to save
#{
e
.
record
.
type
}
:
#{
e
.
record
.
errors
.
full_messages
.
join
(
", "
)
}
"
fail
(
error:
message
)
rescue
=>
e
rescue
=>
e
fail
(
error:
e
.
message
)
fail
(
error:
e
.
message
)
end
end
...
...
spec/services/projects/create_service_spec.rb
View file @
460fb1fa
...
@@ -144,6 +144,20 @@ describe Projects::CreateService, '#execute', services: true do
...
@@ -144,6 +144,20 @@ describe Projects::CreateService, '#execute', services: true do
end
end
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
)
def
create_project
(
user
,
opts
)
Projects
::
CreateService
.
new
(
user
,
opts
).
execute
Projects
::
CreateService
.
new
(
user
,
opts
).
execute
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment