From b1f8ac3c0d83a5d9756537357bc64cf5df79fd19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Z=C3=B6pfel?= Date: Tue, 3 Dec 2013 08:30:28 +0100 Subject: [PATCH] change default for authorization to nil --- lib/google/api_client/auth/storage.rb | 2 +- spec/google/api_client/auth/storage_spec.rb | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) 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