test/strategy_test.rb in omniauth-facebook-3.0.0 vs test/strategy_test.rb in omniauth-facebook-4.0.0.rc1
- old
+ new
@@ -7,19 +7,19 @@
include OAuth2StrategyTests
end
class ClientTest < StrategyTestCase
test 'has correct Facebook site' do
- assert_equal 'https://graph.facebook.com', strategy.client.site
+ assert_equal 'https://graph.facebook.com/v2.6', strategy.client.site
end
test 'has correct authorize url' do
- assert_equal 'https://www.facebook.com/dialog/oauth', strategy.client.options[:authorize_url]
+ assert_equal 'https://www.facebook.com/v2.6/dialog/oauth', strategy.client.options[:authorize_url]
end
test 'has correct token url with versioning' do
- @options = {:client_options => {:site => 'https://graph.facebook.net/v2.2'}}
+ @options = {client_options: {site: 'https://graph.facebook.net/v2.2'}}
assert_equal 'oauth/access_token', strategy.client.options[:token_url]
assert_equal 'https://graph.facebook.net/v2.2/oauth/access_token', strategy.client.token_url
end
end
@@ -31,21 +31,21 @@
strategy.stubs(:query_string).returns('?foo=bar')
assert_equal "#{url_base}/auth/facebook/callback", strategy.callback_url
end
test "returns path from callback_path option (omitting querystring)" do
- @options = { :callback_path => "/auth/FB/done"}
+ @options = { callback_path: "/auth/FB/done"}
url_base = 'http://auth.request.com'
@request.stubs(:url).returns("#{url_base}/page/path")
strategy.stubs(:script_name).returns('') # as not to depend on Rack env
strategy.stubs(:query_string).returns('?foo=bar')
assert_equal "#{url_base}/auth/FB/done", strategy.callback_url
end
test "returns url from callback_url option" do
url = 'https://auth.myapp.com/auth/fb/callback'
- @options = { :callback_url => url }
+ @options = { callback_url: url }
assert_equal url, strategy.callback_url
end
end
class AuthorizeParamsTest < StrategyTestCase
@@ -71,16 +71,10 @@
assert strategy.authorize_params.is_a?(Hash)
assert_equal 'email', strategy.authorize_params[:scope]
end
end
-class TokeParamsTest < StrategyTestCase
- test 'has correct parse strategy' do
- assert_equal :query, strategy.token_params[:parse]
- end
-end
-
class AccessTokenOptionsTest < StrategyTestCase
test 'has correct param name by default' do
assert_equal 'access_token', strategy.access_token_options[:param_name]
end
@@ -100,44 +94,44 @@
end
end
class InfoTest < StrategyTestCase
test 'returns the secure facebook avatar url when `secure_image_url` option is specified' do
- @options = { :secure_image_url => true }
+ @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/321/picture', strategy.info['image']
+ assert_equal 'https://graph.facebook.com/v2.6/321/picture', 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"}}
+ @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']
end
test 'returns the image with size specified in the `image_size` option' do
- @options = { :image_size => 'normal' }
+ @options = { image_size: 'normal' }
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
strategy.stubs(:raw_info).returns(raw_info)
- assert_equal 'http://graph.facebook.com/321/picture?type=normal', strategy.info['image']
+ assert_equal 'http://graph.facebook.com/v2.6/321/picture?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 }
+ @options = { image_size: :normal }
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
strategy.stubs(:raw_info).returns(raw_info)
- assert_equal 'http://graph.facebook.com/321/picture?type=normal', strategy.info['image']
+ assert_equal 'http://graph.facebook.com/v2.6/321/picture?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 } }
+ @options = { image_size: { width: 123, height: 987 } }
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
strategy.stubs(:raw_info).returns(raw_info)
assert_match 'width=123', strategy.info['image']
assert_match 'height=987', strategy.info['image']
- assert_match 'http://graph.facebook.com/321/picture?', strategy.info['image']
+ assert_match 'http://graph.facebook.com/v2.6/321/picture?', strategy.info['image']
end
end
class InfoTestOptionalDataPresent < StrategyTestCase
def setup
@@ -180,11 +174,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/321/picture', strategy.info['image']
+ assert_equal 'http://graph.facebook.com/v2.6/321/picture', 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']
@@ -259,43 +253,43 @@
class RawInfoTest < StrategyTestCase
def setup
super
@access_token = stub('OAuth2::AccessToken')
@appsecret_proof = 'appsecret_proof'
- @options = {:appsecret_proof => @appsecret_proof, :fields => 'name,email'}
+ @options = {appsecret_proof: @appsecret_proof, fields: 'name,email'}
end
- test 'performs a GET to https://graph.facebook.com/me' do
+ test 'performs a GET to https://graph.facebook.com/v2.6/me' do
strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
strategy.stubs(:access_token).returns(@access_token)
- params = {:params => @options}
+ params = {params: @options}
@access_token.expects(:get).with('me', params).returns(stub_everything('OAuth2::Response'))
strategy.raw_info
end
- test 'performs a GET to https://graph.facebook.com/me with locale' do
- @options.merge!({ :locale => 'cs_CZ' })
+ test 'performs a GET to https://graph.facebook.com/v2.6/me with locale' do
+ @options.merge!({ locale: 'cs_CZ' })
strategy.stubs(:access_token).returns(@access_token)
strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
- params = {:params => @options}
+ params = {params: @options}
@access_token.expects(:get).with('me', params).returns(stub_everything('OAuth2::Response'))
strategy.raw_info
end
- test 'performs a GET to https://graph.facebook.com/me with info_fields' do
- @options.merge!({:info_fields => 'about'})
+ test 'performs a GET to https://graph.facebook.com/v2.6/me with info_fields' do
+ @options.merge!({info_fields: 'about'})
strategy.stubs(:access_token).returns(@access_token)
strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
- params = {:params => {:appsecret_proof => @appsecret_proof, :fields => 'about'}}
+ params = {params: {appsecret_proof: @appsecret_proof, fields: 'about'}}
@access_token.expects(:get).with('me', params).returns(stub_everything('OAuth2::Response'))
strategy.raw_info
end
- test 'performs a GET to https://graph.facebook.com/me with default info_fields' do
+ test 'performs a GET to https://graph.facebook.com/v2.6/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'}}
+ 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
@@ -304,28 +298,28 @@
raw_response = stub('Faraday::Response')
raw_response.stubs(:body).returns('{ "ohai": "thar" }')
raw_response.stubs(:status).returns(200)
raw_response.stubs(:headers).returns({'Content-Type' => 'application/json' })
oauth2_response = OAuth2::Response.new(raw_response)
- params = {:params => @options}
+ params = {params: @options}
@access_token.stubs(:get).with('me', params).returns(oauth2_response)
assert_kind_of Hash, strategy.raw_info
assert_equal 'thar', strategy.raw_info['ohai']
end
test 'returns an empty hash when the response is false' do
strategy.stubs(:access_token).returns(@access_token)
strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
- oauth2_response = stub('OAuth2::Response', :parsed => false)
- params = {:params => @options}
+ oauth2_response = stub('OAuth2::Response', parsed: false)
+ params = {params: @options}
@access_token.stubs(:get).with('me', params).returns(oauth2_response)
assert_kind_of Hash, strategy.raw_info
assert_equal({}, strategy.raw_info)
end
test 'should not include raw_info in extras hash when skip_info is specified' do
- @options = { :skip_info => true }
- strategy.stubs(:raw_info).returns({:foo => 'bar' })
+ @options = { skip_info: true }
+ strategy.stubs(:raw_info).returns({foo: 'bar' })
refute_has_key 'raw_info', strategy.extra
end
end
class CredentialsTest < StrategyTestCase