Remove push_matrix method, no need of it
This commit is contained in:
parent
29f80ab31b
commit
00bae7a945
|
@ -46,8 +46,8 @@ class Travis::Api::App
|
|||
status 422
|
||||
respond_with json
|
||||
else
|
||||
if service.respond_to?(:enqueue_to_hub)
|
||||
service.enqueue_to_hub
|
||||
if service.respond_to?(:push)
|
||||
service.push
|
||||
else
|
||||
Travis::Sidekiq::BuildCancellation.perform_async(id: params[:id], user_id: current_user.id, source: 'api')
|
||||
end
|
||||
|
|
|
@ -53,8 +53,8 @@ class Travis::Api::App
|
|||
status 422
|
||||
respond_with json
|
||||
else
|
||||
if service.respond_to?(:enqueue_to_hub)
|
||||
service.enqueue_to_hub
|
||||
if service.respond_to?(:push)
|
||||
service.push
|
||||
else
|
||||
Travis::Sidekiq::JobCancellation.perform_async(id: params[:id], user_id: current_user.id, source: 'api')
|
||||
end
|
||||
|
|
|
@ -20,35 +20,17 @@ module Travis
|
|||
messages
|
||||
end
|
||||
|
||||
def enqueue_to_hub
|
||||
def push
|
||||
# target may have been retrieved with a :join query, so we need to reset the readonly status
|
||||
if can_cancel?
|
||||
target.send(:instance_variable_set, :@readonly, false)
|
||||
target.cancel!
|
||||
|
||||
if type == :build
|
||||
push_matrix(@params)
|
||||
else
|
||||
push(@params, target)
|
||||
end
|
||||
::Sidekiq::Client.push(
|
||||
'queue' => 'hub',
|
||||
'class' => 'Travis::Hub::Sidekiq::Worker',
|
||||
'args' => ["#{type}:cancel", @params]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def push_matrix(payload)
|
||||
target.matrix.each do |job|
|
||||
push(payload, job)
|
||||
end
|
||||
end
|
||||
|
||||
def push(payload, job)
|
||||
Travis.logger.info("Publishing cancel_job message to worker.commands queue for Job##{job.id}")
|
||||
::Sidekiq::Client.push(
|
||||
'queue' => 'hub',
|
||||
'class' => 'Travis::Hub::Sidekiq::Worker',
|
||||
'args' => ["#{type}:cancel", payload]
|
||||
)
|
||||
end
|
||||
|
||||
def type
|
||||
@type ||= @params[:build_id] ? :build : :job
|
||||
end
|
||||
|
@ -70,7 +52,6 @@ module Travis
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -122,12 +122,12 @@ describe 'Builds' do
|
|||
end
|
||||
|
||||
it 'cancels the build' do
|
||||
::Sidekiq::Client.expects(:push).times(4)
|
||||
::Sidekiq::Client.expects(:push)
|
||||
post "/builds/#{build.id}/cancel", {}, headers
|
||||
end
|
||||
|
||||
it 'responds with 204' do
|
||||
::Sidekiq::Client.expects(:push).times(4)
|
||||
::Sidekiq::Client.expects(:push)
|
||||
response = post "/builds/#{build.id}/cancel", {}, headers
|
||||
response.status.should == 204
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user