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,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::TestUser, '.new' do
|
4
|
+
|
5
|
+
it 'should setup all supported attributes' do
|
6
|
+
attributes = {
|
7
|
+
:id => 12345,
|
8
|
+
:access_token => 'access_token',
|
9
|
+
:name => 'nov',
|
10
|
+
:login_url => 'https://www.gamestamper.com/login/test-user/12345',
|
11
|
+
:email => 'test1@client.example.com',
|
12
|
+
:password => 'password'
|
13
|
+
}
|
14
|
+
test_user = GSGraph::TestUser.new(attributes.delete(:id), attributes)
|
15
|
+
test_user.login_url.should == 'https://www.gamestamper.com/login/test-user/12345'
|
16
|
+
test_user.name.should == 'nov'
|
17
|
+
test_user.email.should == 'test1@client.example.com'
|
18
|
+
test_user.password.should == 'password'
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
describe GSGraph::TestUser, '.friend!' do
|
24
|
+
|
25
|
+
before do
|
26
|
+
@u1 = GSGraph::TestUser.new(111, :access_token => 'token1')
|
27
|
+
@u2 = GSGraph::TestUser.new(222, :access_token => 'token2')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should POST twice' do
|
31
|
+
mock_graph :post, '111/friends/222', 'true', :access_token => 'token1' do
|
32
|
+
mock_graph :post, '222/friends/111', 'true', :access_token => 'token2' do
|
33
|
+
@u1.friend! @u2
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
describe GSGraph::TestUser, '.destroy' do
|
41
|
+
before do
|
42
|
+
@user = GSGraph::TestUser.new(111, :access_token => 'access_token')
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should DELETE /user_id' do
|
46
|
+
mock_graph :delete, '111', 'true', :access_token => 'access_token' do
|
47
|
+
@user.destroy
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Thread, '.new' do
|
4
|
+
it 'should setup all supported attributes' do
|
5
|
+
attributes = {
|
6
|
+
:id => "12345",
|
7
|
+
:snippet => 'test message',
|
8
|
+
:message_count => 2,
|
9
|
+
:unread_count => 1,
|
10
|
+
:updated_time => "2011-02-04T15:11:05+0000",
|
11
|
+
:tags => {
|
12
|
+
:data => [{
|
13
|
+
:name => "inbox"
|
14
|
+
}, {
|
15
|
+
:name => "source:web"
|
16
|
+
}]
|
17
|
+
},
|
18
|
+
:participants => {
|
19
|
+
:data => [{
|
20
|
+
:name => "Nov Matake",
|
21
|
+
:email => "xyz@gamestamper.com",
|
22
|
+
:id => "579612276"
|
23
|
+
}, {
|
24
|
+
:name => "Nov Matake",
|
25
|
+
:email => "abc@gamestamper.com",
|
26
|
+
:id => "1575327134"
|
27
|
+
}]
|
28
|
+
},
|
29
|
+
:senders => {
|
30
|
+
:data => [{
|
31
|
+
:name => "Nov Matake",
|
32
|
+
:email => "abc@gamestamper.com",
|
33
|
+
:id => "1575327134"
|
34
|
+
}]
|
35
|
+
},
|
36
|
+
:messages => {
|
37
|
+
:data => [{
|
38
|
+
:id => "m_25aaa73097e54594addb418c7bfbd05c",
|
39
|
+
:subject => "test",
|
40
|
+
:created_time => "2011-02-04T15:11:05+0000",
|
41
|
+
:tags => {
|
42
|
+
:data => [{
|
43
|
+
:name => "inbox"
|
44
|
+
}, {
|
45
|
+
:name => "source:web"
|
46
|
+
}]
|
47
|
+
},
|
48
|
+
:from => {
|
49
|
+
:name => "Nov Matake",
|
50
|
+
:email => "abc@gamestamper.com",
|
51
|
+
:id => "1575327134"
|
52
|
+
},
|
53
|
+
:to => {
|
54
|
+
:data => [{
|
55
|
+
:name => "Nov Matake",
|
56
|
+
:email => "xyz@gamestamper.com",
|
57
|
+
:id => "579612276"
|
58
|
+
}, {
|
59
|
+
:name => "Nov Matake",
|
60
|
+
:email => "abc@gamestamper.com",
|
61
|
+
:id => "1575327134"
|
62
|
+
}]
|
63
|
+
},
|
64
|
+
:message => "test"
|
65
|
+
}],
|
66
|
+
:paging => {
|
67
|
+
:previous => "https://graph.gamestamper.com/?access_token=access_token",
|
68
|
+
:next => "https://graph.gamestamper.com/?access_token=access_token"
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
thread = GSGraph::Thread.new(attributes.delete(:id), attributes)
|
73
|
+
thread.identifier.should == '12345'
|
74
|
+
thread.snippet.should == 'test message'
|
75
|
+
thread.message_count.should == 2
|
76
|
+
thread.unread_count.should == 1
|
77
|
+
thread.updated_time.should == Time.parse('2011-02-04T15:11:05+0000')
|
78
|
+
thread.tags.should == [
|
79
|
+
GSGraph::Tag.new(:name => 'inbox'),
|
80
|
+
GSGraph::Tag.new(:name => 'source:web')
|
81
|
+
]
|
82
|
+
thread.senders.should == [
|
83
|
+
GSGraph::User.new('1575327134', :name => 'Nov Matake', :email => 'abc@gamestamper.com')
|
84
|
+
]
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::UserAchievement do
|
4
|
+
subject { achievement }
|
5
|
+
let(:achievement) { GSGraph::UserAchievement.new(attributes[:id], attributes) }
|
6
|
+
let(:attributes) do
|
7
|
+
{
|
8
|
+
:id => "10150351898227277",
|
9
|
+
:from => {
|
10
|
+
:id => "10150351898227277",
|
11
|
+
:name => "Nov Matake"
|
12
|
+
},
|
13
|
+
:start_time => "2011-09-27T14:18:33+0000",
|
14
|
+
:end_time => "2011-09-27T14:18:33+0000",
|
15
|
+
:publish_time => "2011-09-27T14:18:33+0000",
|
16
|
+
:application => {
|
17
|
+
:id => "134145643294322",
|
18
|
+
:name => "gem sample"
|
19
|
+
},
|
20
|
+
:achievement => {
|
21
|
+
:id => "10150310611431721",
|
22
|
+
:url => "http:\/\/fbgraphsample.heroku.com\/achievements\/1",
|
23
|
+
:type => "game.achievement",
|
24
|
+
:title => "1st Achievement"
|
25
|
+
},
|
26
|
+
:likes => {
|
27
|
+
:count => 0
|
28
|
+
},
|
29
|
+
:comments => {
|
30
|
+
:count => 0
|
31
|
+
}
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
its(:from) { should be_a GSGraph::User }
|
36
|
+
its(:achievement) { should be_a GSGraph::Achievement }
|
37
|
+
its(:application) { should be_a GSGraph::Application }
|
38
|
+
its(:created_time) { should == Time.parse(attributes[:publish_time]).utc }
|
39
|
+
|
40
|
+
describe '#destroy' do
|
41
|
+
it 'should call DELETE /:app_id/achievements' do
|
42
|
+
expect { achievement.destroy }.to request_to('10150351898227277/achievements', :delete)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should delete achievement' do
|
46
|
+
mock_graph :delete, '10150351898227277/achievements', 'true', :access_token => 'app_token', :params => {
|
47
|
+
:achievement => achievement.achievement.url
|
48
|
+
} do
|
49
|
+
achievement.destroy(:access_token => 'app_token').should be_true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,185 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::User do
|
4
|
+
describe '.new' do
|
5
|
+
it 'should setup all supported attributes' do
|
6
|
+
attributes = {
|
7
|
+
:id => '12345',
|
8
|
+
:address => {
|
9
|
+
:city => "Kawasaki",
|
10
|
+
:state => "Kanagawa",
|
11
|
+
:country => "Japan"
|
12
|
+
},
|
13
|
+
:mobile_phone => '810000000000',
|
14
|
+
:installed => true
|
15
|
+
}
|
16
|
+
user = GSGraph::User.new(attributes.delete(:id), attributes)
|
17
|
+
user.address.should == GSGraph::Venue.new(attributes[:address])
|
18
|
+
user.mobile_phone.should == '810000000000'
|
19
|
+
user.installed.should be_true
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should support year-hidden birthday' do
|
23
|
+
user = GSGraph::User.new(12345, :birthday => '12/13')
|
24
|
+
user.birthday.year.should == 0
|
25
|
+
user.birthday.month.should == 12
|
26
|
+
user.birthday.day.should == 13
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should support non-default fields' do
|
30
|
+
mock_graph :get, 'me', 'users/with_non_default_fields', :access_token => 'access_token', :params => {
|
31
|
+
:fields => 'devices, video_upload_limits, age_range, currency'
|
32
|
+
} do
|
33
|
+
me = GSGraph::User.me('access_token').fetch(:fields => 'devices, video_upload_limits, age_range, currency')
|
34
|
+
|
35
|
+
# devices
|
36
|
+
me.devices.should be_instance_of Array
|
37
|
+
me.devices.each do |device|
|
38
|
+
device.should be_instance_of GSGraph::Device
|
39
|
+
end
|
40
|
+
me.devices.should == [GSGraph::Device.new(:os => 'iOS', :hardware => 'iPhone')]
|
41
|
+
|
42
|
+
# video_upload_limits
|
43
|
+
me.video_upload_limits.should be_instance_of ActiveSupport::HashWithIndifferentAccess
|
44
|
+
me.video_upload_limits.should == {'length' => 1200, 'size' => 1073741824}
|
45
|
+
|
46
|
+
# age_range
|
47
|
+
me.age_range.should be_instance_of GSGraph::AgeRange
|
48
|
+
me.age_range.should == Range.new(21, GSGraph::AgeRange::DEFAULT_MAX_AGE)
|
49
|
+
|
50
|
+
# currency
|
51
|
+
me.currency.should be_instance_of ActiveSupport::HashWithIndifferentAccess
|
52
|
+
me.currency.should == {
|
53
|
+
'user_currency' => 'JPY',
|
54
|
+
'currency_exchange' => 0.10846341,
|
55
|
+
'currency_exchange_inverse' => 9.2196990672,
|
56
|
+
'currency_offset' => 1
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '.me' do
|
63
|
+
it 'should return GSGraph::User instance with access_token' do
|
64
|
+
GSGraph::User.me('access_token').should == GSGraph::User.new('me', :access_token => 'access_token')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '.fetch' do
|
69
|
+
context 'with me context' do
|
70
|
+
|
71
|
+
context 'when no access_token given' do
|
72
|
+
it 'should raise GSGraph::Unauthorized' do
|
73
|
+
mock_graph :get, 'me', 'users/me_public', :status => [401, 'Unauthorized'] do
|
74
|
+
lambda do
|
75
|
+
GSGraph::User.fetch('me')
|
76
|
+
end.should raise_exception(GSGraph::Unauthorized)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'when access_token given' do
|
82
|
+
it 'should get current user profile' do
|
83
|
+
mock_graph :get, 'me', 'users/me_private', :access_token => 'access_token' do
|
84
|
+
user = GSGraph::User.me('access_token').fetch
|
85
|
+
user.interested_in.should == ['female']
|
86
|
+
user.relationship_status.should == 'Married'
|
87
|
+
user.website.should == 'http://matake.jp'
|
88
|
+
user.religion.should be_nil
|
89
|
+
user.political.should be_nil
|
90
|
+
user.timezone.should == 9
|
91
|
+
user.verified.should be_true
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'when no access_token given' do
|
99
|
+
it 'should get only public profile' do
|
100
|
+
mock_graph :get, 'arjun', 'users/arjun_public' do
|
101
|
+
user = GSGraph::User.fetch('arjun')
|
102
|
+
user.name.should == 'Arjun Banker'
|
103
|
+
user.first_name.should == 'Arjun'
|
104
|
+
user.last_name.should == 'Banker'
|
105
|
+
user.identifier.should == '7901103'
|
106
|
+
user.link.should == 'http://www.gamestamper.com/Arjun'
|
107
|
+
user.location.should == GSGraph::Page.new(114952118516947, :name => 'San Francisco, California')
|
108
|
+
user.gender.should == 'male'
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'when access_token given' do
|
114
|
+
it 'should get public + private profile' do
|
115
|
+
mock_graph :get, 'arjun', 'users/arjun_private', :access_token => 'access_token' do
|
116
|
+
user = GSGraph::User.fetch('arjun', :access_token => 'access_token')
|
117
|
+
|
118
|
+
# public
|
119
|
+
user.name.should == 'Arjun Banker'
|
120
|
+
user.first_name.should == 'Arjun'
|
121
|
+
user.last_name.should == 'Banker'
|
122
|
+
user.identifier.should == '7901103'
|
123
|
+
user.link.should == 'http://www.gamestamper.com/Arjun'
|
124
|
+
user.location.should == GSGraph::Page.new(114952118516947, :name => 'San Francisco, California')
|
125
|
+
user.gender.should == 'male'
|
126
|
+
|
127
|
+
# private
|
128
|
+
user.about.should == 'daydrea'
|
129
|
+
user.birthday.should == Date.strptime("04/15/1984", "%m/%d/%Y")
|
130
|
+
user.work.should == [
|
131
|
+
GSGraph::Work.new({
|
132
|
+
:employer => {:name => 'Facebook', :id => 20531316728},
|
133
|
+
:position => {:name => 'Software Engineer', :id => 107879555911138},
|
134
|
+
:location => {:name => 'Palo Alto, California', :id => 104022926303756},
|
135
|
+
:start_date => '2007-11'
|
136
|
+
}),
|
137
|
+
GSGraph::Work.new({
|
138
|
+
:employer => {:name => 'Zillow', :id => 113816405300191},
|
139
|
+
:position => {:name => 'Business Intelligence Analyst', :id => 105918922782444},
|
140
|
+
:start_date => '2006-03',
|
141
|
+
:end_date => '2007-10'
|
142
|
+
}),
|
143
|
+
GSGraph::Work.new({
|
144
|
+
:employer => {:name => 'Microsoft', :id => 20528438720},
|
145
|
+
:position => {:name => 'SDET', :id => 110006949022640},
|
146
|
+
:start_date => '2004-08',
|
147
|
+
:end_date => '2006-03'
|
148
|
+
}),
|
149
|
+
GSGraph::Work.new({
|
150
|
+
:employer => {:name => 'Dell', :id => 7706457055},
|
151
|
+
:position => {:name => 'Programmer Analyst', :id => 110344568993267},
|
152
|
+
:start_date => '2003-06',
|
153
|
+
:end_date => '2004-07'
|
154
|
+
})
|
155
|
+
]
|
156
|
+
user.education.should == [
|
157
|
+
GSGraph::Education.new({
|
158
|
+
:school => {:name => 'Texas Academy Of Math And Science', :id => 107922345906866},
|
159
|
+
:year => {:name => '2001', :id => 102241906483610}
|
160
|
+
}),
|
161
|
+
GSGraph::Education.new({
|
162
|
+
:school => {:name => 'The University of Texas at Austin', :id => 24147741537},
|
163
|
+
:year => {:name => '2003', :id => 108077232558120},
|
164
|
+
:concentration => [
|
165
|
+
{:name => 'Computer Science', :id => 116831821660155}
|
166
|
+
]
|
167
|
+
})
|
168
|
+
]
|
169
|
+
user.email.should == nil
|
170
|
+
user.website.should == nil
|
171
|
+
user.hometown.should == GSGraph::Page.new(109533479072558, :name => 'Minnetonka, Minnesota')
|
172
|
+
user.interested_in.should == ['female']
|
173
|
+
user.relationship_status.should == 'In a Relationship'
|
174
|
+
user.religion.should == 'zorp'
|
175
|
+
user.political.should == 'Liberal'
|
176
|
+
user.verified.should be_nil
|
177
|
+
# What's this?
|
178
|
+
# user.significant_other
|
179
|
+
user.timezone.should be_nil
|
180
|
+
user.updated_time.should == Time.parse('2010-05-29T04:29:23+0000')
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Venue, '.new' do
|
4
|
+
|
5
|
+
it 'should setup all supported attributes' do
|
6
|
+
attributes = {
|
7
|
+
:street => "409 Colorado St.",
|
8
|
+
:city => "Austin",
|
9
|
+
:state => "Texas",
|
10
|
+
:country => "United States",
|
11
|
+
:latitude => 30.2669,
|
12
|
+
:longitude => -97.7428
|
13
|
+
}
|
14
|
+
venue = GSGraph::Venue.new(attributes)
|
15
|
+
venue.street.should == "409 Colorado St."
|
16
|
+
venue.city.should == "Austin"
|
17
|
+
venue.state.should == "Texas"
|
18
|
+
venue.country.should == "United States"
|
19
|
+
venue.latitude.should == 30.2669
|
20
|
+
venue.longitude.should == -97.7428
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Video, '.new' do
|
4
|
+
|
5
|
+
it 'should setup all supported attributes' do
|
6
|
+
mock_graph :get, 'video', 'videos/private', :access_token => 'access_token' do
|
7
|
+
video = GSGraph::Video.new('video', :access_token => 'access_token').fetch
|
8
|
+
video.from.should be_a GSGraph::User
|
9
|
+
video.tags.should be_a Array
|
10
|
+
video.tags.each do |tag|
|
11
|
+
tag.should be_a GSGraph::Tag
|
12
|
+
end
|
13
|
+
[:name, :description, :embed_html, :icon, :source].each do |attribute|
|
14
|
+
video.send(attribute).should be_a String
|
15
|
+
end
|
16
|
+
[:created_time, :updated_time].each do |attribute|
|
17
|
+
video.send(attribute).should be_a Time
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should support page as from' do
|
23
|
+
page_video = GSGraph::Video.new('12345', :from => {
|
24
|
+
:id => '23456',
|
25
|
+
:name => 'Smart.fm',
|
26
|
+
:category => 'Web Site'
|
27
|
+
})
|
28
|
+
page_video.from.should == GSGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Work, '.new' do
|
4
|
+
|
5
|
+
it 'should setup all supported attributes' do
|
6
|
+
attributes = {
|
7
|
+
:employer => {
|
8
|
+
:id => 107722015925937,
|
9
|
+
:name => "Drecom Co., Ltd."
|
10
|
+
},
|
11
|
+
:location => {
|
12
|
+
:id => 111736052177472,
|
13
|
+
:name => "Tokyo, Tokyo"
|
14
|
+
},
|
15
|
+
:position => {
|
16
|
+
:id => 111091815582753,
|
17
|
+
:name => "Web Engineer"
|
18
|
+
},
|
19
|
+
:projects => [{
|
20
|
+
:id => 184246058253896,
|
21
|
+
:name => "Drecom Blog",
|
22
|
+
:with => [{
|
23
|
+
:id => 1064067203,
|
24
|
+
:name => "Takanori Ishikawa"
|
25
|
+
}],
|
26
|
+
:start_date => "2008-04",
|
27
|
+
:end_date => "2008-09"
|
28
|
+
}],
|
29
|
+
:start_date => "2007-04",
|
30
|
+
:end_date => "2008-09"
|
31
|
+
}
|
32
|
+
work = GSGraph::Work.new(attributes)
|
33
|
+
work.employer.should == GSGraph::Page.new(
|
34
|
+
107722015925937,
|
35
|
+
:name => "Drecom Co., Ltd."
|
36
|
+
)
|
37
|
+
work.location.should == GSGraph::Page.new(
|
38
|
+
111736052177472,
|
39
|
+
:name => "Tokyo, Tokyo"
|
40
|
+
)
|
41
|
+
work.position.should == GSGraph::Page.new(
|
42
|
+
111091815582753,
|
43
|
+
:name => "Web Engineer"
|
44
|
+
)
|
45
|
+
work.projects.should == [GSGraph::Project.new(
|
46
|
+
184246058253896,
|
47
|
+
:name => "Drecom Blog",
|
48
|
+
:with => [{
|
49
|
+
:id => 1064067203,
|
50
|
+
:name => "Takanori Ishikawa"
|
51
|
+
}],
|
52
|
+
:start_date => "2008-04",
|
53
|
+
:end_date => "2008-09"
|
54
|
+
)]
|
55
|
+
work.start_date.should == Date.new(2007, 4)
|
56
|
+
work.end_date.should == Date.new(2008, 9)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should ignore 0000-00 style date' do
|
60
|
+
attributes = {
|
61
|
+
:employer => {
|
62
|
+
:id => 105612642807396,
|
63
|
+
:name => "Cerego Japan Inc."
|
64
|
+
},
|
65
|
+
:start_date => "0000-00",
|
66
|
+
:end_date => "0000-00"
|
67
|
+
}
|
68
|
+
work = GSGraph::Work.new(attributes)
|
69
|
+
work.start_date.should be_nil
|
70
|
+
work.end_date.should be_nil
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should treat 2010-00 date ' do
|
74
|
+
attributes = {
|
75
|
+
:employer => {
|
76
|
+
:id => 105612642807396,
|
77
|
+
:name => "Cerego Japan Inc."
|
78
|
+
},
|
79
|
+
:start_date => "2008-00",
|
80
|
+
:end_date => "2010-00"
|
81
|
+
}
|
82
|
+
work = GSGraph::Work.new(attributes)
|
83
|
+
work.start_date.should == Date.new(2008, 1)
|
84
|
+
work.end_date.should == Date.new(2010, 1)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should treat 2010 date ' do
|
88
|
+
attributes = {
|
89
|
+
:employer => {
|
90
|
+
:id => 105612642807396,
|
91
|
+
:name => "Cerego Japan Inc."
|
92
|
+
},
|
93
|
+
:start_date => "2008",
|
94
|
+
:end_date => "2010"
|
95
|
+
}
|
96
|
+
work = GSGraph::Work.new(attributes)
|
97
|
+
work.start_date.should == Date.new(2008)
|
98
|
+
work.end_date.should == Date.new(2010)
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|