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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
e4aac7f3
Commit
e4aac7f3
authored
Jan 24, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not raise an error when trying to persist a job
parent
aa290573
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
4 deletions
+10
-4
app/models/commit_status.rb
app/models/commit_status.rb
+2
-2
app/services/ci/create_job_service.rb
app/services/ci/create_job_service.rb
+1
-1
lib/api/commit_statuses.rb
lib/api/commit_statuses.rb
+1
-1
spec/services/ci/create_job_service_spec.rb
spec/services/ci/create_job_service_spec.rb
+6
-0
No files found.
app/models/commit_status.rb
View file @
e4aac7f3
...
...
@@ -51,8 +51,8 @@ class CommitStatus < ActiveRecord::Base
# We still create some CommitStatuses outside of CreatePipelineService.
#
# These are pages deployments and external statuses. We now handle these
#
using CreateJobService, but we still need to ensure that a job has a
# stage assigned. TODO, In future releases we will add model validation.
#
jobs using CreateJobService, but we still need to ensure that a job has
#
a
stage assigned. TODO, In future releases we will add model validation.
#
before_create
unless: :importing?
do
Ci
::
EnsureStageService
.
new
(
project
,
user
).
execute
(
self
)
do
|
stage
|
...
...
app/services/ci/create_job_service.rb
View file @
e4aac7f3
...
...
@@ -5,7 +5,7 @@ module Ci
Ci
::
EnsureStageService
.
new
(
project
,
current_user
)
.
execute
(
subject
)
subject
.
save
!
subject
.
save
end
end
end
...
...
lib/api/commit_statuses.rb
View file @
e4aac7f3
...
...
@@ -96,7 +96,7 @@ module API
if
status
.
new_record?
Ci
::
CreateJobService
.
new
(
@project
,
current_user
).
execute
(
status
)
else
status
.
save
!
status
.
save
if
status
.
changed?
end
render_validation_error!
(
status
)
if
status
.
invalid?
...
...
spec/services/ci/create_job_service_spec.rb
View file @
e4aac7f3
...
...
@@ -17,4 +17,10 @@ describe Ci::CreateJobService, '#execute' do
it
'ensures that a job has a stage assigned'
do
expect
(
service
.
execute
(
status
).
stage_id
).
to
be_present
end
it
'does not raise error if status is invalid'
do
status
.
name
=
nil
expect
(
service
.
execute
(
status
)).
not_to
be_persisted
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