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
def initialize(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
def execute(job, save: true)
def execute!(job, save: true)
assign_pipeline_attributes(job)
Ci::Pipeline.transaction do
......
......@@ -35,7 +35,7 @@ module Ci
check_access!(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`.
new_build
......
......@@ -32,7 +32,7 @@ module Projects
# Create status notifying the deployment of pages
@status = build_commit_status
::Ci::Pipelines::AddJobService.new(@build.pipeline).execute(@status)
::Ci::Pipelines::AddJobService.new(@build.pipeline).execute!(@status)
@status.enqueue!
@status.run!
......
......@@ -100,7 +100,7 @@ module API
status.assign_attributes(attributes_for_keys(updatable_optional_attributes))
if status.valid?
::Ci::Pipelines::AddJobService.new(pipeline).execute(status, save: false)
::Ci::Pipelines::AddJobService.new(pipeline).execute!(status, save: false)
else
render_validation_error!(status)
end
......
......@@ -19,20 +19,20 @@ RSpec.describe Ci::Pipelines::AddJobService do
it 'assigns pipeline attributes to the job' do
expect do
service.execute(job)
service.execute!(job)
end.to change { job.slice(:pipeline, :project, :ref) }.to(
pipeline: pipeline, project: pipeline.project, ref: pipeline.ref
)
end
it 'returns the job itself' do
expect(service.execute(job)).to eq(job)
expect(service.execute!(job)).to eq(job)
end
it 'calls update_older_statuses_retried!' do
expect(job).to receive(:update_older_statuses_retried!)
service.execute(job)
service.execute!(job)
end
context 'when the FF ci_fix_commit_status_retried is disabled' do
......@@ -43,7 +43,7 @@ RSpec.describe Ci::Pipelines::AddJobService do
it 'does not call update_older_statuses_retried!' do
expect(job).not_to receive(:update_older_statuses_retried!)
service.execute(job)
service.execute!(job)
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