diff --git a/lib/google/api_client/auth/storage.rb b/lib/google/api_client/auth/storage.rb index 5197cf2d7..e7cc5bc4e 100644 --- a/lib/google/api_client/auth/storage.rb +++ b/lib/google/api_client/auth/storage.rb @@ -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) diff --git a/spec/google/api_client/auth/storage_spec.rb b/spec/google/api_client/auth/storage_spec.rb index 1c319f4b7..b9564644d 100644 --- a/spec/google/api_client/auth/storage_spec.rb +++ b/spec/google/api_client/auth/storage_spec.rb @@ -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