fix some of the tests
This commit is contained in:
parent
a67b8bf1de
commit
4a59e2286e
|
@ -10,8 +10,9 @@ describe Travis::Api::App::Endpoint::Authorization do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
User.stubs(:find_by_login).with(user.login).returns(user)
|
user.stubs(:github_id).returns(42)
|
||||||
User.stubs(:find).with(user.id).returns(user)
|
User.stubs(:find_github_id).returns(user)
|
||||||
|
User.stubs(:find).returns(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET /auth/authorize' do
|
describe 'GET /auth/authorize' do
|
||||||
|
@ -24,9 +25,10 @@ describe Travis::Api::App::Endpoint::Authorization do
|
||||||
|
|
||||||
describe 'POST /auth/github' do
|
describe 'POST /auth/github' do
|
||||||
before do
|
before do
|
||||||
GH.stubs(:with).with(token: 'private repos').returns stub(:[] => user.login, :headers => {'x-oauth-scopes' => 'repo'})
|
data = { 'id' => user.github_id, 'name' => user.name, 'login' => user.login, 'gravatar_id' => user.gravatar_id }
|
||||||
GH.stubs(:with).with(token: 'public repos').returns stub(:[] => user.login, :headers => {'x-oauth-scopes' => 'public_repo'})
|
GH.stubs(:with).with(token: 'private repos').returns stub(:[] => user.login, :headers => {'x-oauth-scopes' => 'repo'}, :to_hash => data)
|
||||||
GH.stubs(:with).with(token: 'no repos').returns stub(:[] => user.login, :headers => {'x-oauth-scopes' => 'user'})
|
GH.stubs(:with).with(token: 'public repos').returns stub(:[] => user.login, :headers => {'x-oauth-scopes' => 'public_repo'}, :to_hash => data)
|
||||||
|
GH.stubs(:with).with(token: 'no repos').returns stub(:[] => user.login, :headers => {'x-oauth-scopes' => 'user'}, :to_hash => data)
|
||||||
GH.stubs(:with).with(token: 'invalid token').raises(Faraday::Error::ClientError, 'CLIENT ERROR!')
|
GH.stubs(:with).with(token: 'invalid token').raises(Faraday::Error::ClientError, 'CLIENT ERROR!')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -42,11 +44,11 @@ describe Travis::Api::App::Endpoint::Authorization do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'accepts tokens with repo scope' do
|
it 'accepts tokens with repo scope' do
|
||||||
user_for('private repos').should == user
|
user_for('private repos').name.should == user.name
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'accepts tokens with public_repo scope' do
|
it 'accepts tokens with public_repo scope' do
|
||||||
user_for('public repos').should == user
|
user_for('public repos').name.should == user.name
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'rejects tokens with user scope' do
|
it 'rejects tokens with user scope' do
|
||||||
|
|
|
@ -2,11 +2,11 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Travis::Api::App::Endpoint::Profile do
|
describe Travis::Api::App::Endpoint::Profile do
|
||||||
include Travis::Testing::Stubs
|
include Travis::Testing::Stubs
|
||||||
let(:access_token) { Travis::Api::App::AccessToken.create(user: user) }
|
let(:access_token) { Travis::Api::App::AccessToken.create(user: user, app_id: 0) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
User.stubs(:find_by_login).with(user.login).returns(user)
|
User.stubs(:find_by_github_id).returns(user)
|
||||||
User.stubs(:find).with(user.id).returns(user)
|
User.stubs(:find).returns(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'needs to be authenticated' do
|
it 'needs to be authenticated' do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user