Respond with 409 to POST '/users/sync' if sync is in progress
Fixes travis-ci/travis-ci#1659. [Henrik Hodne: squashed commits]
This commit is contained in:
parent
6069f429cd
commit
5517623265
|
@ -47,7 +47,12 @@ class Travis::Api::App
|
|||
end
|
||||
|
||||
post '/sync', scope: :private do
|
||||
respond_with service(:sync_user)
|
||||
if current_user.syncing?
|
||||
status 409
|
||||
{ 'message' => "Sync already in progress. Try again later." }
|
||||
else
|
||||
respond_with service(:sync_user)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,4 +29,19 @@ describe Travis::Api::App::Endpoint::Users do
|
|||
'correct_scopes' => true,
|
||||
}
|
||||
end
|
||||
|
||||
context 'when responding to POST for /users/sync' do
|
||||
context 'when sync is in progress' do
|
||||
before :each do
|
||||
user.stubs(:syncing?).returns(true)
|
||||
end
|
||||
|
||||
it 'returns 409' do
|
||||
response = post('/users/sync', { access_token: access_token.to_s }, 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json, */*; q=0.01')
|
||||
|
||||
response.status.should == 409
|
||||
JSON.parse(response.body).should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user