Commit b4f2e859 authored by Furkan Ayhan's avatar Furkan Ayhan Committed by Fabio Pitino

Change the service method name

parent 096a7c43
...@@ -8,10 +8,10 @@ module Ci ...@@ -8,10 +8,10 @@ module Ci
def initialize(pipeline) def initialize(pipeline)
@pipeline = pipeline @pipeline = pipeline
raise "Pipeline must be persisted for this service to be used" unless @pipeline.persisted? raise ArgumentError, "Pipeline must be persisted for this service to be used" unless @pipeline.persisted?
end end
def execute(job, save: true) def execute!(job, save: true)
assign_pipeline_attributes(job) assign_pipeline_attributes(job)
Ci::Pipeline.transaction do Ci::Pipeline.transaction do
......
...@@ -35,7 +35,7 @@ module Ci ...@@ -35,7 +35,7 @@ module Ci
check_access!(build) check_access!(build)
new_build = clone_build(build) new_build = clone_build(build)
::Ci::Pipelines::AddJobService.new(build.pipeline).execute(new_build) ::Ci::Pipelines::AddJobService.new(build.pipeline).execute!(new_build)
build.reset # refresh the data to get new values of `retried` and `processed`. build.reset # refresh the data to get new values of `retried` and `processed`.
new_build new_build
......
...@@ -32,7 +32,7 @@ module Projects ...@@ -32,7 +32,7 @@ module Projects
# Create status notifying the deployment of pages # Create status notifying the deployment of pages
@status = build_commit_status @status = build_commit_status
::Ci::Pipelines::AddJobService.new(@build.pipeline).execute(@status) ::Ci::Pipelines::AddJobService.new(@build.pipeline).execute!(@status)
@status.enqueue! @status.enqueue!
@status.run! @status.run!
......
...@@ -100,7 +100,7 @@ module API ...@@ -100,7 +100,7 @@ module API
status.assign_attributes(attributes_for_keys(updatable_optional_attributes)) status.assign_attributes(attributes_for_keys(updatable_optional_attributes))
if status.valid? if status.valid?
::Ci::Pipelines::AddJobService.new(pipeline).execute(status, save: false) ::Ci::Pipelines::AddJobService.new(pipeline).execute!(status, save: false)
else else
render_validation_error!(status) render_validation_error!(status)
end end
......
...@@ -19,20 +19,20 @@ RSpec.describe Ci::Pipelines::AddJobService do ...@@ -19,20 +19,20 @@ RSpec.describe Ci::Pipelines::AddJobService do
it 'assigns pipeline attributes to the job' do it 'assigns pipeline attributes to the job' do
expect do expect do
service.execute(job) service.execute!(job)
end.to change { job.slice(:pipeline, :project, :ref) }.to( end.to change { job.slice(:pipeline, :project, :ref) }.to(
pipeline: pipeline, project: pipeline.project, ref: pipeline.ref pipeline: pipeline, project: pipeline.project, ref: pipeline.ref
) )
end end
it 'returns the job itself' do it 'returns the job itself' do
expect(service.execute(job)).to eq(job) expect(service.execute!(job)).to eq(job)
end end
it 'calls update_older_statuses_retried!' do it 'calls update_older_statuses_retried!' do
expect(job).to receive(:update_older_statuses_retried!) expect(job).to receive(:update_older_statuses_retried!)
service.execute(job) service.execute!(job)
end end
context 'when the FF ci_fix_commit_status_retried is disabled' do context 'when the FF ci_fix_commit_status_retried is disabled' do
...@@ -43,7 +43,7 @@ RSpec.describe Ci::Pipelines::AddJobService do ...@@ -43,7 +43,7 @@ RSpec.describe Ci::Pipelines::AddJobService do
it 'does not call update_older_statuses_retried!' do it 'does not call update_older_statuses_retried!' do
expect(job).not_to receive(:update_older_statuses_retried!) expect(job).not_to receive(:update_older_statuses_retried!)
service.execute(job) service.execute!(job)
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment