Add feature flag to enqueue restart build to Hub
This commit is contained in:
parent
9bbfb7ec97
commit
9bd145856b
|
@ -426,6 +426,3 @@ DEPENDENCIES
|
|||
travis-yaml!
|
||||
unicorn
|
||||
yard-sinatra!
|
||||
|
||||
BUNDLED WITH
|
||||
1.11.2
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
require 'travis/api/app'
|
||||
require 'travis/api/workers/build_cancellation'
|
||||
require 'travis/api/workers/build_restart'
|
||||
require 'travis/api/enqueue/services/enqueue_build'
|
||||
|
||||
class Travis::Api::App
|
||||
|
@ -54,8 +55,12 @@ class Travis::Api::App
|
|||
status 400
|
||||
result = false
|
||||
else
|
||||
payload = {id: params[:id], user_id: current_user.id}
|
||||
Travis::Enqueue::Services::EnqueueBuild.push("build:restart", payload)
|
||||
if Travis::Features.owner_active?(:enqueue_to_hub, current_user)
|
||||
payload = {id: params[:id], user_id: current_user.id}
|
||||
Travis::Enqueue::Services::EnqueueBuild.push("build:restart", payload)
|
||||
else
|
||||
Travis::Sidekiq::BuildRestart.perform_async(id: params[:id], user_id: current_user.id)
|
||||
end
|
||||
|
||||
status 202
|
||||
result = true
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
require 'sidekiq'
|
||||
require 'travis'
|
||||
require 'travis/api/workers/build_cancellation'
|
||||
require 'travis/api/workers/build_restart'
|
||||
require 'travis/api/workers/job_cancellation'
|
||||
require 'travis/api/workers/job_restart'
|
||||
require 'travis/support/amqp'
|
||||
|
|
|
@ -118,17 +118,36 @@ describe 'Builds' do
|
|||
build.update_attribute(:state, 'passed')
|
||||
end
|
||||
|
||||
it 'restarts the build' do
|
||||
Travis::Enqueue::Services::EnqueueBuild.expects(:push).with("build:restart", {id: build.id.to_s, user_id: user.id})
|
||||
response = post "/builds/#{build.id}/restart", {}, headers
|
||||
response.status.should == 202
|
||||
describe 'Enqueues restart event to the Hub' do
|
||||
before { Travis::Features.activate_owner(:enqueue_to_hub, repo.owner) }
|
||||
|
||||
it 'restarts the build' do
|
||||
Travis::Enqueue::Services::EnqueueBuild.expects(:push).with("build:restart", {id: build.id.to_s, user_id: user.id})
|
||||
response = post "/builds/#{build.id}/restart", {}, headers
|
||||
response.status.should == 202
|
||||
end
|
||||
|
||||
it 'sends the correct response body' do
|
||||
Travis::Enqueue::Services::EnqueueBuild.expects(:push).with("build:restart", {id: build.id.to_s, user_id: user.id})
|
||||
response = post "/builds/#{build.id}/restart", {}, headers
|
||||
body = JSON.parse(response.body)
|
||||
body.should == {"result"=>true, "flash"=>[{"notice"=>"The build was successfully restarted."}]}
|
||||
end
|
||||
end
|
||||
|
||||
it 'sends the correct response body' do
|
||||
Travis::Enqueue::Services::EnqueueBuild.expects(:push).with("build:restart", {id: build.id.to_s, user_id: user.id})
|
||||
response = post "/builds/#{build.id}/restart", {}, headers
|
||||
body = JSON.parse(response.body)
|
||||
body.should == {"result"=>true, "flash"=>[{"notice"=>"The build was successfully restarted."}]}
|
||||
describe 'Restart from the Core' do
|
||||
it 'restarts the build' do
|
||||
Travis::Sidekiq::BuildRestart.expects(:perform_async).with(id: build.id.to_s, user_id: user.id)
|
||||
response = post "/builds/#{build.id}/restart", {}, headers
|
||||
response.status.should == 202
|
||||
end
|
||||
|
||||
it 'sends the correct response body' do
|
||||
Travis::Sidekiq::BuildRestart.expects(:perform_async).with(id: build.id.to_s, user_id: user.id)
|
||||
response = post "/builds/#{build.id}/restart", {}, headers
|
||||
body = JSON.parse(response.body)
|
||||
body.should == {"result"=>true, "flash"=>[{"notice"=>"The build was successfully restarted."}]}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user