add check for state on job restart and cancel
This commit is contained in:
parent
ec62a5b918
commit
506e0f0f7a
|
@ -35,6 +35,8 @@ module Travis
|
|||
NotImplemented = ServerError .create('request not (yet) implemented', status: 501)
|
||||
RequestLimitReached = ClientError .create('request limit reached for resource', status: 429)
|
||||
AlreadySyncing = ClientError .create('sync already in progress', status: 409)
|
||||
AlreadyRunning = ClientError .create('job already running', status: 409)
|
||||
NotCancelable = ClientError .create('job is not running, cannot canel', status: 409)
|
||||
MethodNotAllowed = ClientError .create('method not allowed', status: 405)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,12 +8,17 @@ module Travis::API::V3
|
|||
end
|
||||
|
||||
def cancel(user)
|
||||
puts find.state
|
||||
raise NotCancelable if %w(passed failed cancelled errored).include? find.state
|
||||
payload = { id: id, user_id: user.id, source: 'api' }
|
||||
perform_async(:job_cancellation, payload)
|
||||
payload
|
||||
end
|
||||
|
||||
def restart(user)
|
||||
puts find.state
|
||||
puts find.state.class
|
||||
raise AlreadyRunning if %w(received queued started).include? find.state
|
||||
payload = { id: id, user_id: user.id, source: 'api' }
|
||||
perform_async(:job_restart, payload)
|
||||
payload
|
||||
|
|
Loading…
Reference in New Issue
Block a user