change default for authorization to nil

This commit is contained in:
Volker Zöpfel 2013-12-03 08:30:28 +01:00
parent 18c4bab286
commit b1f8ac3c0d
2 changed files with 8 additions and 4 deletions

View File

@ -57,7 +57,7 @@ module Google
# Loads credentials and authorizes an client.
# @return [Object] Signet::OAuth2::Client or NIL
def authorize
@authorization = false
@authorization = nil
cached_credentials = load_credentials
if cached_credentials && cached_credentials.size > 0
@authorization = Signet::OAuth2::Client.new(cached_credentials)

View File

@ -38,15 +38,19 @@ describe Google::APIClient::Storage do
client_stub.stub(:expired?).and_return(true)
Signet::OAuth2::Client.should_receive(:new).and_return(client_stub)
subject.should_receive(:refresh_authorization)
subject.authorize
auth = subject.authorize
auth.should == subject.authorization
auth.should_not be_nil
end
end
describe 'without credentials' do
it 'should return false' do
it 'should return nil' do
subject.authorization.should be_nil
subject.should_receive(:load_credentials).and_return({})
subject.authorize.should be_false
subject.authorize.should be_nil
subject.authorization.should be_nil
end
end
end