gs_graph 2.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitattributes +22 -0
- data/.gitignore +26 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +95 -0
- data/LICENSE +20 -0
- data/README.rdoc +314 -0
- data/Rakefile +25 -0
- data/VERSION +1 -0
- data/assets/fb_graph.ai +1726 -6
- data/assets/fb_graph.png +0 -0
- data/gs_graph.gemspec +28 -0
- data/lib/gs_graph.rb +174 -0
- data/lib/gs_graph/achievement.rb +44 -0
- data/lib/gs_graph/action.rb +12 -0
- data/lib/gs_graph/ad_account.rb +51 -0
- data/lib/gs_graph/ad_campaign.rb +39 -0
- data/lib/gs_graph/ad_campaign_stat.rb +22 -0
- data/lib/gs_graph/ad_connection_object.rb +53 -0
- data/lib/gs_graph/ad_creative.rb +44 -0
- data/lib/gs_graph/ad_group.rb +51 -0
- data/lib/gs_graph/ad_group_stat.rb +22 -0
- data/lib/gs_graph/ad_keyword.rb +20 -0
- data/lib/gs_graph/ad_keyword_suggestion.rb +8 -0
- data/lib/gs_graph/ad_keyword_valid.rb +23 -0
- data/lib/gs_graph/ad_preview.rb +10 -0
- data/lib/gs_graph/ad_user.rb +58 -0
- data/lib/gs_graph/age_range.rb +12 -0
- data/lib/gs_graph/album.rb +59 -0
- data/lib/gs_graph/app_request.rb +24 -0
- data/lib/gs_graph/application.rb +119 -0
- data/lib/gs_graph/auth.rb +88 -0
- data/lib/gs_graph/auth/cookie.rb +20 -0
- data/lib/gs_graph/auth/signed_request.rb +44 -0
- data/lib/gs_graph/broad_targeting_category.rb +13 -0
- data/lib/gs_graph/checkin.rb +51 -0
- data/lib/gs_graph/collection.rb +55 -0
- data/lib/gs_graph/comment.rb +24 -0
- data/lib/gs_graph/comparison.rb +13 -0
- data/lib/gs_graph/connection.rb +37 -0
- data/lib/gs_graph/connections.rb +3 -0
- data/lib/gs_graph/connections/accounts.rb +23 -0
- data/lib/gs_graph/connections/achievements.rb +21 -0
- data/lib/gs_graph/connections/activities.rb +14 -0
- data/lib/gs_graph/connections/ad_accounts.rb +15 -0
- data/lib/gs_graph/connections/ad_campaign_stats.rb +22 -0
- data/lib/gs_graph/connections/ad_campaigns.rb +30 -0
- data/lib/gs_graph/connections/ad_connection_objects.rb +14 -0
- data/lib/gs_graph/connections/ad_creatives.rb +14 -0
- data/lib/gs_graph/connections/ad_group_stats.rb +22 -0
- data/lib/gs_graph/connections/ad_groups.rb +35 -0
- data/lib/gs_graph/connections/ad_previews.rb +10 -0
- data/lib/gs_graph/connections/admins.rb +10 -0
- data/lib/gs_graph/connections/albums.rb +21 -0
- data/lib/gs_graph/connections/app_notifications.rb +10 -0
- data/lib/gs_graph/connections/app_requests.rb +21 -0
- data/lib/gs_graph/connections/attending.rb +26 -0
- data/lib/gs_graph/connections/banned.rb +31 -0
- data/lib/gs_graph/connections/blocked.rb +36 -0
- data/lib/gs_graph/connections/books.rb +14 -0
- data/lib/gs_graph/connections/broad_targeting_categories.rb +14 -0
- data/lib/gs_graph/connections/checkins.rb +21 -0
- data/lib/gs_graph/connections/comments.rb +21 -0
- data/lib/gs_graph/connections/conversations.rb +14 -0
- data/lib/gs_graph/connections/declined.rb +25 -0
- data/lib/gs_graph/connections/docs.rb +14 -0
- data/lib/gs_graph/connections/events.rb +21 -0
- data/lib/gs_graph/connections/family.rb +14 -0
- data/lib/gs_graph/connections/feed.rb +21 -0
- data/lib/gs_graph/connections/former_participants.rb +14 -0
- data/lib/gs_graph/connections/friend_lists.rb +21 -0
- data/lib/gs_graph/connections/friend_requests.rb +12 -0
- data/lib/gs_graph/connections/friends.rb +14 -0
- data/lib/gs_graph/connections/games.rb +14 -0
- data/lib/gs_graph/connections/groups.rb +14 -0
- data/lib/gs_graph/connections/home.rb +14 -0
- data/lib/gs_graph/connections/inbox.rb +20 -0
- data/lib/gs_graph/connections/insights.rb +27 -0
- data/lib/gs_graph/connections/interests.rb +14 -0
- data/lib/gs_graph/connections/invited.rb +36 -0
- data/lib/gs_graph/connections/likes.rb +29 -0
- data/lib/gs_graph/connections/links.rb +21 -0
- data/lib/gs_graph/connections/maybe.rb +25 -0
- data/lib/gs_graph/connections/members.rb +22 -0
- data/lib/gs_graph/connections/messages.rb +22 -0
- data/lib/gs_graph/connections/milestones.rb +21 -0
- data/lib/gs_graph/connections/movies.rb +14 -0
- data/lib/gs_graph/connections/music.rb +14 -0
- data/lib/gs_graph/connections/mutual_friends.rb +26 -0
- data/lib/gs_graph/connections/noreply.rb +23 -0
- data/lib/gs_graph/connections/notes.rb +21 -0
- data/lib/gs_graph/connections/notifications.rb +18 -0
- data/lib/gs_graph/connections/offers.rb +22 -0
- data/lib/gs_graph/connections/outbox.rb +20 -0
- data/lib/gs_graph/connections/participants.rb +14 -0
- data/lib/gs_graph/connections/payments.rb +14 -0
- data/lib/gs_graph/connections/permissions.rb +16 -0
- data/lib/gs_graph/connections/photos.rb +21 -0
- data/lib/gs_graph/connections/picture.rb +39 -0
- data/lib/gs_graph/connections/pokes.rb +12 -0
- data/lib/gs_graph/connections/posts.rb +14 -0
- data/lib/gs_graph/connections/promotable_posts.rb +14 -0
- data/lib/gs_graph/connections/question_options.rb +14 -0
- data/lib/gs_graph/connections/questions.rb +22 -0
- data/lib/gs_graph/connections/reach_estimates.rb +12 -0
- data/lib/gs_graph/connections/roles.rb +36 -0
- data/lib/gs_graph/connections/scores.rb +22 -0
- data/lib/gs_graph/connections/senders.rb +14 -0
- data/lib/gs_graph/connections/settings.rb +65 -0
- data/lib/gs_graph/connections/statuses.rb +14 -0
- data/lib/gs_graph/connections/subscribed_to.rb +14 -0
- data/lib/gs_graph/connections/subscribers.rb +14 -0
- data/lib/gs_graph/connections/subscriptions.rb +53 -0
- data/lib/gs_graph/connections/tabs.rb +23 -0
- data/lib/gs_graph/connections/tagged.rb +14 -0
- data/lib/gs_graph/connections/tags.rb +23 -0
- data/lib/gs_graph/connections/television.rb +14 -0
- data/lib/gs_graph/connections/test_users.rb +19 -0
- data/lib/gs_graph/connections/threads.rb +14 -0
- data/lib/gs_graph/connections/user_achievements.rb +22 -0
- data/lib/gs_graph/connections/user_likes.rb +19 -0
- data/lib/gs_graph/connections/videos.rb +21 -0
- data/lib/gs_graph/connections/votes.rb +9 -0
- data/lib/gs_graph/cover.rb +10 -0
- data/lib/gs_graph/debugger.rb +28 -0
- data/lib/gs_graph/device.rb +11 -0
- data/lib/gs_graph/doc.rb +18 -0
- data/lib/gs_graph/domain.rb +32 -0
- data/lib/gs_graph/education.rb +32 -0
- data/lib/gs_graph/event.rb +52 -0
- data/lib/gs_graph/exception.rb +139 -0
- data/lib/gs_graph/friend_list.rb +13 -0
- data/lib/gs_graph/friend_request.rb +14 -0
- data/lib/gs_graph/group.rb +29 -0
- data/lib/gs_graph/image.rb +11 -0
- data/lib/gs_graph/insight.rb +13 -0
- data/lib/gs_graph/klass.rb +31 -0
- data/lib/gs_graph/link.rb +32 -0
- data/lib/gs_graph/location.rb +20 -0
- data/lib/gs_graph/message.rb +30 -0
- data/lib/gs_graph/milestone.rb +26 -0
- data/lib/gs_graph/node.rb +149 -0
- data/lib/gs_graph/note.rb +32 -0
- data/lib/gs_graph/notification.rb +32 -0
- data/lib/gs_graph/offer.rb +33 -0
- data/lib/gs_graph/open_graph.rb +3 -0
- data/lib/gs_graph/open_graph/action.rb +42 -0
- data/lib/gs_graph/open_graph/application_context.rb +10 -0
- data/lib/gs_graph/open_graph/object.rb +29 -0
- data/lib/gs_graph/open_graph/user_context.rb +21 -0
- data/lib/gs_graph/order.rb +55 -0
- data/lib/gs_graph/page.rb +57 -0
- data/lib/gs_graph/page/category_attributes.rb +117 -0
- data/lib/gs_graph/photo.rb +48 -0
- data/lib/gs_graph/picture.rb +14 -0
- data/lib/gs_graph/place.rb +7 -0
- data/lib/gs_graph/poke.rb +19 -0
- data/lib/gs_graph/post.rb +117 -0
- data/lib/gs_graph/privacy.rb +27 -0
- data/lib/gs_graph/project.rb +4 -0
- data/lib/gs_graph/promotable_post.rb +34 -0
- data/lib/gs_graph/property.rb +13 -0
- data/lib/gs_graph/query.rb +47 -0
- data/lib/gs_graph/question.rb +26 -0
- data/lib/gs_graph/question_option.rb +22 -0
- data/lib/gs_graph/reach_estimate.rb +22 -0
- data/lib/gs_graph/role.rb +13 -0
- data/lib/gs_graph/score.rb +16 -0
- data/lib/gs_graph/searchable.rb +33 -0
- data/lib/gs_graph/searchable/result.rb +31 -0
- data/lib/gs_graph/serialization.rb +19 -0
- data/lib/gs_graph/status.rb +27 -0
- data/lib/gs_graph/subscription.rb +14 -0
- data/lib/gs_graph/tab.rb +17 -0
- data/lib/gs_graph/tag.rb +30 -0
- data/lib/gs_graph/tagged_object.rb +23 -0
- data/lib/gs_graph/targeting.rb +23 -0
- data/lib/gs_graph/test_user.rb +24 -0
- data/lib/gs_graph/thread.rb +71 -0
- data/lib/gs_graph/user.rb +153 -0
- data/lib/gs_graph/user_achievement.rb +35 -0
- data/lib/gs_graph/venue.rb +14 -0
- data/lib/gs_graph/video.rb +41 -0
- data/lib/gs_graph/work.rb +48 -0
- data/lib/patch/rack/oauth2/access_token.rb +11 -0
- data/lib/patch/rack/oauth2/access_token/introspectable.rb +37 -0
- data/lib/patch/rack/oauth2/client.rb +13 -0
- data/lib/patch/rack/oauth2/grant/fb_exchange_token.rb +11 -0
- data/lib/patch/rack/oauth2/util.rb +14 -0
- data/spec/gs_graph/achievement_spec.rb +59 -0
- data/spec/gs_graph/ad_account_spec.rb +124 -0
- data/spec/gs_graph/ad_campaign_spec.rb +99 -0
- data/spec/gs_graph/ad_connection_object_spec.rb +71 -0
- data/spec/gs_graph/ad_creative_spec.rb +87 -0
- data/spec/gs_graph/ad_group_spec.rb +95 -0
- data/spec/gs_graph/ad_keyword_spec.rb +27 -0
- data/spec/gs_graph/ad_keyword_suggestion_spec.rb +17 -0
- data/spec/gs_graph/ad_keyword_valid_spec.rb +19 -0
- data/spec/gs_graph/ad_user_spec.rb +67 -0
- data/spec/gs_graph/album_spec.rb +93 -0
- data/spec/gs_graph/app_request_spec.rb +40 -0
- data/spec/gs_graph/application_spec.rb +251 -0
- data/spec/gs_graph/auth/cookie_spec.rb +29 -0
- data/spec/gs_graph/auth/signed_request_spec.rb +22 -0
- data/spec/gs_graph/auth_spec.rb +223 -0
- data/spec/gs_graph/broad_targeting_category_spec.rb +17 -0
- data/spec/gs_graph/checkin_spec.rb +42 -0
- data/spec/gs_graph/collection_spec.rb +50 -0
- data/spec/gs_graph/comment_spec.rb +31 -0
- data/spec/gs_graph/connection_spec.rb +42 -0
- data/spec/gs_graph/connections/accounts_spec.rb +78 -0
- data/spec/gs_graph/connections/achievements_spec.rb +27 -0
- data/spec/gs_graph/connections/activities_spec.rb +34 -0
- data/spec/gs_graph/connections/ad_accounts_spec.rb +28 -0
- data/spec/gs_graph/connections/ad_campaign_stat_spec.rb +35 -0
- data/spec/gs_graph/connections/ad_campaigns_spec.rb +36 -0
- data/spec/gs_graph/connections/ad_connection_objects_spec.rb +20 -0
- data/spec/gs_graph/connections/ad_creatives_spec.rb +29 -0
- data/spec/gs_graph/connections/ad_group_stat_spec.rb +54 -0
- data/spec/gs_graph/connections/ad_groups_spec.rb +92 -0
- data/spec/gs_graph/connections/ad_previews_spec.rb +18 -0
- data/spec/gs_graph/connections/admins_spec.rb +20 -0
- data/spec/gs_graph/connections/albums_spec.rb +63 -0
- data/spec/gs_graph/connections/app_notifications_spec.rb +23 -0
- data/spec/gs_graph/connections/app_requests_spec.rb +28 -0
- data/spec/gs_graph/connections/attending_spec.rb +47 -0
- data/spec/gs_graph/connections/banned_spec.rb +63 -0
- data/spec/gs_graph/connections/blocked_spec.rb +56 -0
- data/spec/gs_graph/connections/books_spec.rb +32 -0
- data/spec/gs_graph/connections/broad_targeting_categories_spec.rb +18 -0
- data/spec/gs_graph/connections/checkins_spec.rb +153 -0
- data/spec/gs_graph/connections/comments_spec.rb +75 -0
- data/spec/gs_graph/connections/conversations_spec.rb +19 -0
- data/spec/gs_graph/connections/declined_spec.rb +47 -0
- data/spec/gs_graph/connections/docs_spec.rb +14 -0
- data/spec/gs_graph/connections/events_spec.rb +52 -0
- data/spec/gs_graph/connections/family_spec.rb +32 -0
- data/spec/gs_graph/connections/feed_spec.rb +124 -0
- data/spec/gs_graph/connections/former_participants_spec.rb +44 -0
- data/spec/gs_graph/connections/friend_lists_spec.rb +26 -0
- data/spec/gs_graph/connections/friend_requests_spec.rb +16 -0
- data/spec/gs_graph/connections/friends_spec.rb +51 -0
- data/spec/gs_graph/connections/games_spec.rb +20 -0
- data/spec/gs_graph/connections/groups_spec.rb +31 -0
- data/spec/gs_graph/connections/home_spec.rb +62 -0
- data/spec/gs_graph/connections/inbox_spec.rb +16 -0
- data/spec/gs_graph/connections/insights_spec.rb +104 -0
- data/spec/gs_graph/connections/interests_spec.rb +12 -0
- data/spec/gs_graph/connections/invited_spec.rb +84 -0
- data/spec/gs_graph/connections/likes_spec.rb +127 -0
- data/spec/gs_graph/connections/links_spec.rb +31 -0
- data/spec/gs_graph/connections/maybe_spec.rb +47 -0
- data/spec/gs_graph/connections/members_spec.rb +57 -0
- data/spec/gs_graph/connections/messages_spec.rb +58 -0
- data/spec/gs_graph/connections/milestones_spec.rb +40 -0
- data/spec/gs_graph/connections/movies_spec.rb +12 -0
- data/spec/gs_graph/connections/music_spec.rb +12 -0
- data/spec/gs_graph/connections/mutual_friends_spec.rb +28 -0
- data/spec/gs_graph/connections/noreply_spec.rb +39 -0
- data/spec/gs_graph/connections/notes_spec.rb +31 -0
- data/spec/gs_graph/connections/notifications_spec.rb +30 -0
- data/spec/gs_graph/connections/outbox_spec.rb +16 -0
- data/spec/gs_graph/connections/participants_spec.rb +42 -0
- data/spec/gs_graph/connections/payments_spec.rb +17 -0
- data/spec/gs_graph/connections/permissions_spec.rb +44 -0
- data/spec/gs_graph/connections/photos_spec.rb +39 -0
- data/spec/gs_graph/connections/picture_spec.rb +92 -0
- data/spec/gs_graph/connections/pokes_spec.rb +16 -0
- data/spec/gs_graph/connections/posts_spec.rb +34 -0
- data/spec/gs_graph/connections/promotable_posts_spec.rb +24 -0
- data/spec/gs_graph/connections/question_options_spec.rb +14 -0
- data/spec/gs_graph/connections/questions_spec.rb +31 -0
- data/spec/gs_graph/connections/reach_estimates_spec.rb +18 -0
- data/spec/gs_graph/connections/roles_spec.rb +59 -0
- data/spec/gs_graph/connections/scores_spec.rb +40 -0
- data/spec/gs_graph/connections/senders_spec.rb +42 -0
- data/spec/gs_graph/connections/settings_spec.rb +62 -0
- data/spec/gs_graph/connections/statuses_spec.rb +72 -0
- data/spec/gs_graph/connections/subscribed_to_spec.rb +12 -0
- data/spec/gs_graph/connections/subscribers_spec.rb +12 -0
- data/spec/gs_graph/connections/subscriptions_spec.rb +47 -0
- data/spec/gs_graph/connections/tabs_spec.rb +47 -0
- data/spec/gs_graph/connections/tagged_spec.rb +42 -0
- data/spec/gs_graph/connections/tags_spec.rb +30 -0
- data/spec/gs_graph/connections/television_spec.rb +12 -0
- data/spec/gs_graph/connections/test_users_spec.rb +65 -0
- data/spec/gs_graph/connections/threads_spec.rb +12 -0
- data/spec/gs_graph/connections/user_achievements_spec.rb +37 -0
- data/spec/gs_graph/connections/user_likes_spec.rb +55 -0
- data/spec/gs_graph/connections/videos_spec.rb +27 -0
- data/spec/gs_graph/connections/votes_spec.rb +15 -0
- data/spec/gs_graph/debugger_spec.rb +33 -0
- data/spec/gs_graph/doc_spec.rb +27 -0
- data/spec/gs_graph/domain_spec.rb +23 -0
- data/spec/gs_graph/education_spec.rb +61 -0
- data/spec/gs_graph/event_spec.rb +70 -0
- data/spec/gs_graph/exception_spec.rb +310 -0
- data/spec/gs_graph/friend_list_spec.rb +22 -0
- data/spec/gs_graph/group_spec.rb +28 -0
- data/spec/gs_graph/image_spec.rb +16 -0
- data/spec/gs_graph/insight_spec.rb +18 -0
- data/spec/gs_graph/link_spec.rb +41 -0
- data/spec/gs_graph/location_spec.rb +28 -0
- data/spec/gs_graph/message_spec.rb +47 -0
- data/spec/gs_graph/node_spec.rb +91 -0
- data/spec/gs_graph/note_spec.rb +37 -0
- data/spec/gs_graph/notification_spec.rb +59 -0
- data/spec/gs_graph/offer_spec.rb +30 -0
- data/spec/gs_graph/open_graph/action_spec.rb +112 -0
- data/spec/gs_graph/open_graph/application_context_spec.rb +28 -0
- data/spec/gs_graph/open_graph/object_spec.rb +76 -0
- data/spec/gs_graph/open_graph/user_context_spec.rb +33 -0
- data/spec/gs_graph/order_spec.rb +66 -0
- data/spec/gs_graph/page/local_business_spec.rb +88 -0
- data/spec/gs_graph/page/movie_spec.rb +25 -0
- data/spec/gs_graph/page/music_spec.rb +25 -0
- data/spec/gs_graph/page/person_spec.rb +23 -0
- data/spec/gs_graph/page/product_spec.rb +36 -0
- data/spec/gs_graph/page_spec.rb +81 -0
- data/spec/gs_graph/photo_spec.rb +85 -0
- data/spec/gs_graph/place_spec.rb +8 -0
- data/spec/gs_graph/post_spec.rb +238 -0
- data/spec/gs_graph/privacy_spec.rb +33 -0
- data/spec/gs_graph/project_spec.rb +46 -0
- data/spec/gs_graph/promotable_post_spec.rb +57 -0
- data/spec/gs_graph/qeustion_option_spec.rb +35 -0
- data/spec/gs_graph/query_spec.rb +73 -0
- data/spec/gs_graph/question_spec.rb +73 -0
- data/spec/gs_graph/reach_estimate_spec.rb +48 -0
- data/spec/gs_graph/searchable_spec.rb +47 -0
- data/spec/gs_graph/seriarization_spec.rb +29 -0
- data/spec/gs_graph/status_spec.rb +31 -0
- data/spec/gs_graph/subscription_spec.rb +5 -0
- data/spec/gs_graph/tag_spec.rb +34 -0
- data/spec/gs_graph/tagged_object_spec.rb +45 -0
- data/spec/gs_graph/targeting_spec.rb +34 -0
- data/spec/gs_graph/test_user_spec.rb +50 -0
- data/spec/gs_graph/thread_spec.rb +86 -0
- data/spec/gs_graph/user_achievement_spec.rb +53 -0
- data/spec/gs_graph/user_spec.rb +185 -0
- data/spec/gs_graph/venue_spec.rb +23 -0
- data/spec/gs_graph/video_spec.rb +31 -0
- data/spec/gs_graph/work_spec.rb +101 -0
- data/spec/gs_graph_spec.rb +57 -0
- data/spec/spec_helper.rb +9 -0
- metadata +538 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::BroadTargetingCategory, '.new' do
|
4
|
+
it 'should setup all supported attributes' do
|
5
|
+
attributes = {
|
6
|
+
:id => 6002714401172,
|
7
|
+
:name => "Baby Boomers",
|
8
|
+
:parent_category => "Family Status"
|
9
|
+
}
|
10
|
+
|
11
|
+
btc = GSGraph::BroadTargetingCategory.new(attributes.delete(:id), attributes)
|
12
|
+
btc.identifier.should == 6002714401172
|
13
|
+
btc.name.should == "Baby Boomers"
|
14
|
+
btc.parent_category.should == "Family Status"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Checkin, '.new' do
|
4
|
+
it 'should accept GSGraph::Place as place' do
|
5
|
+
checkin = GSGraph::Checkin.new(12345, :place => GSGraph::Place.new(123456))
|
6
|
+
checkin.place.should == GSGraph::Place.new(123456)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should accept String/Integer as place' do
|
10
|
+
checkin1 = GSGraph::Checkin.new(12345, :place => 123456)
|
11
|
+
checkin2 = GSGraph::Checkin.new(12345, :place => '123456')
|
12
|
+
checkin1.place.should == GSGraph::Place.new(123456)
|
13
|
+
checkin2.place.should == GSGraph::Place.new('123456')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe GSGraph::Checkin, '.search' do
|
18
|
+
context 'when no access_token given' do
|
19
|
+
it 'should raise GSGraph::Unauthorized' do
|
20
|
+
mock_graph :get, 'search', 'checkins/search_public', :params => {
|
21
|
+
:type => 'checkin'
|
22
|
+
}, :status => [401, 'Unauthorized'] do
|
23
|
+
lambda do
|
24
|
+
GSGraph::Checkin.search
|
25
|
+
end.should raise_exception(GSGraph::Unauthorized)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when access_token is given' do
|
31
|
+
it 'should return checkins as GSGraph::Checkin' do
|
32
|
+
mock_graph :get, 'search', 'checkins/search_private', :access_token => 'access_token', :params => {
|
33
|
+
:type => 'checkin'
|
34
|
+
} do
|
35
|
+
checkins = GSGraph::Checkin.search(:access_token => 'access_token')
|
36
|
+
checkins.each do |checkin|
|
37
|
+
checkin.should be_instance_of(GSGraph::Checkin)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Collection, '.new' do
|
4
|
+
|
5
|
+
it 'should return an array with pagination info' do
|
6
|
+
mock_graph :get, 'platform/statuses', 'pages/statuses/platform_private', :access_token => 'access_token' do
|
7
|
+
collection = GSGraph::Page.new('platform', :access_token => 'access_token').statuses.collection
|
8
|
+
collection.should be_kind_of(Array)
|
9
|
+
collection.previous.should be_kind_of(Hash)
|
10
|
+
collection.next.should be_kind_of(Hash)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should allow blank data' do
|
15
|
+
patterns = [
|
16
|
+
GSGraph::Collection.new,
|
17
|
+
GSGraph::Collection.new({}),
|
18
|
+
GSGraph::Collection.new({:count => 5}),
|
19
|
+
GSGraph::Collection.new(nil)
|
20
|
+
]
|
21
|
+
patterns.each do |collection|
|
22
|
+
collection.should be_kind_of(Array)
|
23
|
+
collection.previous.should be_kind_of(Hash)
|
24
|
+
collection.next.should be_kind_of(Hash)
|
25
|
+
collection.should be_blank
|
26
|
+
collection.previous.should be_blank
|
27
|
+
collection.next.should be_blank
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should fetch count as total_count' do
|
32
|
+
collection = GSGraph::Collection.new({:count => 5})
|
33
|
+
collection.total_count.should == 5
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should accept Array' do
|
37
|
+
collection = GSGraph::Collection.new([1, 2, 3])
|
38
|
+
collection.total_count.should == 3
|
39
|
+
collection.should == [1, 2, 3]
|
40
|
+
collection.previous.should be_blank
|
41
|
+
collection.next.should be_blank
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should raise error for invalid input' do
|
45
|
+
lambda do
|
46
|
+
GSGraph::Collection.new("STRING")
|
47
|
+
end.should raise_error(ArgumentError, 'Invalid collection')
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Comment, '.new' do
|
4
|
+
|
5
|
+
it 'should setup all supported attributes' do
|
6
|
+
attributes = {
|
7
|
+
:id => '12345',
|
8
|
+
:from => {
|
9
|
+
:id => '23456',
|
10
|
+
:name => 'nov matake'
|
11
|
+
},
|
12
|
+
:message => 'hello',
|
13
|
+
:created_time => '2010-01-02T15:37:40+0000'
|
14
|
+
}
|
15
|
+
comment = GSGraph::Comment.new(attributes.delete(:id), attributes)
|
16
|
+
comment.identifier.should == '12345'
|
17
|
+
comment.from.should == GSGraph::User.new('23456', :name => 'nov matake')
|
18
|
+
comment.message.should == 'hello'
|
19
|
+
comment.created_time.should == Time.parse('2010-01-02T15:37:40+0000')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should support page as from' do
|
23
|
+
page_comment = GSGraph::Comment.new('12345', :from => {
|
24
|
+
:id => '23456',
|
25
|
+
:name => 'Smart.fm',
|
26
|
+
:category => 'Web Site'
|
27
|
+
})
|
28
|
+
page_comment.from.should == GSGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Connection, '.new' do
|
4
|
+
it 'should return an array with connection info' do
|
5
|
+
mock_graph :get, 'platform/statuses', 'pages/statuses/platform_private', :access_token => 'access_token' do
|
6
|
+
page = GSGraph::Page.new('platform', :access_token => 'access_token')
|
7
|
+
statuses = page.statuses
|
8
|
+
statuses.should be_kind_of(Array)
|
9
|
+
statuses.collection.should be_kind_of(GSGraph::Collection)
|
10
|
+
statuses.owner.should == page
|
11
|
+
statuses.connection.should == :statuses
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe GSGraph::Connection do
|
17
|
+
it 'should be useful for pagenation' do
|
18
|
+
me = GSGraph::User.new('me', :access_token => 'access_token')
|
19
|
+
posts = nil
|
20
|
+
mock_graph :get, 'me/home', 'users/home/me_private', :access_token => 'access_token' do
|
21
|
+
posts = me.home
|
22
|
+
posts.first.created_time.should == Time.parse('2010-04-27T13:06:14+0000')
|
23
|
+
posts.last.created_time.should == Time.parse('2010-04-27T11:07:48+0000')
|
24
|
+
end
|
25
|
+
mock_graph :get, 'me/home', 'users/home/me_private_previous', :access_token => 'access_token', :params => {
|
26
|
+
:limit => '25',
|
27
|
+
:since => '123456789'
|
28
|
+
} do
|
29
|
+
previous_posts = posts.previous
|
30
|
+
previous_posts.first.created_time.should == Time.parse('2010-04-27T13:23:08+0000')
|
31
|
+
previous_posts.last.created_time.should == Time.parse('2010-04-27T13:10:56+0000')
|
32
|
+
end
|
33
|
+
mock_graph :get, 'me/home', 'users/home/me_private_next', :access_token => 'access_token', :params => {
|
34
|
+
:limit => '25',
|
35
|
+
:until => '123456789'
|
36
|
+
} do
|
37
|
+
next_posts = posts.next
|
38
|
+
next_posts.first.created_time.should == Time.parse('2010-04-27T11:06:29+0000')
|
39
|
+
next_posts.last.created_time.should == Time.parse('2010-04-27T09:44:28+0000')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Connections::Accounts do
|
4
|
+
describe '#accounts' do
|
5
|
+
context 'when included by GSGraph::User' do
|
6
|
+
context 'when no access_token given' do
|
7
|
+
it 'should raise GSGraph::Unauthorized' do
|
8
|
+
mock_graph :get, 'matake/accounts', 'users/accounts/matake_public', :status => [401, 'Unauthorized'] do
|
9
|
+
lambda do
|
10
|
+
GSGraph::User.new('matake').accounts
|
11
|
+
end.should raise_exception(GSGraph::Unauthorized)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when access_token is given' do
|
17
|
+
it 'should return accounts as GSGraph::Page or GSGraph::Application' do
|
18
|
+
mock_graph :get, 'matake/accounts', 'users/accounts/matake_private', :access_token => 'access_token' do
|
19
|
+
accounts = GSGraph::User.new('matake', :access_token => 'access_token').accounts
|
20
|
+
accounts.class.should == GSGraph::Connection
|
21
|
+
accounts.first.should == GSGraph::Page.new(
|
22
|
+
'140478125968442',
|
23
|
+
:access_token => 'access_token',
|
24
|
+
:name => 'OAuth.jp',
|
25
|
+
:category => 'Community organization',
|
26
|
+
:perms => [
|
27
|
+
"ADMINISTER",
|
28
|
+
"EDIT_PROFILE",
|
29
|
+
"CREATE_CONTENT",
|
30
|
+
"MODERATE_CONTENT",
|
31
|
+
"CREATE_ADS",
|
32
|
+
"BASIC_ADMIN"
|
33
|
+
]
|
34
|
+
)
|
35
|
+
accounts.last.should == GSGraph::Application.new(
|
36
|
+
'159306934123399',
|
37
|
+
:access_token => 'access_token',
|
38
|
+
:name => 'Rack::OAuth2 Sample'
|
39
|
+
)
|
40
|
+
accounts[0, 9].each do |account|
|
41
|
+
account.should be_instance_of(GSGraph::Page)
|
42
|
+
end
|
43
|
+
accounts[9, 4].each do |account|
|
44
|
+
account.should be_instance_of(GSGraph::Application)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when manage_pages permission given' do
|
50
|
+
it 'should has special access_token behalf of the page' do
|
51
|
+
mock_graph :get, 'matake/accounts', 'users/accounts/matake_private_with_manage_pages_permission', :access_token => 'access_token_for_user' do
|
52
|
+
accounts = GSGraph::User.new('matake', :access_token => 'access_token_for_user').accounts
|
53
|
+
accounts.first.should == GSGraph::Page.new(
|
54
|
+
'140478125968442',
|
55
|
+
:access_token => 'access_token_for_oauth_jp',
|
56
|
+
:name => 'OAuth.jp',
|
57
|
+
:category => 'Technology'
|
58
|
+
)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'when included by GSGraph::Application' do
|
66
|
+
it 'should return an array of TestUser' do
|
67
|
+
mock_graph :get, 'app/accounts', 'applications/accounts/private', :access_token => 'access_token_for_app' do
|
68
|
+
accounts = GSGraph::Application.new('app', :access_token => 'access_token_for_app').accounts
|
69
|
+
accounts.first.should == GSGraph::TestUser.new(
|
70
|
+
'100002527044219',
|
71
|
+
:access_token => '117950878254050|2.AQA7fQ_BuZqxAiHc.3600.1308646800.0-100002527044219|T1wRNmvnx5j5nw-2x00gZgdBjbo',
|
72
|
+
:login_url => 'https://www.gamestamper.com/platform/test_account_login.php?user_id=100002527044219&n=SOlkQGg6Icr5BeI'
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Connections::Achievements do
|
4
|
+
let(:app) { GSGraph::Application.new('app_id', :access_token => 'app_token') }
|
5
|
+
|
6
|
+
describe '#achievements' do
|
7
|
+
it 'should return an Array of GSGraph::Achievement' do
|
8
|
+
mock_graph :get, 'app_id/achievements', 'applications/achievements/sample', :access_token => 'app_token' do
|
9
|
+
app.achievements.each do |achievement|
|
10
|
+
achievement.should be_instance_of GSGraph::Achievement
|
11
|
+
achievement.access_token.should == 'app_token'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#achievement!' do
|
18
|
+
let(:achievement_url) { 'http://fbgraphsample.heroku.com/achievements/1' }
|
19
|
+
it 'should return true' do
|
20
|
+
mock_graph :post, 'app_id/achievements', 'true', :access_token => 'app_token', :params => {
|
21
|
+
:achievement => achievement_url
|
22
|
+
} do
|
23
|
+
app.achievement!(achievement_url).should be_true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe GSGraph::Connections::Activities, '#activities' do
|
5
|
+
context 'when included by GSGraph::User' do
|
6
|
+
context 'when no access_token given' do
|
7
|
+
it 'should raise GSGraph::Unauthorized' do
|
8
|
+
mock_graph :get, 'arjun/activities', 'users/activities/arjun_public', :status => [401, 'Unauthorized'] do
|
9
|
+
lambda do
|
10
|
+
GSGraph::User.new('arjun').activities
|
11
|
+
end.should raise_exception(GSGraph::Unauthorized)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when access_token is given' do
|
17
|
+
it 'should return activities as GSGraph::Page' do
|
18
|
+
mock_graph :get, 'arjun/activities', 'users/activities/arjun_private', :access_token => 'access_token' do
|
19
|
+
activities = GSGraph::User.new('arjun', :access_token => 'access_token').activities
|
20
|
+
activities.class.should == GSGraph::Connection
|
21
|
+
activities.first.should == GSGraph::Page.new(
|
22
|
+
'378209722137',
|
23
|
+
:access_token => 'access_token',
|
24
|
+
:name => 'Doing Things at the Last Minute',
|
25
|
+
:category => '活動'
|
26
|
+
)
|
27
|
+
activities.each do |activity|
|
28
|
+
activity.should be_instance_of(GSGraph::Page)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Connections::AdAccounts, '#ad_accounts' do
|
4
|
+
context 'when included by GSGraph::User' do
|
5
|
+
context 'when access_token is given' do
|
6
|
+
it 'should return ad_accounts as GSGraph::AdAccount' do
|
7
|
+
mock_graph :get, 'me/adaccounts', 'users/ad_accounts/me_ad_accounts', :access_token => 'access_token' do
|
8
|
+
ad_accounts = GSGraph::User.me('access_token').ad_accounts
|
9
|
+
ad_accounts.size.should == 2
|
10
|
+
ad_accounts.each { |ad_account| ad_account.should be_instance_of(GSGraph::AdAccount) }
|
11
|
+
ad_accounts.first.should == GSGraph::AdAccount.new(
|
12
|
+
"act_108370185937777",
|
13
|
+
:account_id => 108370185937777,
|
14
|
+
:name => "",
|
15
|
+
:account_status => 1,
|
16
|
+
:currency => "USD",
|
17
|
+
:timezone_id => 1,
|
18
|
+
:timezone_name => "America/Los_Angeles",
|
19
|
+
:daily_spend_limit => 5000,
|
20
|
+
:users => [{"uid" => 10000294098888, :permissions => [1,2,3,4,5,7], :role => 1001}],
|
21
|
+
:capabilities => [],
|
22
|
+
:access_token => 'access_token'
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Connections::AdCampaignStats, '#ad_campaign_stats' do
|
4
|
+
context 'when included by GSGraph::AdAccount' do
|
5
|
+
context 'when access_token is given' do
|
6
|
+
it 'should return ad_campaign_stats as GSGraph::AdCampaignStat' do
|
7
|
+
mock_graph :get, 'act_11223344/adcampaignstats', 'ad_accounts/ad_campaign_stats/test_ad_campaign_stats', :access_token => 'access_token' do
|
8
|
+
ad_campaign_stats = GSGraph::AdAccount.new('act_11223344', :access_token => 'access_token').ad_campaign_stats
|
9
|
+
|
10
|
+
ad_campaign_stats.size.should == 2
|
11
|
+
ad_campaign_stats.each { |ad_campaign_stat| ad_campaign_stat.should be_instance_of(GSGraph::AdCampaignStat) }
|
12
|
+
ad_campaign_stats.first.should == GSGraph::AdCampaignStat.new(
|
13
|
+
"6002647797777/stats/0/1315507793",
|
14
|
+
:campaign_id => 6002647797777,
|
15
|
+
:start_time => nil,
|
16
|
+
:end_time => Time.parse("2011-09-08T18:49:53+0000"),
|
17
|
+
:impressions => 232641,
|
18
|
+
:clicks => 534,
|
19
|
+
:spent => 18885,
|
20
|
+
:social_impressions => 22676,
|
21
|
+
:social_clicks => 81,
|
22
|
+
:social_spent => 1548,
|
23
|
+
:unique_impressions => 0,
|
24
|
+
:social_unique_impressions => 0,
|
25
|
+
:unique_clicks => 0,
|
26
|
+
:social_unique_clicks => 0,
|
27
|
+
:actions => 140,
|
28
|
+
:connections => 0,
|
29
|
+
:access_token => 'access_token'
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe GSGraph::Connections::AdCampaigns, '#ad_campaign!' do
|
3
|
+
context 'when included by GSGraph::AdAccount' do
|
4
|
+
it 'should return generated ad_account' do
|
5
|
+
mock_graph :post, 'act_22334455/adcampaigns', 'ad_accounts/ad_campaigns/post_with_valid_access_token' do
|
6
|
+
ad_campaign = GSGraph::AdAccount.new('act_22334455', :access_token => 'valid').ad_campaign!(
|
7
|
+
:name => "Campaign 1",
|
8
|
+
:daily_budget => 500
|
9
|
+
)
|
10
|
+
|
11
|
+
ad_campaign.identifier.should == "6004167532222"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should handle the redownload parameter' do
|
16
|
+
mock_graph :post, 'act_22334455/adcampaigns', 'ad_accounts/ad_campaigns/post_with_redownload' do
|
17
|
+
ad_campaign = GSGraph::AdAccount.new('act_22334455', :access_token => 'valid').ad_campaign!(
|
18
|
+
:name => "Campaign 1",
|
19
|
+
:daily_budget => 500,
|
20
|
+
:redownload => true
|
21
|
+
)
|
22
|
+
|
23
|
+
ad_campaign.identifier.should == "6004167532222"
|
24
|
+
ad_campaign.account_id.should == 22334455
|
25
|
+
ad_campaign.name.should == "Campaign 1"
|
26
|
+
ad_campaign.daily_budget.should == 500
|
27
|
+
ad_campaign.campaign_status.should == 2
|
28
|
+
ad_campaign.daily_imps.should == 0
|
29
|
+
ad_campaign.start_time.should == Time.at(1330282800)
|
30
|
+
ad_campaign.end_time.should == Time.at(1330588800)
|
31
|
+
ad_campaign.updated_time.should == Time.at(1329850926)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
describe GSGraph::Connections::AdConnectionObjects, '#ad_connection_objects' do
|
2
|
+
context 'when included by GSGraph::AdAccount' do
|
3
|
+
context 'when access_token is given' do
|
4
|
+
it 'should return ad_connection_objects as GSGraph::AdConnectionObject' do
|
5
|
+
mock_graph :get, 'act_11223344/connectionobjects', 'ad_accounts/ad_connection_objects/test_connection_objects', :access_token => 'access_token' do
|
6
|
+
ad_connections = GSGraph::AdAccount.new("act_11223344", :access_token => 'access_token').connection_objects
|
7
|
+
ad_connections.size.should == 3
|
8
|
+
|
9
|
+
ad_connections.first.identifier.should == 354545238888
|
10
|
+
ad_connections.first.name.should == "MyPage"
|
11
|
+
ad_connections.first.url.should == "http://www.gamestamper.com/MyPage"
|
12
|
+
ad_connections.first.type.should == 1
|
13
|
+
ad_connections.first.picture.should == "http://profile.ak.fbcdn.net/hprofile-ak-snc4/41591_354545238178_3195000_s.jpg"
|
14
|
+
ad_connections.first.tabs.keys.size.should == 5
|
15
|
+
ad_connections.first.tabs["http://www.gamestamper.com/MyPage?sk=wall"].should == "Wall"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|