mirror of
https://github.com/nov/fb_graph2
synced 2023-03-27 23:22:15 -04:00
token metadata helper specs
This commit is contained in:
parent
5671dcc6d2
commit
62be17a020
3 changed files with 71 additions and 5 deletions
|
@ -21,6 +21,11 @@ module FbGraph2
|
|||
end
|
||||
end
|
||||
|
||||
def fetch(params = {}, options = {})
|
||||
attributes = get params, options
|
||||
self.class.new(attributes[:data]).authenticate access_token
|
||||
end
|
||||
|
||||
def valid?
|
||||
!!is_valid
|
||||
end
|
||||
|
@ -36,10 +41,5 @@ module FbGraph2
|
|||
def page_token?
|
||||
app.present? && user.present? && page.present?
|
||||
end
|
||||
|
||||
def fetch(params = {}, options = {})
|
||||
attributes = get params, options
|
||||
self.class.new(attributes[:data]).authenticate access_token
|
||||
end
|
||||
end
|
||||
end
|
51
spec/fb_graph2/token_metadata_spec.rb
Normal file
51
spec/fb_graph2/token_metadata_spec.rb
Normal file
|
@ -0,0 +1,51 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe FbGraph2::TokenMetadata do
|
||||
let(:app_token) do
|
||||
attributes = mock_json 'token_metadata/app_token'
|
||||
FbGraph2::TokenMetadata.new attributes[:data]
|
||||
end
|
||||
let(:user_token) do
|
||||
attributes = mock_json 'token_metadata/user_token'
|
||||
FbGraph2::TokenMetadata.new attributes[:data]
|
||||
end
|
||||
let(:page_token) do
|
||||
attributes = mock_json 'token_metadata/page_token'
|
||||
FbGraph2::TokenMetadata.new attributes[:data]
|
||||
end
|
||||
let(:invalid_token) do
|
||||
attributes = mock_json 'token_metadata/invalid_token'
|
||||
FbGraph2::TokenMetadata.new attributes[:data]
|
||||
end
|
||||
|
||||
context 'when app_token' do
|
||||
subject { app_token }
|
||||
its(:app_token?) { should == true }
|
||||
its(:user_token?) { should == false }
|
||||
its(:page_token?) { should == false }
|
||||
end
|
||||
|
||||
context 'when user_token' do
|
||||
subject { user_token }
|
||||
its(:app_token?) { should == false }
|
||||
its(:user_token?) { should == true }
|
||||
its(:page_token?) { should == false }
|
||||
end
|
||||
|
||||
context 'when page_token' do
|
||||
subject { page_token }
|
||||
its(:app_token?) { should == false }
|
||||
its(:user_token?) { should == false }
|
||||
its(:page_token?) { should == true }
|
||||
end
|
||||
|
||||
context 'when valid' do
|
||||
subject { user_token }
|
||||
its(:valid?) { should == true }
|
||||
end
|
||||
|
||||
context 'when invalid' do
|
||||
subject { invalid_token }
|
||||
its(:valid?) { should == false }
|
||||
end
|
||||
end
|
15
spec/mock_json/token_metadata/invalid_token.json
Normal file
15
spec/mock_json/token_metadata/invalid_token.json
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"data": {
|
||||
"error": {
|
||||
"message": "Error validating access token: This may be because the user logged out or may be due to a system error.",
|
||||
"code": 190,
|
||||
"subcode": 467
|
||||
},
|
||||
"app_id": "210798282372757",
|
||||
"is_valid": false,
|
||||
"application": "gem sample",
|
||||
"user_id": "579612276",
|
||||
"expires_at": 1409655600,
|
||||
"scopes": ["public_profile", "basic_info", "read_stream", "read_mailbox", "read_page_mailboxes", "rsvp_event", "email", "ads_management", "ads_read", "read_insights", "manage_notifications", "read_friendlists", "manage_pages", "publish_actions", "user_birthday", "user_religion_politics", "user_relationships", "user_relationship_details", "user_hometown", "user_location", "user_likes", "user_activities", "user_interests", "user_education_history", "user_work_history", "user_website", "user_groups", "user_events", "user_photos", "user_videos", "user_friends", "user_about_me", "user_status", "user_games_activity", "user_tagged_places", "user_actions.books", "user_actions.music", "user_actions.video", "user_actions.news"]
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue