1
0
Fork 0
mirror of https://github.com/simi/omniauth-facebook.git synced 2022-11-09 12:32:45 -05:00

obey skip_info? config

This commit is contained in:
Mark Dodwell 2012-05-05 21:48:50 -07:00
parent 8bb4e86ec9
commit 88f47364f1
2 changed files with 12 additions and 4 deletions

View file

@ -47,9 +47,9 @@ module OmniAuth
end
extra do
prune!({
'raw_info' => raw_info
})
hash = {}
hash['raw_info'] = raw_info unless skip_info?
prune! hash
end
def raw_info

View file

@ -245,16 +245,17 @@ describe OmniAuth::Strategies::Facebook do
describe '#raw_info' do
before :each do
@access_token = double('OAuth2::AccessToken')
subject.stub(:access_token) { @access_token }
end
it 'performs a GET to https://graph.facebook.com/me' do
subject.stub(:access_token) { @access_token }
@access_token.stub(:get) { double('OAuth2::Response').as_null_object }
@access_token.should_receive(:get).with('/me')
subject.raw_info
end
it 'returns a Hash' do
subject.stub(:access_token) { @access_token }
@access_token.stub(:get).with('/me') do
raw_response = double('Faraday::Response')
raw_response.stub(:body) { '{ "ohai": "thar" }' }
@ -267,6 +268,7 @@ describe OmniAuth::Strategies::Facebook do
end
it 'returns an empty hash when the response is false' do
subject.stub(:access_token) { @access_token }
@access_token.stub(:get).with('/me') do
response = double('OAuth2::Response')
response.stub(:parsed => false)
@ -274,6 +276,12 @@ describe OmniAuth::Strategies::Facebook do
end
subject.raw_info.should be_a(Hash)
end
it 'should not include raw_info in extras hash when skip_info is specified' do
@options = { :skip_info => true }
subject.stub(:raw_info) { { :foo => 'bar' } }
subject.extra.should_not have_key('raw_info')
end
end
describe '#credentials' do