245 | 245 |
def setup
|
246 | 246 |
super
|
247 | 247 |
@access_token = stub('OAuth2::AccessToken')
|
|
248 |
@appsecret_proof = 'appsecret_proof'
|
|
249 |
@options = {:appsecret_proof => @appsecret_proof}
|
248 | 250 |
end
|
249 | 251 |
|
250 | 252 |
test 'performs a GET to https://graph.facebook.com/me' do
|
|
253 |
strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
|
251 | 254 |
strategy.stubs(:access_token).returns(@access_token)
|
252 | |
@access_token.expects(:get).with('/me', {}).returns(stub_everything('OAuth2::Response'))
|
|
255 |
params = {:params => @options}
|
|
256 |
@access_token.expects(:get).with('/me', params).returns(stub_everything('OAuth2::Response'))
|
253 | 257 |
strategy.raw_info
|
254 | 258 |
end
|
255 | 259 |
|
256 | 260 |
test 'performs a GET to https://graph.facebook.com/me with locale' do
|
257 | |
@options = { :locale => 'cs_CZ' }
|
|
261 |
@options.merge!({ :locale => 'cs_CZ' })
|
258 | 262 |
strategy.stubs(:access_token).returns(@access_token)
|
259 | |
@access_token.expects(:get).with('/me', {:params => {:locale => 'cs_CZ'}}).returns(stub_everything('OAuth2::Response'))
|
|
263 |
strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
|
|
264 |
params = {:params => @options}
|
|
265 |
@access_token.expects(:get).with('/me', params).returns(stub_everything('OAuth2::Response'))
|
260 | 266 |
strategy.raw_info
|
261 | 267 |
end
|
262 | 268 |
|
263 | 269 |
test 'performs a GET to https://graph.facebook.com/me with info_fields' do
|
264 | |
@options = { :info_fields => 'about' }
|
|
270 |
@options.merge!({:info_fields => 'about'})
|
265 | 271 |
strategy.stubs(:access_token).returns(@access_token)
|
266 | |
@access_token.expects(:get).with('/me', {:params => {:fields => 'about'}}).returns(stub_everything('OAuth2::Response'))
|
|
272 |
strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
|
|
273 |
params = {:params => {:appsecret_proof => @appsecret_proof, :fields => 'about'}}
|
|
274 |
@access_token.expects(:get).with('/me', params).returns(stub_everything('OAuth2::Response'))
|
267 | 275 |
strategy.raw_info
|
268 | 276 |
end
|
269 | 277 |
|
270 | 278 |
test 'returns a Hash' do
|
271 | 279 |
strategy.stubs(:access_token).returns(@access_token)
|
|
280 |
strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
|
272 | 281 |
raw_response = stub('Faraday::Response')
|
273 | 282 |
raw_response.stubs(:body).returns('{ "ohai": "thar" }')
|
274 | 283 |
raw_response.stubs(:status).returns(200)
|
275 | 284 |
raw_response.stubs(:headers).returns({'Content-Type' => 'application/json' })
|
276 | 285 |
oauth2_response = OAuth2::Response.new(raw_response)
|
277 | |
@access_token.stubs(:get).with('/me', {}).returns(oauth2_response)
|
|
286 |
params = {:params => @options}
|
|
287 |
@access_token.stubs(:get).with('/me', params).returns(oauth2_response)
|
278 | 288 |
assert_kind_of Hash, strategy.raw_info
|
279 | 289 |
assert_equal 'thar', strategy.raw_info['ohai']
|
280 | 290 |
end
|
281 | 291 |
|
282 | 292 |
test 'returns an empty hash when the response is false' do
|
283 | 293 |
strategy.stubs(:access_token).returns(@access_token)
|
|
294 |
strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
|
284 | 295 |
oauth2_response = stub('OAuth2::Response', :parsed => false)
|
285 | |
@access_token.stubs(:get).with('/me', {}).returns(oauth2_response)
|
|
296 |
params = {:params => @options}
|
|
297 |
@access_token.stubs(:get).with('/me', params).returns(oauth2_response)
|
286 | 298 |
assert_kind_of Hash, strategy.raw_info
|
|
299 |
assert_equal({}, strategy.raw_info)
|
287 | 300 |
end
|
288 | 301 |
|
289 | 302 |
test 'should not include raw_info in extras hash when skip_info is specified' do
|