gs_graph 2.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,61 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe GSGraph::Education, '.new' do
|
|
4
|
+
|
|
5
|
+
it 'should setup all supported attributes' do
|
|
6
|
+
attributes = {
|
|
7
|
+
:school => {
|
|
8
|
+
:id => 110149592341159,
|
|
9
|
+
:name => "\u540c\u5fd7\u793e\u5927\u5b66"
|
|
10
|
+
},
|
|
11
|
+
:degree => {
|
|
12
|
+
:id => 110616875633830,
|
|
13
|
+
:name => "Master of Engineering"
|
|
14
|
+
},
|
|
15
|
+
:year => {
|
|
16
|
+
:id => 104926492884272,
|
|
17
|
+
:name => "2007"
|
|
18
|
+
},
|
|
19
|
+
:concentration => [
|
|
20
|
+
{
|
|
21
|
+
:id => 112303688789448,
|
|
22
|
+
:name => "Engineering"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
:id => 102358546472290,
|
|
26
|
+
:name => "Intelligent Information"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
:id => 108311762535367,
|
|
30
|
+
:name => "Intelligent Systems Design Laboratory"
|
|
31
|
+
}
|
|
32
|
+
] }
|
|
33
|
+
education = GSGraph::Education.new(attributes)
|
|
34
|
+
education.school.should == GSGraph::Page.new(
|
|
35
|
+
110149592341159,
|
|
36
|
+
:name => "\u540c\u5fd7\u793e\u5927\u5b66"
|
|
37
|
+
)
|
|
38
|
+
education.degree.should == GSGraph::Page.new(
|
|
39
|
+
110616875633830,
|
|
40
|
+
:name => "Master of Engineering"
|
|
41
|
+
)
|
|
42
|
+
education.year.should == GSGraph::Page.new(
|
|
43
|
+
104926492884272,
|
|
44
|
+
:name => "2007"
|
|
45
|
+
)
|
|
46
|
+
education.concentration.should == [
|
|
47
|
+
GSGraph::Page.new(
|
|
48
|
+
112303688789448,
|
|
49
|
+
:name => "Engineering"
|
|
50
|
+
),
|
|
51
|
+
GSGraph::Page.new(
|
|
52
|
+
102358546472290,
|
|
53
|
+
:name => "Intelligent Information"
|
|
54
|
+
),
|
|
55
|
+
GSGraph::Page.new(
|
|
56
|
+
108311762535367,
|
|
57
|
+
:name => "Intelligent Systems Design Laboratory"
|
|
58
|
+
)
|
|
59
|
+
]
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe GSGraph::Event do
|
|
4
|
+
let :attributes do
|
|
5
|
+
{
|
|
6
|
+
:id => '12345',
|
|
7
|
+
:owner => {
|
|
8
|
+
:id => '23456',
|
|
9
|
+
:name => 'nov matake'
|
|
10
|
+
},
|
|
11
|
+
:name => 'event 1',
|
|
12
|
+
:description => 'an event for gs_graph test',
|
|
13
|
+
:start_time => '2010-03-14T21:00:00+0000',
|
|
14
|
+
:end_time => '2010-03-15T00:30:00+0000',
|
|
15
|
+
:location => 'Smart.fm office',
|
|
16
|
+
:venue => {
|
|
17
|
+
:street => 'Sakuragaoka',
|
|
18
|
+
:city => 'Shibuya',
|
|
19
|
+
:state => 'Tokyo',
|
|
20
|
+
:zip => '150-0031',
|
|
21
|
+
:country => 'Japan',
|
|
22
|
+
:latitude => '35.685',
|
|
23
|
+
:longitude => '139.751'
|
|
24
|
+
},
|
|
25
|
+
:privacy => 'OPEN',
|
|
26
|
+
:updated_time => '2010-01-02T15:37:41+0000'
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
let(:event) { GSGraph::Event.new(attributes.delete(:id), attributes) }
|
|
30
|
+
|
|
31
|
+
describe '.new' do
|
|
32
|
+
it 'should setup all supported attributes' do
|
|
33
|
+
event.identifier.should == '12345'
|
|
34
|
+
event.owner.should == GSGraph::User.new('23456', :name => 'nov matake')
|
|
35
|
+
event.name.should == 'event 1'
|
|
36
|
+
event.description.should == 'an event for gs_graph test'
|
|
37
|
+
event.start_time.should == Time.parse('2010-03-14T21:00:00+0000')
|
|
38
|
+
event.end_time.should == Time.parse('2010-03-15T00:30:00+0000')
|
|
39
|
+
event.location.should == 'Smart.fm office'
|
|
40
|
+
event.venue.should == GSGraph::Venue.new(
|
|
41
|
+
:street => 'Sakuragaoka',
|
|
42
|
+
:city => 'Shibuya',
|
|
43
|
+
:state => 'Tokyo',
|
|
44
|
+
:zip => '150-0031',
|
|
45
|
+
:country => 'Japan',
|
|
46
|
+
:latitude => '35.685',
|
|
47
|
+
:longitude => '139.751'
|
|
48
|
+
)
|
|
49
|
+
event.privacy.should == 'OPEN'
|
|
50
|
+
event.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe '#update' do
|
|
55
|
+
it 'should update existing event' do
|
|
56
|
+
lambda do
|
|
57
|
+
event.update(:location => 'Kyoto', :access_token => 'access_token')
|
|
58
|
+
end.should request_to('12345', :post)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
context 'when venue is a page' do
|
|
63
|
+
it 'should use GSGraph::Page instead of GSGraph::Venue' do
|
|
64
|
+
mock_graph :get, 'event_id', 'events/with_venue_as_page', :access_token => 'access_token' do
|
|
65
|
+
event = GSGraph::Event.fetch('event_id', :access_token => 'access_token')
|
|
66
|
+
event.venue.should be_instance_of GSGraph::Page
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe GSGraph::Exception do
|
|
4
|
+
it 'should properly set its message for inspect' do
|
|
5
|
+
err = GSGraph::Exception.new(400, 'This is the error message')
|
|
6
|
+
err.inspect.should == '#<GSGraph::Exception: This is the error message>'
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
context 'when response body is given' do
|
|
10
|
+
it 'should setup message and type from error' do
|
|
11
|
+
err = GSGraph::Exception.new(400, 'This is the original message', {
|
|
12
|
+
:error => {
|
|
13
|
+
:type => 'SomeError',
|
|
14
|
+
:message => 'This is the error message'
|
|
15
|
+
}
|
|
16
|
+
}.to_json)
|
|
17
|
+
err.code.should == 400
|
|
18
|
+
err.type.should == 'SomeError'
|
|
19
|
+
err.message.should == 'This is the error message'
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context 'when response body is not given' do
|
|
24
|
+
it 'should not have type' do
|
|
25
|
+
err = GSGraph::Exception.new(400, 'This is the original message')
|
|
26
|
+
err.code.should == 400
|
|
27
|
+
err.type.should be_nil
|
|
28
|
+
err.message.should == 'This is the original message'
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe GSGraph::BadRequest do
|
|
34
|
+
it 'should have 400 status code' do
|
|
35
|
+
err = GSGraph::BadRequest.new 'Bad Request'
|
|
36
|
+
err.code.should == 400
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe GSGraph::Unauthorized do
|
|
41
|
+
it 'should have 401 status code' do
|
|
42
|
+
err = GSGraph::Unauthorized.new 'Unauthorized'
|
|
43
|
+
err.code.should == 401
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe GSGraph::NotFound do
|
|
48
|
+
it 'should have 404 status code' do
|
|
49
|
+
err = GSGraph::NotFound.new 'Not Found'
|
|
50
|
+
err.code.should == 404
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe GSGraph::Exception, ".handle_httpclient_error" do
|
|
55
|
+
context "when WWW-Authenticate header is present" do
|
|
56
|
+
context "with an expired access token" do
|
|
57
|
+
let(:parsed_response) do
|
|
58
|
+
{
|
|
59
|
+
:error => {
|
|
60
|
+
:message => "Error validating access token: The session has been invalidated because the user has changed the password.",
|
|
61
|
+
:type => "OAuthException"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
end
|
|
65
|
+
let(:headers) do
|
|
66
|
+
{
|
|
67
|
+
"WWW-Authenticate" => 'OAuth "Facebook Platform" "invalid_token" "Error validating access token: The session has been invalidated because the user has changed the password.'
|
|
68
|
+
}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "should raise an InvalidSession exception" do
|
|
72
|
+
lambda {GSGraph::Exception.handle_httpclient_error(parsed_response, headers)}.should raise_exception(GSGraph::InvalidSession)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
context "with an invalid access token" do
|
|
77
|
+
let(:parsed_response) do
|
|
78
|
+
{
|
|
79
|
+
:error => {
|
|
80
|
+
:message => 'Invalid OAuth access token.',
|
|
81
|
+
:type => "OAuthException"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
end
|
|
85
|
+
let(:headers) do
|
|
86
|
+
{
|
|
87
|
+
"WWW-Authenticate" => 'OAuth "Facebook Platform" "invalid_token" "Invalid OAuth access token."'
|
|
88
|
+
}
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "should raise an InvalidToken exception" do
|
|
92
|
+
lambda {GSGraph::Exception.handle_httpclient_error(parsed_response, headers)}.should raise_exception(GSGraph::InvalidToken)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
context "with a variant capitalization of the header" do
|
|
96
|
+
let(:headers) do
|
|
97
|
+
{
|
|
98
|
+
"Www-Authenticate" => 'OAuth "Facebook Platform" "invalid_token" "Invalid OAuth access token."'
|
|
99
|
+
}
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "should raise an InvalidToken exception" do
|
|
103
|
+
lambda {GSGraph::Exception.handle_httpclient_error(parsed_response, headers)}.should raise_exception(GSGraph::InvalidToken)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
context "with an invalid request" do
|
|
109
|
+
let(:parsed_response) do
|
|
110
|
+
{
|
|
111
|
+
:error => {
|
|
112
|
+
:message => '(#100) Must include the \"campaign_id\" index',
|
|
113
|
+
:type => "OAuthException"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
end
|
|
117
|
+
let(:headers) do
|
|
118
|
+
{
|
|
119
|
+
"WWW-Authenticate" =>'OAuth "Facebook Platform" "invalid_request" "(#100) Must include the \"campaign_id\" index"'
|
|
120
|
+
}
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it "should raise an InvalidRequest exception" do
|
|
124
|
+
lambda {GSGraph::Exception.handle_httpclient_error(parsed_response, headers)}.should raise_exception(GSGraph::InvalidRequest)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
context "without the WWW-Authenticate header" do
|
|
130
|
+
context "with an OAuthException" do
|
|
131
|
+
let(:parsed_response) do
|
|
132
|
+
{
|
|
133
|
+
:error => {
|
|
134
|
+
:message => 'Some kind of OAuthException',
|
|
135
|
+
:type => "OAuthException"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it "should raise an Unauthorized exception" do
|
|
141
|
+
lambda {GSGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(GSGraph::Unauthorized)
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
context "with an Exception" do
|
|
146
|
+
let(:parsed_response) do
|
|
147
|
+
{
|
|
148
|
+
:error => {
|
|
149
|
+
:message => 'Some kind of Exception',
|
|
150
|
+
:type => "Exception"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it "should raise a BadRequest exception" do
|
|
156
|
+
lambda {GSGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(GSGraph::BadRequest)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
context "with an Ads API Exception" do
|
|
160
|
+
context "of Could not save creative" do
|
|
161
|
+
let(:parsed_response) do
|
|
162
|
+
{
|
|
163
|
+
:error => {
|
|
164
|
+
:message => 'Could not save creative',
|
|
165
|
+
:type => "Exception"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it "should raise a CreativeNotSaved exception" do
|
|
171
|
+
lambda {GSGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(GSGraph::CreativeNotSaved)
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
context "of QueryLockTimeout" do
|
|
176
|
+
let(:parsed_response) do
|
|
177
|
+
{
|
|
178
|
+
:error => {
|
|
179
|
+
:message => 'QueryLockTimeoutException',
|
|
180
|
+
:type => "Exception"
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
it "should raise a QueryLockTimeout exception" do
|
|
186
|
+
lambda {GSGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(GSGraph::QueryLockTimeout)
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
context "of Could not create targeting spec" do
|
|
191
|
+
let(:parsed_response) do
|
|
192
|
+
{
|
|
193
|
+
:error => {
|
|
194
|
+
:message => 'Could not create targeting spec',
|
|
195
|
+
:type => "Exception"
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
it "should raise a TargetingSpecNotSaved exception" do
|
|
201
|
+
lambda {GSGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(GSGraph::TargetingSpecNotSaved)
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
context "of Could not fetch adgroups" do
|
|
206
|
+
let(:parsed_response) do
|
|
207
|
+
{
|
|
208
|
+
:error => {
|
|
209
|
+
:message => 'Could not fetch adgroups',
|
|
210
|
+
:type => "Exception"
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
it "should raise a AdgroupFetchFailure exception" do
|
|
216
|
+
lambda {GSGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(GSGraph::AdgroupFetchFailure)
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
context "of Failed to open process" do
|
|
221
|
+
let(:parsed_response) do
|
|
222
|
+
{
|
|
223
|
+
:error => {
|
|
224
|
+
:message => 'Failed to open process',
|
|
225
|
+
:type => "Exception"
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
it "should raise a OpenProcessFailure exception" do
|
|
231
|
+
lambda {GSGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(GSGraph::OpenProcessFailure)
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
context "of Could not commit transaction" do
|
|
236
|
+
let(:parsed_response) do
|
|
237
|
+
{
|
|
238
|
+
:error => {
|
|
239
|
+
:message => 'Could not commit transaction',
|
|
240
|
+
:type => "Exception"
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
it "should raise a TransactionCommitFailure exception" do
|
|
246
|
+
lambda {GSGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(GSGraph::TransactionCommitFailure)
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
context "of QueryErrorException" do
|
|
251
|
+
let(:parsed_response) do
|
|
252
|
+
{
|
|
253
|
+
:error => {
|
|
254
|
+
:message => 'DB Error: QueryErrorException',
|
|
255
|
+
:type => "Exception"
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
it "should raise a QueryError exception" do
|
|
261
|
+
lambda {GSGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(GSGraph::QueryError)
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
context "of QueryConnectionException" do
|
|
266
|
+
let(:parsed_response) do
|
|
267
|
+
{
|
|
268
|
+
:error => {
|
|
269
|
+
:message => 'QueryConnectionException',
|
|
270
|
+
:type => "Exception"
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
it "should raise a QueryConnection exception" do
|
|
276
|
+
lambda {GSGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(GSGraph::QueryConnection)
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
context "of QueryDuplicateKeyException" do
|
|
281
|
+
let(:parsed_response) do
|
|
282
|
+
{
|
|
283
|
+
:error => {
|
|
284
|
+
:message => 'QueryDuplicateKeyException',
|
|
285
|
+
:type => "Exception"
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
it "should raise a QueryDuplicateKey exception" do
|
|
291
|
+
lambda {GSGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(GSGraph::QueryDuplicateKey)
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
context "with an Exception not containing the error field" do
|
|
297
|
+
let(:parsed_response) do
|
|
298
|
+
{
|
|
299
|
+
:error_code => 1,
|
|
300
|
+
:error_msg => "An unknown error occurred."
|
|
301
|
+
}
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
it "should raise an InternalServerError exception" do
|
|
305
|
+
lambda {GSGraph::Exception.handle_httpclient_error(parsed_response, {})}.should raise_exception(GSGraph::InternalServerError)
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe GSGraph::FriendList do
|
|
4
|
+
|
|
5
|
+
it 'should setup all supported attributes' do
|
|
6
|
+
attributes = {
|
|
7
|
+
:id => '12345',
|
|
8
|
+
:name => 'My List'
|
|
9
|
+
}
|
|
10
|
+
video = GSGraph::FriendList.new(attributes.delete(:id), attributes)
|
|
11
|
+
video.identifier.should == '12345'
|
|
12
|
+
video.name.should == 'My List'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe 'destroy' do
|
|
16
|
+
it 'should return true' do
|
|
17
|
+
mock_graph :delete, 'list_id', 'true', :access_token => 'access_token' do
|
|
18
|
+
GSGraph::FriendList.new('list_id').destroy(:access_token => 'access_token').should be_true
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|