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,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Group, '.new' do
|
4
|
+
|
5
|
+
it 'should setup all supported attributes' do
|
6
|
+
attributes = {
|
7
|
+
:id => '12345',
|
8
|
+
:owner => {
|
9
|
+
:id => '23456',
|
10
|
+
:name => 'nov matake'
|
11
|
+
},
|
12
|
+
:name => 'group 1',
|
13
|
+
:description => 'a group for gs_graph test',
|
14
|
+
:link => 'http://www.gamestamper.com/group/12345',
|
15
|
+
:privacy => 'OPEN',
|
16
|
+
:updated_time => '2010-01-02T15:37:41+0000'
|
17
|
+
}
|
18
|
+
group = GSGraph::Group.new(attributes.delete(:id), attributes)
|
19
|
+
group.identifier.should == '12345'
|
20
|
+
group.owner.should == GSGraph::User.new('23456', :name => 'nov matake')
|
21
|
+
group.name.should == 'group 1'
|
22
|
+
group.description.should == 'a group for gs_graph test'
|
23
|
+
group.link.should == 'http://www.gamestamper.com/group/12345'
|
24
|
+
group.privacy.should == 'OPEN'
|
25
|
+
group.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Image, '.new' do
|
4
|
+
let :attributes do
|
5
|
+
{
|
6
|
+
:source => 'https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash1/168119_10150146071831729_20531316728_7844072_5116892_n.jpg',
|
7
|
+
:height => 483,
|
8
|
+
:width => 720
|
9
|
+
}
|
10
|
+
end
|
11
|
+
subject { GSGraph::Image.new(attributes) }
|
12
|
+
|
13
|
+
its(:source) { should == attributes[:source] }
|
14
|
+
its(:height) { should == attributes[:height] }
|
15
|
+
its(:width) { should == attributes[:width] }
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Insight, '.new' do
|
4
|
+
|
5
|
+
it 'should setup all supported attributes' do
|
6
|
+
attributes = {
|
7
|
+
:name => 'name_for_the_stats',
|
8
|
+
:period => 'day',
|
9
|
+
:values => [{'key1' => 'value2'}, {'key2' => 'value2'}]
|
10
|
+
}
|
11
|
+
insight = GSGraph::Insight.new('foo/insights/bar', attributes)
|
12
|
+
insight.identifier == 'foo/insights/bar'
|
13
|
+
insight.period.should == 'day'
|
14
|
+
insight.values.should == [{'key1' => 'value2'}, {'key2' => 'value2'}]
|
15
|
+
insight.values.first[:key1].should == 'value2'
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Link, '.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
|
+
:link => 'http://www.gamestamper.com/link/12345',
|
13
|
+
:name => 'name',
|
14
|
+
:description => 'description',
|
15
|
+
:icon => 'http://static.ak.fbcdn.net/rsrc.php/zB010/hash/9yvl71tw.gif',
|
16
|
+
:picture => 'http://i.ytimg.com/vi/JA068qeB0oM/2.jpg',
|
17
|
+
:message => 'check this out!',
|
18
|
+
:created_time => '2010-01-02T15:37:41+0000'
|
19
|
+
}
|
20
|
+
link = GSGraph::Link.new(attributes.delete(:id), attributes)
|
21
|
+
link.identifier.should == '12345'
|
22
|
+
link.from.should == GSGraph::User.new('23456', :name => 'nov matake')
|
23
|
+
link.link.should == 'http://www.gamestamper.com/link/12345'
|
24
|
+
link.name.should == 'name'
|
25
|
+
link.description.should == 'description'
|
26
|
+
link.icon.should == 'http://static.ak.fbcdn.net/rsrc.php/zB010/hash/9yvl71tw.gif'
|
27
|
+
link.picture.should == 'http://i.ytimg.com/vi/JA068qeB0oM/2.jpg'
|
28
|
+
link.message.should == 'check this out!'
|
29
|
+
link.created_time.should == Time.parse('2010-01-02T15:37:41+0000')
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should support page as from' do
|
33
|
+
page_link = GSGraph::Link.new('12345', :from => {
|
34
|
+
:id => '23456',
|
35
|
+
:name => 'Smart.fm',
|
36
|
+
:category => 'Web Site'
|
37
|
+
})
|
38
|
+
page_link.from.should == GSGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Location, '.new' do
|
4
|
+
|
5
|
+
it 'should setup all supported attributes' do
|
6
|
+
attributes = {
|
7
|
+
:latitude => 30.2669,
|
8
|
+
:longitude => -97.7428
|
9
|
+
}
|
10
|
+
location = GSGraph::Location.new(attributes)
|
11
|
+
location.latitude.should == 30.2669
|
12
|
+
location.longitude.should == -97.7428
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe GSGraph::Location, '.to_hash' do
|
18
|
+
|
19
|
+
it 'should setup all supported attributes' do
|
20
|
+
attributes = {
|
21
|
+
:latitude => 30.2669,
|
22
|
+
:longitude => -97.7428
|
23
|
+
}
|
24
|
+
location = GSGraph::Location.new(attributes)
|
25
|
+
location.to_hash == attributes
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Message, '.new' do
|
4
|
+
it 'should setup all supported attributes' do
|
5
|
+
attributes = {
|
6
|
+
:id => "12345",
|
7
|
+
:created_time => "2011-02-04T15:11:05+0000",
|
8
|
+
:tags => {
|
9
|
+
:data => [{
|
10
|
+
:name => "inbox"
|
11
|
+
}, {
|
12
|
+
:name => "source:web"
|
13
|
+
}]
|
14
|
+
},
|
15
|
+
:from => {
|
16
|
+
:name => "Nov Matake",
|
17
|
+
:email => "abc@gamestamper.com",
|
18
|
+
:id => "1575327134"
|
19
|
+
},
|
20
|
+
:to => {
|
21
|
+
:data => [{
|
22
|
+
:name => "Nov Matake",
|
23
|
+
:email => "xyz@gamestamper.com",
|
24
|
+
:id => "579612276"
|
25
|
+
}, {
|
26
|
+
:name => "Nov Matake",
|
27
|
+
:email => "abc@gamestamper.com",
|
28
|
+
:id => "1575327134"
|
29
|
+
}]
|
30
|
+
},
|
31
|
+
:message => "test test"
|
32
|
+
}
|
33
|
+
message = GSGraph::Message.new(attributes.delete(:id), attributes)
|
34
|
+
message.identifier.should == '12345'
|
35
|
+
message.message.should == 'test test'
|
36
|
+
message.created_time.should == Time.parse('2011-02-04T15:11:05+0000')
|
37
|
+
message.tags.should == [
|
38
|
+
GSGraph::Tag.new(:name => 'inbox'),
|
39
|
+
GSGraph::Tag.new(:name => 'source:web')
|
40
|
+
]
|
41
|
+
message.from.should == GSGraph::User.new('1575327134', :name => 'Nov Matake', :email => 'abc@gamestamper.com')
|
42
|
+
message.to.should == [
|
43
|
+
GSGraph::User.new('579612276', :name => 'Nov Matake', :email => 'xyz@gamestamper.com'),
|
44
|
+
GSGraph::User.new('1575327134', :name => 'Nov Matake', :email => 'abc@gamestamper.com')
|
45
|
+
]
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Node do
|
4
|
+
|
5
|
+
describe '.new' do
|
6
|
+
it 'should setup endpoint' do
|
7
|
+
GSGraph::Node.new('matake').endpoint.should == File.join(GSGraph::graph_url, 'matake')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should support access_token option' do
|
11
|
+
GSGraph::Node.new('matake', :access_token => 'access_token').access_token.should == 'access_token'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should store raw attributes' do
|
15
|
+
attributes = {:key => :value}
|
16
|
+
GSGraph::Node.new(12345, attributes).raw_attributes.should == attributes
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#build_params' do
|
21
|
+
let(:node) { node = GSGraph::Node.new('identifier') }
|
22
|
+
let(:tmpfile) { Tempfile.new('tmp') }
|
23
|
+
|
24
|
+
it 'should make all values to JSON or String' do
|
25
|
+
client = Rack::OAuth2::Client.new(:identifier => 'client_id', :secret => 'client_secret')
|
26
|
+
params = node.send :build_params, {:hash => {:a => :b}, :array => [:a, :b], :integer => 123}
|
27
|
+
params[:hash].should == '{"a":"b"}'
|
28
|
+
params[:array].should == '["a","b"]'
|
29
|
+
params[:integer].should == '123'
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should support Rack::OAuth2::AccessToken::Legacy as self.access_token' do
|
33
|
+
client = Rack::OAuth2::Client.new(:identifier => 'client_id', :secret => 'client_secret')
|
34
|
+
node = GSGraph::Node.new('identifier', :access_token => Rack::OAuth2::AccessToken::Legacy.new(:access_token => 'token'))
|
35
|
+
params = node.send :build_params, {}
|
36
|
+
params[:access_token].should == 'token'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should support Rack::OAuth2::AccessToken::Legacy as options[:access_token]' do
|
40
|
+
client = Rack::OAuth2::Client.new(:identifier => 'client_id', :secret => 'client_secret')
|
41
|
+
params = node.send :build_params, {:access_token => Rack::OAuth2::AccessToken::Legacy.new(:access_token => 'token')}
|
42
|
+
params[:access_token].should == 'token'
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should support Tempfile' do
|
46
|
+
params = node.send :build_params, :upload => tmpfile
|
47
|
+
(tmpfile.equal? params[:upload]).should be_true
|
48
|
+
# NOTE: For some reason, below fails with RSpec 2.10.0
|
49
|
+
# params[:upload].should == tmpfile
|
50
|
+
end
|
51
|
+
|
52
|
+
require 'action_dispatch/http/upload'
|
53
|
+
it 'should support ActionDispatch::Http::UploadedFile' do
|
54
|
+
upload = ActionDispatch::Http::UploadedFile.new(
|
55
|
+
:tempfile => tmpfile
|
56
|
+
)
|
57
|
+
params = node.send :build_params, :upload => upload
|
58
|
+
(params[:upload].equal? tmpfile).should be_true
|
59
|
+
# NOTE: For some reason, below fails with RSpec 2.10.0
|
60
|
+
# params[:upload].should == tmpfile
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#handle_response' do
|
65
|
+
it 'should handle null/false response' do
|
66
|
+
node = GSGraph::Node.new('identifier')
|
67
|
+
null_response = node.send :handle_response do
|
68
|
+
HTTP::Message.new_response 'null'
|
69
|
+
end
|
70
|
+
null_response.should be_nil
|
71
|
+
lambda do
|
72
|
+
node.send :handle_response do
|
73
|
+
HTTP::Message.new_response 'false'
|
74
|
+
end
|
75
|
+
end.should raise_error(
|
76
|
+
GSGraph::NotFound,
|
77
|
+
'Graph API returned false, so probably it means your requested object is not found.'
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should raise GSGraph::Exception for invalid JSON response' do
|
82
|
+
node = GSGraph::Node.new('identifier')
|
83
|
+
expect do
|
84
|
+
node.send :handle_response do
|
85
|
+
HTTP::Message.new_response 'invalid'
|
86
|
+
end
|
87
|
+
end.to raise_error GSGraph::Exception
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Note, '.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
|
+
:subject => 'TODO',
|
13
|
+
:message => 'later or never',
|
14
|
+
:created_time => '2010-01-02T15:37:40+0000',
|
15
|
+
:updated_time => '2010-01-02T15:37:41+0000',
|
16
|
+
:icon => 'http://static.ak.fbcdn.net/rsrc.php/z7NSY/hash/ajh5dbgz.gif'
|
17
|
+
}
|
18
|
+
note = GSGraph::Note.new(attributes.delete(:id), attributes)
|
19
|
+
note.identifier.should == '12345'
|
20
|
+
note.from.should == GSGraph::User.new('23456', :name => 'nov matake')
|
21
|
+
note.subject.should == 'TODO'
|
22
|
+
note.message.should == 'later or never'
|
23
|
+
note.created_time.should == Time.parse('2010-01-02T15:37:40+0000')
|
24
|
+
note.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
|
25
|
+
note.icon.should == 'http://static.ak.fbcdn.net/rsrc.php/z7NSY/hash/ajh5dbgz.gif'
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should support page as from' do
|
29
|
+
page_note = GSGraph::Note.new('12345', :from => {
|
30
|
+
:id => '23456',
|
31
|
+
:name => 'Smart.fm',
|
32
|
+
:category => 'Web Site'
|
33
|
+
})
|
34
|
+
page_note.from.should == GSGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Notification do
|
4
|
+
let :attributes do
|
5
|
+
{
|
6
|
+
:id => 'notif_579612276_139149416',
|
7
|
+
:title => 'Nobuhiro Nakajima commented on your status.',
|
8
|
+
:message => 'Actual Comment Here',
|
9
|
+
:link => 'http://www.gamestamper.com/matake/posts/10150574049082277',
|
10
|
+
:unread => 0,
|
11
|
+
:application => {
|
12
|
+
:id => '19675640871',
|
13
|
+
:name => 'Feed Comments'
|
14
|
+
},
|
15
|
+
:from => {
|
16
|
+
:id => '1260873121',
|
17
|
+
:name => 'Nobuhiro Nakajima'
|
18
|
+
},
|
19
|
+
:to => {
|
20
|
+
:id => '579612276',
|
21
|
+
:name => 'Nov Matake'
|
22
|
+
},
|
23
|
+
:created_time => '2012-01-25T04:01:09+0000',
|
24
|
+
:updated_time => '2012-01-25T04:01:20+0000'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should setup all supported attributes' do
|
29
|
+
notification = GSGraph::Notification.new(attributes[:id], attributes)
|
30
|
+
notification.identifier.should == attributes[:id]
|
31
|
+
notification.title.should == attributes[:title]
|
32
|
+
notification.message.should == attributes[:message]
|
33
|
+
notification.link.should == attributes[:link]
|
34
|
+
notification.unread.should be_false
|
35
|
+
notification.application.should == GSGraph::Application.new(
|
36
|
+
attributes[:application][:id], attributes[:application]
|
37
|
+
)
|
38
|
+
notification.from.should == GSGraph::User.new(
|
39
|
+
attributes[:from][:id], attributes[:from]
|
40
|
+
)
|
41
|
+
notification.to.should == GSGraph::User.new(
|
42
|
+
attributes[:to][:id], attributes[:to]
|
43
|
+
)
|
44
|
+
notification.created_time.should == Time.parse('2012-01-25T04:01:09+0000')
|
45
|
+
notification.updated_time.should == Time.parse('2012-01-25T04:01:20+0000')
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#read!' do
|
49
|
+
it 'should update unread to read' do
|
50
|
+
mock_graph :post, 'notification_id', 'true', :params => {
|
51
|
+
:unread => 'false'
|
52
|
+
}, :access_token => 'access_token' do
|
53
|
+
GSGraph::Notification.new('notification_id').read!(
|
54
|
+
:access_token => 'access_token'
|
55
|
+
).should be_true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::Offer do
|
4
|
+
let(:offer) { mock_graph(:get, '23456/offers', 'offers/private', :access_token => 'access_token') { offer = page.offers[0] }}
|
5
|
+
let(:page) { GSGraph::Page.new('23456', {:name => 'page_name', :category => 'page_cat', :access_token => 'access_token'}) }
|
6
|
+
|
7
|
+
describe '.new' do
|
8
|
+
it 'should setup all supported attributes' do
|
9
|
+
offer.identifier.should == '12345'
|
10
|
+
offer.from.should == GSGraph::Page.new('23456', {:name => 'page_name', :category => 'page_cat'})
|
11
|
+
offer.title.should == 'offer 1'
|
12
|
+
offer.created_time.should == Time.parse('2011-10-14T21:00:00+0000').utc
|
13
|
+
offer.expiration_time.should == Time.parse('2018-03-15T00:30:00+0000').utc
|
14
|
+
offer.terms.should == 'One offer per customer'
|
15
|
+
offer.image_url.should == 'http://example.org/image.png'
|
16
|
+
offer.coupon_type.should == 'online_only'
|
17
|
+
offer.claim_limit.should == 1000
|
18
|
+
offer.redemption_link.should == 'http://example.org/redeem'
|
19
|
+
offer.redemption_code.should == nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#update' do
|
24
|
+
it 'should update existing offer' do
|
25
|
+
lambda do
|
26
|
+
offer.update(:terms => 'Two offers per customer', :access_token => 'access_token')
|
27
|
+
end.should request_to('12345', :post)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GSGraph::OpenGraph::Action do
|
4
|
+
subject do
|
5
|
+
GSGraph::OpenGraph::Action.new attributes[:id], attributes
|
6
|
+
end
|
7
|
+
let :attributes do
|
8
|
+
MultiJson.load(json).with_indifferent_access
|
9
|
+
end
|
10
|
+
shared_examples_for :og_action_initialized do
|
11
|
+
its(:from) do
|
12
|
+
should == GSGraph::User.new(attributes[:from][:id], attributes[:from])
|
13
|
+
end
|
14
|
+
its(:application) do
|
15
|
+
should == GSGraph::Application.new(attributes[:application][:id], attributes[:application])
|
16
|
+
end
|
17
|
+
[:start_time, :end_time, :publish_time].each do |key|
|
18
|
+
its(key) { should == Time.parse(attributes[key]) }
|
19
|
+
end
|
20
|
+
its(:objects) { should be_a Hash }
|
21
|
+
its(:likes) { should be_instance_of GSGraph::Connection }
|
22
|
+
its(:comments) { should be_instance_of GSGraph::Connection }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'with play action' do
|
26
|
+
let :json do
|
27
|
+
<<-JSON
|
28
|
+
{
|
29
|
+
"id": "10150402047187277",
|
30
|
+
"from": {
|
31
|
+
"id": "579612276",
|
32
|
+
"name": "Nov Matake"
|
33
|
+
},
|
34
|
+
"start_time": "2011-11-05T00:19:01+0000",
|
35
|
+
"end_time": "2011-11-05T00:19:01+0000",
|
36
|
+
"publish_time": "2011-11-05T00:19:01+0000",
|
37
|
+
"application": {
|
38
|
+
"id": "134145643294322",
|
39
|
+
"name": "gem sample"
|
40
|
+
},
|
41
|
+
"data": {
|
42
|
+
"game": {
|
43
|
+
"id": "10150267719331290",
|
44
|
+
"url": "http:\/\/samples.ogp.me\/163382137069945",
|
45
|
+
"type": "game",
|
46
|
+
"title": "Sample Game"
|
47
|
+
}
|
48
|
+
},
|
49
|
+
"likes": {
|
50
|
+
"count": 0
|
51
|
+
},
|
52
|
+
"comments": {
|
53
|
+
"count": 0
|
54
|
+
},
|
55
|
+
"type": "games.plays"
|
56
|
+
}
|
57
|
+
JSON
|
58
|
+
end
|
59
|
+
it_behaves_like :og_action_initialized
|
60
|
+
its(:type) { should == 'games.plays' }
|
61
|
+
it 'should have a game object' do
|
62
|
+
subject.objects['game'].should == subject.objects[:game]
|
63
|
+
subject.objects[:game].should be_instance_of GSGraph::OpenGraph::Object
|
64
|
+
subject.objects[:game].type.should == 'game'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'with custom action' do
|
69
|
+
let :json do
|
70
|
+
<<-JSON
|
71
|
+
{
|
72
|
+
"id": "10150389446227277",
|
73
|
+
"from": {
|
74
|
+
"id": "579612276",
|
75
|
+
"name": "Nov Matake"
|
76
|
+
},
|
77
|
+
"start_time": "2011-10-26T02:21:00+0000",
|
78
|
+
"end_time": "2011-10-26T02:21:00+0000",
|
79
|
+
"publish_time": "2011-10-26T02:21:00+0000",
|
80
|
+
"application": {
|
81
|
+
"id": "134145643294322",
|
82
|
+
"name": "gem sample"
|
83
|
+
},
|
84
|
+
"data": {
|
85
|
+
"custom_field": "This is not a JSON object.",
|
86
|
+
"custom_object": {
|
87
|
+
"id": "10150362170052970",
|
88
|
+
"url": "http:\/\/samples.ogp.me\/264755040233381",
|
89
|
+
"type": "fbgraphsample:custom_object",
|
90
|
+
"title": "Custom Object"
|
91
|
+
}
|
92
|
+
},
|
93
|
+
"likes": {
|
94
|
+
"count": 0
|
95
|
+
},
|
96
|
+
"comments": {
|
97
|
+
"count": 0
|
98
|
+
},
|
99
|
+
"type": "fbgraphsample:custom_action"
|
100
|
+
}
|
101
|
+
JSON
|
102
|
+
end
|
103
|
+
it_behaves_like :og_action_initialized
|
104
|
+
its(:type) { should == 'fbgraphsample:custom_action' }
|
105
|
+
it 'should have a custom object' do
|
106
|
+
subject.objects['custom_object'].should == subject.objects[:custom_object]
|
107
|
+
subject.objects[:custom_object].should be_instance_of GSGraph::OpenGraph::Object
|
108
|
+
subject.objects[:custom_object].type.should == 'fbgraphsample:custom_object'
|
109
|
+
subject.objects[:custom_field].should == 'This is not a JSON object.'
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|