mirror of
https://github.com/nov/fb_graph2
synced 2023-03-27 23:22:15 -04:00
auth_spec
This commit is contained in:
parent
d2696e4d32
commit
a569bc48a1
4 changed files with 32 additions and 6 deletions
25
spec/fb_graph2/auth_spec.rb
Normal file
25
spec/fb_graph2/auth_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe FbGraph2::Auth do
|
||||||
|
describe '.app' do
|
||||||
|
subject { instance }
|
||||||
|
let(:instance) { FbGraph2::Auth.new 'client_id', 'client_secret' }
|
||||||
|
|
||||||
|
it { should be_a Rack::OAuth2::Client }
|
||||||
|
|
||||||
|
describe 'fb_exchange_token grant' do
|
||||||
|
it do
|
||||||
|
instance.fb_exchange_token = 'short_lived_access_token'
|
||||||
|
access_token = mock_graph :post, 'oauth/access_token', 'token_response', params: {
|
||||||
|
grant_type: 'fb_exchange_token',
|
||||||
|
fb_exchange_token: 'short_lived_access_token',
|
||||||
|
client_id: 'client_id',
|
||||||
|
client_secret: 'client_secret'
|
||||||
|
}, disable_api_versioning: true do
|
||||||
|
instance.access_token!
|
||||||
|
end
|
||||||
|
access_token.should be_instance_of Rack::OAuth2::AccessToken::Legacy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -22,7 +22,7 @@ describe FbGraph2::Node do
|
||||||
it 'should use api_version globally' do
|
it 'should use api_version globally' do
|
||||||
expect do
|
expect do
|
||||||
instance.fetch
|
instance.fetch
|
||||||
end.to request_to 'v2.x/identifier', :get, api_version_in_path: true
|
end.to request_to 'v2.x/identifier', :get, disable_api_versioning: true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ describe FbGraph2::Node do
|
||||||
it 'should use api_version globally' do
|
it 'should use api_version globally' do
|
||||||
expect do
|
expect do
|
||||||
instance.edge :foo
|
instance.edge :foo
|
||||||
end.to request_to 'v2.x/identifier/foo', :get, api_version_in_path: true
|
end.to request_to 'v2.x/identifier/foo', :get, disable_api_versioning: true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -40,7 +40,7 @@ describe FbGraph2::Node do
|
||||||
it 'should use api_version locally' do
|
it 'should use api_version locally' do
|
||||||
expect do
|
expect do
|
||||||
instance.fetch nil, api_version: 'v2.y'
|
instance.fetch nil, api_version: 'v2.y'
|
||||||
end.to request_to 'v2.y/identifier', :get, api_version_in_path: true
|
end.to request_to 'v2.y/identifier', :get, disable_api_versioning: true
|
||||||
FbGraph2.api_version.should == @original
|
FbGraph2.api_version.should == @original
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -49,7 +49,7 @@ describe FbGraph2::Node do
|
||||||
it 'should use api_version locally' do
|
it 'should use api_version locally' do
|
||||||
expect do
|
expect do
|
||||||
instance.edge :foo, {}, api_version: 'v2.y'
|
instance.edge :foo, {}, api_version: 'v2.y'
|
||||||
end.to request_to 'v2.y/identifier/foo', :get, api_version_in_path: true
|
end.to request_to 'v2.y/identifier/foo', :get, disable_api_versioning: true
|
||||||
FbGraph2.api_version.should == @original
|
FbGraph2.api_version.should == @original
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
1
spec/mock_json/token_response.json
Normal file
1
spec/mock_json/token_response.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
access_token=access_token&expires=5183975
|
|
@ -14,7 +14,7 @@ module MockGraph
|
||||||
response = yield
|
response = yield
|
||||||
a_request(
|
a_request(
|
||||||
method,
|
method,
|
||||||
endpoint_for(path)
|
endpoint_for(path, options)
|
||||||
).with(
|
).with(
|
||||||
request_for(method, options)
|
request_for(method, options)
|
||||||
).should have_been_made.once
|
).should have_been_made.once
|
||||||
|
@ -40,7 +40,7 @@ module MockGraph
|
||||||
private
|
private
|
||||||
|
|
||||||
def endpoint_for(path, options = {})
|
def endpoint_for(path, options = {})
|
||||||
api_version = unless options[:api_version_in_path]
|
api_version = unless options[:disable_api_versioning]
|
||||||
options[:api_version] || FbGraph2.api_version
|
options[:api_version] || FbGraph2.api_version
|
||||||
end
|
end
|
||||||
File.join FbGraph2.root_url, api_version.to_s, path
|
File.join FbGraph2.root_url, api_version.to_s, path
|
||||||
|
|
Loading…
Reference in a new issue