test/strategy_test.rb in omniauth-facebook-7.0.0 vs test/strategy_test.rb in omniauth-facebook-8.0.0
- old
+ new
@@ -93,53 +93,68 @@
assert_equal '123', strategy.uid
end
end
class InfoTest < StrategyTestCase
+ def setup
+ super
+ @access_token = stub('OAuth2::AccessToken')
+ @access_token.stubs(:token).returns('test_access_token')
+ end
+
test 'returns the secure facebook avatar url when `secure_image_url` option is specified' do
@options = { secure_image_url: true }
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
strategy.stubs(:raw_info).returns(raw_info)
- assert_equal 'https://graph.facebook.com/v4.0/321/picture', strategy.info['image']
+ strategy.stubs(:access_token).returns(@access_token)
+ assert_equal 'https://graph.facebook.com/v4.0/321/picture?access_token=test_access_token', strategy.info['image']
end
test 'returns the image_url based of the client site' do
@options = { secure_image_url: true, client_options: {site: "https://blah.facebook.com/v2.2"}}
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
strategy.stubs(:raw_info).returns(raw_info)
- assert_equal 'https://blah.facebook.com/v2.2/321/picture', strategy.info['image']
+ strategy.stubs(:access_token).returns(@access_token)
+ assert_equal "https://blah.facebook.com/v2.2/321/picture?access_token=test_access_token", strategy.info['image']
end
test 'returns the image with size specified in the `image_size` option' do
@options = { image_size: 'normal' }
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
strategy.stubs(:raw_info).returns(raw_info)
- assert_equal 'http://graph.facebook.com/v4.0/321/picture?type=normal', strategy.info['image']
+ strategy.stubs(:access_token).returns(@access_token)
+ assert_equal 'http://graph.facebook.com/v4.0/321/picture?access_token=test_access_token&type=normal', strategy.info['image']
end
test 'returns the image with size specified as a symbol in the `image_size` option' do
@options = { image_size: :normal }
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
strategy.stubs(:raw_info).returns(raw_info)
- assert_equal 'http://graph.facebook.com/v4.0/321/picture?type=normal', strategy.info['image']
+ strategy.stubs(:access_token).returns(@access_token)
+ assert_equal 'http://graph.facebook.com/v4.0/321/picture?access_token=test_access_token&type=normal', strategy.info['image']
end
test 'returns the image with width and height specified in the `image_size` option' do
@options = { image_size: { width: 123, height: 987 } }
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
strategy.stubs(:raw_info).returns(raw_info)
+ strategy.stubs(:access_token).returns(@access_token)
assert_match 'width=123', strategy.info['image']
assert_match 'height=987', strategy.info['image']
- assert_match 'http://graph.facebook.com/v4.0/321/picture?', strategy.info['image']
+ assert_match 'http://graph.facebook.com/v4.0/321/picture?access_token=test_access_token', strategy.info['image']
end
end
class InfoTestOptionalDataPresent < StrategyTestCase
def setup
super
@raw_info ||= { 'name' => 'Fred Smith' }
strategy.stubs(:raw_info).returns(@raw_info)
+
+ access_token = stub('OAuth2::AccessToken')
+ access_token.stubs(:token).returns('test_access_token')
+ strategy.stubs(:access_token).returns(access_token)
end
test 'returns the name' do
assert_equal 'Fred Smith', strategy.info['name']
end
@@ -174,11 +189,11 @@
assert_equal 'I am great', strategy.info['description']
end
test 'returns the facebook avatar url' do
@raw_info['id'] = '321'
- assert_equal 'http://graph.facebook.com/v4.0/321/picture', strategy.info['image']
+ assert_equal 'http://graph.facebook.com/v4.0/321/picture?access_token=test_access_token', strategy.info['image']
end
test 'returns the Facebook link as the Facebook url' do
@raw_info['link'] = 'http://www.facebook.com/fredsmith'
assert_kind_of Hash, strategy.info['urls']
@@ -213,9 +228,13 @@
class InfoTestOptionalDataNotPresent < StrategyTestCase
def setup
super
@raw_info ||= { 'name' => 'Fred Smith' }
strategy.stubs(:raw_info).returns(@raw_info)
+
+ access_token = stub('OAuth2::AccessToken')
+ access_token.stubs(:token).returns('test_access_token')
+ strategy.stubs(:access_token).returns(access_token)
end
test 'has no email key' do
refute_has_key 'email', strategy.info
end