Skip to content
Snippets Groups Projects
Commit e4aac7f3 authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Do not raise an error when trying to persist a job

parent aa290573
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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|
Loading
Loading
Loading
Loading
@@ -5,7 +5,7 @@ module Ci
Ci::EnsureStageService.new(project, current_user)
.execute(subject)
 
subject.save!
subject.save
end
end
end
Loading
Loading
Loading
Loading
@@ -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?
Loading
Loading
Loading
Loading
@@ -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
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