rename endpoint to users and fix endpoint specs
This commit is contained in:
parent
fbd89ceeb0
commit
81022ea7b4
|
@ -40,7 +40,7 @@ GIT
|
|||
|
||||
GIT
|
||||
remote: git://github.com/travis-ci/travis-core.git
|
||||
revision: a4b1446e3746a5ff59a5438a34f7b2471e33a731
|
||||
revision: 6d8de39fa098965aad52b51f8f9a3f5490e7def5
|
||||
branch: sf-more-services
|
||||
specs:
|
||||
travis-core (0.0.1)
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'travis/api/app'
|
|||
|
||||
class Travis::Api::App
|
||||
class Endpoint
|
||||
class User < Endpoint
|
||||
class Users < Endpoint
|
||||
# Gives information about the currently logged in user.
|
||||
#
|
||||
# Example:
|
24
spec/endpoint/accounts_spec.rb
Normal file
24
spec/endpoint/accounts_spec.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Travis::Api::App::Endpoint::Accounts do
|
||||
include Travis::Testing::Stubs
|
||||
let(:access_token) { Travis::Api::App::AccessToken.create(user: user, app_id: -1) }
|
||||
|
||||
before do
|
||||
User.stubs(:find_by_github_id).returns(user)
|
||||
User.stubs(:find).returns(user)
|
||||
user.stubs(:repositories).returns(stub(administratable: stub(select: [repository])))
|
||||
user.stubs(:attributes).returns(:id => user.id, :login => user.login, :name => user.name)
|
||||
end
|
||||
|
||||
it 'includes accounts' do
|
||||
get('/accounts', access_token: access_token.to_s).should be_ok
|
||||
parsed_body['accounts'].should == [{
|
||||
'id' => user.id,
|
||||
'login' => user.login,
|
||||
'name' => user.name,
|
||||
'type' => 'user',
|
||||
'reposCount' => nil
|
||||
}]
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Travis::Api::App::Endpoint::Profile do
|
||||
describe Travis::Api::App::Endpoint::Users do
|
||||
include Travis::Testing::Stubs
|
||||
let(:access_token) { Travis::Api::App::AccessToken.create(user: user, app_id: -1) }
|
||||
|
||||
|
@ -11,11 +11,11 @@ describe Travis::Api::App::Endpoint::Profile do
|
|||
end
|
||||
|
||||
it 'needs to be authenticated' do
|
||||
get('/profile').should_not be_ok
|
||||
get('/users').should_not be_ok
|
||||
end
|
||||
|
||||
it 'replies with the current user' do
|
||||
get('/profile', access_token: access_token.to_s).should be_ok
|
||||
get('/users', access_token: access_token.to_s).should be_ok
|
||||
parsed_body['user'].should == {
|
||||
'id' => user.id,
|
||||
'login' => user.login,
|
||||
|
@ -27,15 +27,4 @@ describe Travis::Api::App::Endpoint::Profile do
|
|||
'synced_at' => user.synced_at.strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
}
|
||||
end
|
||||
|
||||
it 'includes accounts' do
|
||||
get('/profile', access_token: access_token.to_s).should be_ok
|
||||
parsed_body['accounts'].should == [{
|
||||
'id' => user.id,
|
||||
'login' => user.login,
|
||||
'name' => user.name,
|
||||
'type' => 'user',
|
||||
'reposCount' => nil
|
||||
}]
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user