Skip to content

Commit

Permalink
Fix default info_fields to 'email'
Browse files Browse the repository at this point in the history
  • Loading branch information
blueplanet committed Jul 12, 2015
1 parent b127c35 commit 6993244
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/omniauth/strategies/facebook.rb
Expand Up @@ -60,7 +60,7 @@ def raw_info

def info_options
params = {:appsecret_proof => appsecret_proof}
params.merge!({:fields => options[:info_fields]}) if options[:info_fields]
params.merge!({:fields => (options[:info_fields] || 'name,email')})
params.merge!({:locale => options[:locale]}) if options[:locale]

{ :params => params }
Expand Down
10 changes: 9 additions & 1 deletion test/strategy_test.rb
Expand Up @@ -259,7 +259,7 @@ def setup
super
@access_token = stub('OAuth2::AccessToken')
@appsecret_proof = 'appsecret_proof'
@options = {:appsecret_proof => @appsecret_proof}
@options = {:appsecret_proof => @appsecret_proof, :fields => 'name,email'}
end

test 'performs a GET to https://graph.facebook.com/me' do
Expand Down Expand Up @@ -288,6 +288,14 @@ def setup
strategy.raw_info
end

test 'performs a GET to https://graph.facebook.com/me with default info_fields' do
strategy.stubs(:access_token).returns(@access_token)
strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
params = {:params => {:appsecret_proof => @appsecret_proof, :fields => 'name,email'}}
@access_token.expects(:get).with('me', params).returns(stub_everything('OAuth2::Response'))
strategy.raw_info
end

test 'returns a Hash' do
strategy.stubs(:access_token).returns(@access_token)
strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
Expand Down

0 comments on commit 6993244

Please sign in to comment.