gs_graph 2.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (348) hide show
  1. data/.document +5 -0
  2. data/.gitattributes +22 -0
  3. data/.gitignore +26 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +3 -0
  6. data/Gemfile +11 -0
  7. data/Gemfile.lock +95 -0
  8. data/LICENSE +20 -0
  9. data/README.rdoc +314 -0
  10. data/Rakefile +25 -0
  11. data/VERSION +1 -0
  12. data/assets/fb_graph.ai +1726 -6
  13. data/assets/fb_graph.png +0 -0
  14. data/gs_graph.gemspec +28 -0
  15. data/lib/gs_graph.rb +174 -0
  16. data/lib/gs_graph/achievement.rb +44 -0
  17. data/lib/gs_graph/action.rb +12 -0
  18. data/lib/gs_graph/ad_account.rb +51 -0
  19. data/lib/gs_graph/ad_campaign.rb +39 -0
  20. data/lib/gs_graph/ad_campaign_stat.rb +22 -0
  21. data/lib/gs_graph/ad_connection_object.rb +53 -0
  22. data/lib/gs_graph/ad_creative.rb +44 -0
  23. data/lib/gs_graph/ad_group.rb +51 -0
  24. data/lib/gs_graph/ad_group_stat.rb +22 -0
  25. data/lib/gs_graph/ad_keyword.rb +20 -0
  26. data/lib/gs_graph/ad_keyword_suggestion.rb +8 -0
  27. data/lib/gs_graph/ad_keyword_valid.rb +23 -0
  28. data/lib/gs_graph/ad_preview.rb +10 -0
  29. data/lib/gs_graph/ad_user.rb +58 -0
  30. data/lib/gs_graph/age_range.rb +12 -0
  31. data/lib/gs_graph/album.rb +59 -0
  32. data/lib/gs_graph/app_request.rb +24 -0
  33. data/lib/gs_graph/application.rb +119 -0
  34. data/lib/gs_graph/auth.rb +88 -0
  35. data/lib/gs_graph/auth/cookie.rb +20 -0
  36. data/lib/gs_graph/auth/signed_request.rb +44 -0
  37. data/lib/gs_graph/broad_targeting_category.rb +13 -0
  38. data/lib/gs_graph/checkin.rb +51 -0
  39. data/lib/gs_graph/collection.rb +55 -0
  40. data/lib/gs_graph/comment.rb +24 -0
  41. data/lib/gs_graph/comparison.rb +13 -0
  42. data/lib/gs_graph/connection.rb +37 -0
  43. data/lib/gs_graph/connections.rb +3 -0
  44. data/lib/gs_graph/connections/accounts.rb +23 -0
  45. data/lib/gs_graph/connections/achievements.rb +21 -0
  46. data/lib/gs_graph/connections/activities.rb +14 -0
  47. data/lib/gs_graph/connections/ad_accounts.rb +15 -0
  48. data/lib/gs_graph/connections/ad_campaign_stats.rb +22 -0
  49. data/lib/gs_graph/connections/ad_campaigns.rb +30 -0
  50. data/lib/gs_graph/connections/ad_connection_objects.rb +14 -0
  51. data/lib/gs_graph/connections/ad_creatives.rb +14 -0
  52. data/lib/gs_graph/connections/ad_group_stats.rb +22 -0
  53. data/lib/gs_graph/connections/ad_groups.rb +35 -0
  54. data/lib/gs_graph/connections/ad_previews.rb +10 -0
  55. data/lib/gs_graph/connections/admins.rb +10 -0
  56. data/lib/gs_graph/connections/albums.rb +21 -0
  57. data/lib/gs_graph/connections/app_notifications.rb +10 -0
  58. data/lib/gs_graph/connections/app_requests.rb +21 -0
  59. data/lib/gs_graph/connections/attending.rb +26 -0
  60. data/lib/gs_graph/connections/banned.rb +31 -0
  61. data/lib/gs_graph/connections/blocked.rb +36 -0
  62. data/lib/gs_graph/connections/books.rb +14 -0
  63. data/lib/gs_graph/connections/broad_targeting_categories.rb +14 -0
  64. data/lib/gs_graph/connections/checkins.rb +21 -0
  65. data/lib/gs_graph/connections/comments.rb +21 -0
  66. data/lib/gs_graph/connections/conversations.rb +14 -0
  67. data/lib/gs_graph/connections/declined.rb +25 -0
  68. data/lib/gs_graph/connections/docs.rb +14 -0
  69. data/lib/gs_graph/connections/events.rb +21 -0
  70. data/lib/gs_graph/connections/family.rb +14 -0
  71. data/lib/gs_graph/connections/feed.rb +21 -0
  72. data/lib/gs_graph/connections/former_participants.rb +14 -0
  73. data/lib/gs_graph/connections/friend_lists.rb +21 -0
  74. data/lib/gs_graph/connections/friend_requests.rb +12 -0
  75. data/lib/gs_graph/connections/friends.rb +14 -0
  76. data/lib/gs_graph/connections/games.rb +14 -0
  77. data/lib/gs_graph/connections/groups.rb +14 -0
  78. data/lib/gs_graph/connections/home.rb +14 -0
  79. data/lib/gs_graph/connections/inbox.rb +20 -0
  80. data/lib/gs_graph/connections/insights.rb +27 -0
  81. data/lib/gs_graph/connections/interests.rb +14 -0
  82. data/lib/gs_graph/connections/invited.rb +36 -0
  83. data/lib/gs_graph/connections/likes.rb +29 -0
  84. data/lib/gs_graph/connections/links.rb +21 -0
  85. data/lib/gs_graph/connections/maybe.rb +25 -0
  86. data/lib/gs_graph/connections/members.rb +22 -0
  87. data/lib/gs_graph/connections/messages.rb +22 -0
  88. data/lib/gs_graph/connections/milestones.rb +21 -0
  89. data/lib/gs_graph/connections/movies.rb +14 -0
  90. data/lib/gs_graph/connections/music.rb +14 -0
  91. data/lib/gs_graph/connections/mutual_friends.rb +26 -0
  92. data/lib/gs_graph/connections/noreply.rb +23 -0
  93. data/lib/gs_graph/connections/notes.rb +21 -0
  94. data/lib/gs_graph/connections/notifications.rb +18 -0
  95. data/lib/gs_graph/connections/offers.rb +22 -0
  96. data/lib/gs_graph/connections/outbox.rb +20 -0
  97. data/lib/gs_graph/connections/participants.rb +14 -0
  98. data/lib/gs_graph/connections/payments.rb +14 -0
  99. data/lib/gs_graph/connections/permissions.rb +16 -0
  100. data/lib/gs_graph/connections/photos.rb +21 -0
  101. data/lib/gs_graph/connections/picture.rb +39 -0
  102. data/lib/gs_graph/connections/pokes.rb +12 -0
  103. data/lib/gs_graph/connections/posts.rb +14 -0
  104. data/lib/gs_graph/connections/promotable_posts.rb +14 -0
  105. data/lib/gs_graph/connections/question_options.rb +14 -0
  106. data/lib/gs_graph/connections/questions.rb +22 -0
  107. data/lib/gs_graph/connections/reach_estimates.rb +12 -0
  108. data/lib/gs_graph/connections/roles.rb +36 -0
  109. data/lib/gs_graph/connections/scores.rb +22 -0
  110. data/lib/gs_graph/connections/senders.rb +14 -0
  111. data/lib/gs_graph/connections/settings.rb +65 -0
  112. data/lib/gs_graph/connections/statuses.rb +14 -0
  113. data/lib/gs_graph/connections/subscribed_to.rb +14 -0
  114. data/lib/gs_graph/connections/subscribers.rb +14 -0
  115. data/lib/gs_graph/connections/subscriptions.rb +53 -0
  116. data/lib/gs_graph/connections/tabs.rb +23 -0
  117. data/lib/gs_graph/connections/tagged.rb +14 -0
  118. data/lib/gs_graph/connections/tags.rb +23 -0
  119. data/lib/gs_graph/connections/television.rb +14 -0
  120. data/lib/gs_graph/connections/test_users.rb +19 -0
  121. data/lib/gs_graph/connections/threads.rb +14 -0
  122. data/lib/gs_graph/connections/user_achievements.rb +22 -0
  123. data/lib/gs_graph/connections/user_likes.rb +19 -0
  124. data/lib/gs_graph/connections/videos.rb +21 -0
  125. data/lib/gs_graph/connections/votes.rb +9 -0
  126. data/lib/gs_graph/cover.rb +10 -0
  127. data/lib/gs_graph/debugger.rb +28 -0
  128. data/lib/gs_graph/device.rb +11 -0
  129. data/lib/gs_graph/doc.rb +18 -0
  130. data/lib/gs_graph/domain.rb +32 -0
  131. data/lib/gs_graph/education.rb +32 -0
  132. data/lib/gs_graph/event.rb +52 -0
  133. data/lib/gs_graph/exception.rb +139 -0
  134. data/lib/gs_graph/friend_list.rb +13 -0
  135. data/lib/gs_graph/friend_request.rb +14 -0
  136. data/lib/gs_graph/group.rb +29 -0
  137. data/lib/gs_graph/image.rb +11 -0
  138. data/lib/gs_graph/insight.rb +13 -0
  139. data/lib/gs_graph/klass.rb +31 -0
  140. data/lib/gs_graph/link.rb +32 -0
  141. data/lib/gs_graph/location.rb +20 -0
  142. data/lib/gs_graph/message.rb +30 -0
  143. data/lib/gs_graph/milestone.rb +26 -0
  144. data/lib/gs_graph/node.rb +149 -0
  145. data/lib/gs_graph/note.rb +32 -0
  146. data/lib/gs_graph/notification.rb +32 -0
  147. data/lib/gs_graph/offer.rb +33 -0
  148. data/lib/gs_graph/open_graph.rb +3 -0
  149. data/lib/gs_graph/open_graph/action.rb +42 -0
  150. data/lib/gs_graph/open_graph/application_context.rb +10 -0
  151. data/lib/gs_graph/open_graph/object.rb +29 -0
  152. data/lib/gs_graph/open_graph/user_context.rb +21 -0
  153. data/lib/gs_graph/order.rb +55 -0
  154. data/lib/gs_graph/page.rb +57 -0
  155. data/lib/gs_graph/page/category_attributes.rb +117 -0
  156. data/lib/gs_graph/photo.rb +48 -0
  157. data/lib/gs_graph/picture.rb +14 -0
  158. data/lib/gs_graph/place.rb +7 -0
  159. data/lib/gs_graph/poke.rb +19 -0
  160. data/lib/gs_graph/post.rb +117 -0
  161. data/lib/gs_graph/privacy.rb +27 -0
  162. data/lib/gs_graph/project.rb +4 -0
  163. data/lib/gs_graph/promotable_post.rb +34 -0
  164. data/lib/gs_graph/property.rb +13 -0
  165. data/lib/gs_graph/query.rb +47 -0
  166. data/lib/gs_graph/question.rb +26 -0
  167. data/lib/gs_graph/question_option.rb +22 -0
  168. data/lib/gs_graph/reach_estimate.rb +22 -0
  169. data/lib/gs_graph/role.rb +13 -0
  170. data/lib/gs_graph/score.rb +16 -0
  171. data/lib/gs_graph/searchable.rb +33 -0
  172. data/lib/gs_graph/searchable/result.rb +31 -0
  173. data/lib/gs_graph/serialization.rb +19 -0
  174. data/lib/gs_graph/status.rb +27 -0
  175. data/lib/gs_graph/subscription.rb +14 -0
  176. data/lib/gs_graph/tab.rb +17 -0
  177. data/lib/gs_graph/tag.rb +30 -0
  178. data/lib/gs_graph/tagged_object.rb +23 -0
  179. data/lib/gs_graph/targeting.rb +23 -0
  180. data/lib/gs_graph/test_user.rb +24 -0
  181. data/lib/gs_graph/thread.rb +71 -0
  182. data/lib/gs_graph/user.rb +153 -0
  183. data/lib/gs_graph/user_achievement.rb +35 -0
  184. data/lib/gs_graph/venue.rb +14 -0
  185. data/lib/gs_graph/video.rb +41 -0
  186. data/lib/gs_graph/work.rb +48 -0
  187. data/lib/patch/rack/oauth2/access_token.rb +11 -0
  188. data/lib/patch/rack/oauth2/access_token/introspectable.rb +37 -0
  189. data/lib/patch/rack/oauth2/client.rb +13 -0
  190. data/lib/patch/rack/oauth2/grant/fb_exchange_token.rb +11 -0
  191. data/lib/patch/rack/oauth2/util.rb +14 -0
  192. data/spec/gs_graph/achievement_spec.rb +59 -0
  193. data/spec/gs_graph/ad_account_spec.rb +124 -0
  194. data/spec/gs_graph/ad_campaign_spec.rb +99 -0
  195. data/spec/gs_graph/ad_connection_object_spec.rb +71 -0
  196. data/spec/gs_graph/ad_creative_spec.rb +87 -0
  197. data/spec/gs_graph/ad_group_spec.rb +95 -0
  198. data/spec/gs_graph/ad_keyword_spec.rb +27 -0
  199. data/spec/gs_graph/ad_keyword_suggestion_spec.rb +17 -0
  200. data/spec/gs_graph/ad_keyword_valid_spec.rb +19 -0
  201. data/spec/gs_graph/ad_user_spec.rb +67 -0
  202. data/spec/gs_graph/album_spec.rb +93 -0
  203. data/spec/gs_graph/app_request_spec.rb +40 -0
  204. data/spec/gs_graph/application_spec.rb +251 -0
  205. data/spec/gs_graph/auth/cookie_spec.rb +29 -0
  206. data/spec/gs_graph/auth/signed_request_spec.rb +22 -0
  207. data/spec/gs_graph/auth_spec.rb +223 -0
  208. data/spec/gs_graph/broad_targeting_category_spec.rb +17 -0
  209. data/spec/gs_graph/checkin_spec.rb +42 -0
  210. data/spec/gs_graph/collection_spec.rb +50 -0
  211. data/spec/gs_graph/comment_spec.rb +31 -0
  212. data/spec/gs_graph/connection_spec.rb +42 -0
  213. data/spec/gs_graph/connections/accounts_spec.rb +78 -0
  214. data/spec/gs_graph/connections/achievements_spec.rb +27 -0
  215. data/spec/gs_graph/connections/activities_spec.rb +34 -0
  216. data/spec/gs_graph/connections/ad_accounts_spec.rb +28 -0
  217. data/spec/gs_graph/connections/ad_campaign_stat_spec.rb +35 -0
  218. data/spec/gs_graph/connections/ad_campaigns_spec.rb +36 -0
  219. data/spec/gs_graph/connections/ad_connection_objects_spec.rb +20 -0
  220. data/spec/gs_graph/connections/ad_creatives_spec.rb +29 -0
  221. data/spec/gs_graph/connections/ad_group_stat_spec.rb +54 -0
  222. data/spec/gs_graph/connections/ad_groups_spec.rb +92 -0
  223. data/spec/gs_graph/connections/ad_previews_spec.rb +18 -0
  224. data/spec/gs_graph/connections/admins_spec.rb +20 -0
  225. data/spec/gs_graph/connections/albums_spec.rb +63 -0
  226. data/spec/gs_graph/connections/app_notifications_spec.rb +23 -0
  227. data/spec/gs_graph/connections/app_requests_spec.rb +28 -0
  228. data/spec/gs_graph/connections/attending_spec.rb +47 -0
  229. data/spec/gs_graph/connections/banned_spec.rb +63 -0
  230. data/spec/gs_graph/connections/blocked_spec.rb +56 -0
  231. data/spec/gs_graph/connections/books_spec.rb +32 -0
  232. data/spec/gs_graph/connections/broad_targeting_categories_spec.rb +18 -0
  233. data/spec/gs_graph/connections/checkins_spec.rb +153 -0
  234. data/spec/gs_graph/connections/comments_spec.rb +75 -0
  235. data/spec/gs_graph/connections/conversations_spec.rb +19 -0
  236. data/spec/gs_graph/connections/declined_spec.rb +47 -0
  237. data/spec/gs_graph/connections/docs_spec.rb +14 -0
  238. data/spec/gs_graph/connections/events_spec.rb +52 -0
  239. data/spec/gs_graph/connections/family_spec.rb +32 -0
  240. data/spec/gs_graph/connections/feed_spec.rb +124 -0
  241. data/spec/gs_graph/connections/former_participants_spec.rb +44 -0
  242. data/spec/gs_graph/connections/friend_lists_spec.rb +26 -0
  243. data/spec/gs_graph/connections/friend_requests_spec.rb +16 -0
  244. data/spec/gs_graph/connections/friends_spec.rb +51 -0
  245. data/spec/gs_graph/connections/games_spec.rb +20 -0
  246. data/spec/gs_graph/connections/groups_spec.rb +31 -0
  247. data/spec/gs_graph/connections/home_spec.rb +62 -0
  248. data/spec/gs_graph/connections/inbox_spec.rb +16 -0
  249. data/spec/gs_graph/connections/insights_spec.rb +104 -0
  250. data/spec/gs_graph/connections/interests_spec.rb +12 -0
  251. data/spec/gs_graph/connections/invited_spec.rb +84 -0
  252. data/spec/gs_graph/connections/likes_spec.rb +127 -0
  253. data/spec/gs_graph/connections/links_spec.rb +31 -0
  254. data/spec/gs_graph/connections/maybe_spec.rb +47 -0
  255. data/spec/gs_graph/connections/members_spec.rb +57 -0
  256. data/spec/gs_graph/connections/messages_spec.rb +58 -0
  257. data/spec/gs_graph/connections/milestones_spec.rb +40 -0
  258. data/spec/gs_graph/connections/movies_spec.rb +12 -0
  259. data/spec/gs_graph/connections/music_spec.rb +12 -0
  260. data/spec/gs_graph/connections/mutual_friends_spec.rb +28 -0
  261. data/spec/gs_graph/connections/noreply_spec.rb +39 -0
  262. data/spec/gs_graph/connections/notes_spec.rb +31 -0
  263. data/spec/gs_graph/connections/notifications_spec.rb +30 -0
  264. data/spec/gs_graph/connections/outbox_spec.rb +16 -0
  265. data/spec/gs_graph/connections/participants_spec.rb +42 -0
  266. data/spec/gs_graph/connections/payments_spec.rb +17 -0
  267. data/spec/gs_graph/connections/permissions_spec.rb +44 -0
  268. data/spec/gs_graph/connections/photos_spec.rb +39 -0
  269. data/spec/gs_graph/connections/picture_spec.rb +92 -0
  270. data/spec/gs_graph/connections/pokes_spec.rb +16 -0
  271. data/spec/gs_graph/connections/posts_spec.rb +34 -0
  272. data/spec/gs_graph/connections/promotable_posts_spec.rb +24 -0
  273. data/spec/gs_graph/connections/question_options_spec.rb +14 -0
  274. data/spec/gs_graph/connections/questions_spec.rb +31 -0
  275. data/spec/gs_graph/connections/reach_estimates_spec.rb +18 -0
  276. data/spec/gs_graph/connections/roles_spec.rb +59 -0
  277. data/spec/gs_graph/connections/scores_spec.rb +40 -0
  278. data/spec/gs_graph/connections/senders_spec.rb +42 -0
  279. data/spec/gs_graph/connections/settings_spec.rb +62 -0
  280. data/spec/gs_graph/connections/statuses_spec.rb +72 -0
  281. data/spec/gs_graph/connections/subscribed_to_spec.rb +12 -0
  282. data/spec/gs_graph/connections/subscribers_spec.rb +12 -0
  283. data/spec/gs_graph/connections/subscriptions_spec.rb +47 -0
  284. data/spec/gs_graph/connections/tabs_spec.rb +47 -0
  285. data/spec/gs_graph/connections/tagged_spec.rb +42 -0
  286. data/spec/gs_graph/connections/tags_spec.rb +30 -0
  287. data/spec/gs_graph/connections/television_spec.rb +12 -0
  288. data/spec/gs_graph/connections/test_users_spec.rb +65 -0
  289. data/spec/gs_graph/connections/threads_spec.rb +12 -0
  290. data/spec/gs_graph/connections/user_achievements_spec.rb +37 -0
  291. data/spec/gs_graph/connections/user_likes_spec.rb +55 -0
  292. data/spec/gs_graph/connections/videos_spec.rb +27 -0
  293. data/spec/gs_graph/connections/votes_spec.rb +15 -0
  294. data/spec/gs_graph/debugger_spec.rb +33 -0
  295. data/spec/gs_graph/doc_spec.rb +27 -0
  296. data/spec/gs_graph/domain_spec.rb +23 -0
  297. data/spec/gs_graph/education_spec.rb +61 -0
  298. data/spec/gs_graph/event_spec.rb +70 -0
  299. data/spec/gs_graph/exception_spec.rb +310 -0
  300. data/spec/gs_graph/friend_list_spec.rb +22 -0
  301. data/spec/gs_graph/group_spec.rb +28 -0
  302. data/spec/gs_graph/image_spec.rb +16 -0
  303. data/spec/gs_graph/insight_spec.rb +18 -0
  304. data/spec/gs_graph/link_spec.rb +41 -0
  305. data/spec/gs_graph/location_spec.rb +28 -0
  306. data/spec/gs_graph/message_spec.rb +47 -0
  307. data/spec/gs_graph/node_spec.rb +91 -0
  308. data/spec/gs_graph/note_spec.rb +37 -0
  309. data/spec/gs_graph/notification_spec.rb +59 -0
  310. data/spec/gs_graph/offer_spec.rb +30 -0
  311. data/spec/gs_graph/open_graph/action_spec.rb +112 -0
  312. data/spec/gs_graph/open_graph/application_context_spec.rb +28 -0
  313. data/spec/gs_graph/open_graph/object_spec.rb +76 -0
  314. data/spec/gs_graph/open_graph/user_context_spec.rb +33 -0
  315. data/spec/gs_graph/order_spec.rb +66 -0
  316. data/spec/gs_graph/page/local_business_spec.rb +88 -0
  317. data/spec/gs_graph/page/movie_spec.rb +25 -0
  318. data/spec/gs_graph/page/music_spec.rb +25 -0
  319. data/spec/gs_graph/page/person_spec.rb +23 -0
  320. data/spec/gs_graph/page/product_spec.rb +36 -0
  321. data/spec/gs_graph/page_spec.rb +81 -0
  322. data/spec/gs_graph/photo_spec.rb +85 -0
  323. data/spec/gs_graph/place_spec.rb +8 -0
  324. data/spec/gs_graph/post_spec.rb +238 -0
  325. data/spec/gs_graph/privacy_spec.rb +33 -0
  326. data/spec/gs_graph/project_spec.rb +46 -0
  327. data/spec/gs_graph/promotable_post_spec.rb +57 -0
  328. data/spec/gs_graph/qeustion_option_spec.rb +35 -0
  329. data/spec/gs_graph/query_spec.rb +73 -0
  330. data/spec/gs_graph/question_spec.rb +73 -0
  331. data/spec/gs_graph/reach_estimate_spec.rb +48 -0
  332. data/spec/gs_graph/searchable_spec.rb +47 -0
  333. data/spec/gs_graph/seriarization_spec.rb +29 -0
  334. data/spec/gs_graph/status_spec.rb +31 -0
  335. data/spec/gs_graph/subscription_spec.rb +5 -0
  336. data/spec/gs_graph/tag_spec.rb +34 -0
  337. data/spec/gs_graph/tagged_object_spec.rb +45 -0
  338. data/spec/gs_graph/targeting_spec.rb +34 -0
  339. data/spec/gs_graph/test_user_spec.rb +50 -0
  340. data/spec/gs_graph/thread_spec.rb +86 -0
  341. data/spec/gs_graph/user_achievement_spec.rb +53 -0
  342. data/spec/gs_graph/user_spec.rb +185 -0
  343. data/spec/gs_graph/venue_spec.rb +23 -0
  344. data/spec/gs_graph/video_spec.rb +31 -0
  345. data/spec/gs_graph/work_spec.rb +101 -0
  346. data/spec/gs_graph_spec.rb +57 -0
  347. data/spec/spec_helper.rb +9 -0
  348. metadata +538 -0
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe GSGraph::Connections::Interests, '#interests' do
4
+ it 'should return interests pages as GSGraph::Page' do
5
+ mock_graph :get, 'matake/interests', 'users/interests/matake_private', :access_token => 'access_token' do
6
+ pages = GSGraph::User.new('matake', :access_token => 'access_token').interests
7
+ pages.each do |page|
8
+ page.should be_instance_of(GSGraph::Page)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,84 @@
1
+ require 'spec_helper'
2
+
3
+ describe GSGraph::Connections::Invited do
4
+ let(:event) { GSGraph::Event.new('smartday', :access_token => 'access_token') }
5
+
6
+ describe '#invited' do
7
+ it 'should return invited users as GSGraph::User' do
8
+ mock_graph :get, 'smartday/invited', 'events/invited/smartday_private', :access_token => 'access_token' do
9
+ event.invited.each do |user|
10
+ user.should be_instance_of(GSGraph::User)
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ describe '#invited?' do
17
+ context 'when invited' do
18
+ it 'should return RSVP status' do
19
+ mock_graph :get, 'smartday/invited/1575327134', 'events/invited/not_replied', :access_token => 'access_token' do
20
+ event.invited?(
21
+ GSGraph::User.new('1575327134')
22
+ ).should == :not_replied
23
+ end
24
+ end
25
+ end
26
+
27
+ context 'otherwise' do
28
+ it 'should return false' do
29
+ mock_graph :get, 'smartday/invited/12345', 'empty', :access_token => 'access_token' do
30
+ event.invited?(
31
+ GSGraph::User.new('12345')
32
+ ).should be_false
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ describe '#invite!' do
39
+ context 'when options[:users] option is given' do
40
+ it 'should use it' do
41
+ mock_graph :post, 'smartday/invited', 'true', :access_token => 'access_token', :params => {
42
+ :users => "uid1,uid2"
43
+ } do
44
+ event.invite!(:users => "uid1,uid2").should be_true
45
+ end
46
+ end
47
+ end
48
+
49
+ context 'otherwise' do
50
+ context 'when single user is given' do
51
+ it 'should invite him/her' do
52
+ mock_graph :post, 'smartday/invited', 'true', :access_token => 'access_token', :params => {
53
+ :users => "uid1"
54
+ } do
55
+ event.invite!(
56
+ GSGraph::User.new("uid1")
57
+ ).should be_true
58
+ end
59
+ end
60
+ end
61
+
62
+ context 'when an Array of users are given' do
63
+ it 'should invite all of them' do
64
+ mock_graph :post, 'smartday/invited', 'true', :access_token => 'access_token', :params => {
65
+ :users => "uid1,uid2"
66
+ } do
67
+ event.invite!(
68
+ GSGraph::User.new("uid1"),
69
+ GSGraph::User.new("uid2")
70
+ ).should be_true
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+
77
+ describe '#uninvite!' do
78
+ it 'should return true' do
79
+ mock_graph :delete, 'smartday/invited/uid', 'true', :access_token => 'access_token' do
80
+ event.uninvite!(GSGraph::User.new("uid")).should be_true
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,127 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe GSGraph::Connections::Likes do
5
+ describe '#likes' do
6
+ context 'when liked by a Page' do
7
+ it 'should handle the liker as a Page' do
8
+ mock_graph :get, 'post_id', 'posts/liked_by_page', :access_token => 'access_token' do
9
+ post = GSGraph::Post.new('post_id').fetch(:access_token => 'access_token')
10
+ post.likes.first.should be_instance_of GSGraph::Page
11
+ end
12
+ end
13
+ end
14
+
15
+ context 'when included by GSGraph::Post' do
16
+ let(:post) { GSGraph::Post.new('post_id', :access_token => 'access_token', :likes => {}) }
17
+
18
+ describe 'cached likes' do
19
+ context 'when cached' do
20
+ it 'should use cache' do
21
+ lambda do
22
+ post.likes
23
+ end.should_not request_to 'post_id/likes?access_token=access_token'
24
+ end
25
+
26
+ context 'when options are specified' do
27
+ it 'should not use cache' do
28
+ lambda do
29
+ post.likes(:no_cache => true)
30
+ end.should request_to 'post_id/likes?access_token=access_token&no_cache=true'
31
+ end
32
+ end
33
+ end
34
+
35
+ context 'otherwise' do
36
+ let(:post) { GSGraph::Post.new(12345, :access_token => 'access_token') }
37
+
38
+ it 'should not use cache' do
39
+ lambda do
40
+ post.likes
41
+ end.should request_to '12345/likes?access_token=access_token'
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ context 'when included by GSGraph::Status' do
48
+ context 'when cached collection exists' do
49
+ before do
50
+ mock_graph :get, 'with_likes', 'statuses/with_likes', :access_token => 'access_token' do
51
+ @status = GSGraph::Status.new('with_likes').fetch(:access_token => 'access_token')
52
+ end
53
+ end
54
+
55
+ context 'when no options given' do
56
+ it 'should not access to Graph API' do
57
+ @status.likes.should == [GSGraph::User.new(
58
+ '604578140',
59
+ :access_token => 'access_token',
60
+ :name => 'K Hiromi'
61
+ )]
62
+ @status.likes.next.should == []
63
+ @status.likes.previous.should == []
64
+ end
65
+ end
66
+
67
+ context 'when any options given' do
68
+ it 'should access to Graph API' do
69
+ lambda do
70
+ @status.likes(:no_cache => true) # :no_cache has no meaning, just putting some value as options
71
+ end.should request_to('115838235152172/likes?access_token=access_token&no_cache=true')
72
+ lambda do
73
+ @status.likes(:limit => 10)
74
+ end.should request_to('115838235152172/likes?access_token=access_token&limit=10')
75
+ end
76
+
77
+ context 'when next/previous are obviously blank' do
78
+ it 'should not access to Graph API' do
79
+ @status.likes.next(:no_cache => true).should == []
80
+ @status.likes.previous(:no_cache => true).should == []
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ describe '#like!' do
89
+ context 'when included by GSGraph::Post' do
90
+ context 'when no access_token given' do
91
+ it 'should raise GSGraph::Exception' do
92
+ mock_graph :post, '12345/likes', 'posts/likes/post_without_access_token', :status => [500, 'Internal Server Error'] do
93
+ lambda do
94
+ GSGraph::Post.new('12345').like!
95
+ end.should raise_exception(GSGraph::Exception)
96
+ end
97
+ end
98
+ end
99
+
100
+ context 'when invalid access_token is given' do
101
+ it 'should raise GSGraph::Exception' do
102
+ mock_graph :post, '12345/likes', 'posts/likes/post_with_invalid_access_token', :status => [500, 'Internal Server Error'] do
103
+ lambda do
104
+ GSGraph::Post.new('12345', :access_token => 'invalid').like!
105
+ end.should raise_exception(GSGraph::Exception)
106
+ end
107
+ end
108
+ end
109
+
110
+ context 'when valid access_token is given' do
111
+ it 'should return true' do
112
+ mock_graph :post, '12345/likes', 'posts/likes/post_with_valid_access_token' do
113
+ GSGraph::Post.new('12345', :access_token => 'valid').like!.should be_true
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
119
+
120
+ describe '#unlike!' do
121
+ it 'should DELETE /:object_id/likes' do
122
+ mock_graph :delete, '12345/likes', 'true', :access_token => 'valid' do
123
+ GSGraph::Post.new('12345', :access_token => 'valid').unlike!
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe GSGraph::Connections::Links, '#links' do
4
+ context 'when included by GSGraph::User' do
5
+ it 'should return notes as GSGraph::Link' do
6
+ mock_graph :get, 'matake/links', 'users/links/matake_private', :access_token => 'access_token' do
7
+ links = GSGraph::User.new('matake', :access_token => 'access_token').links
8
+ links.each do |link|
9
+ link.should be_instance_of(GSGraph::Link)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ describe GSGraph::Connections::Links, '#link!' do
17
+ context 'when included by GSGraph::User' do
18
+ it 'should return generated link' do
19
+ mock_graph :post, 'matake/links', 'users/links/post_with_valid_access_token' do
20
+ link = GSGraph::User.new('matake', :access_token => 'valid').link!(
21
+ :link => 'http://github.com/nov/gs_graph',
22
+ :message => 'A Ruby wrapper for Facebook Graph API.'
23
+ )
24
+ link.identifier.should == 120765121284251
25
+ link.link.should == 'http://github.com/nov/gs_graph'
26
+ link.message.should == 'A Ruby wrapper for Facebook Graph API.'
27
+ link.access_token.should == 'valid'
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe GSGraph::Connections::Maybe do
4
+ let(:event) do
5
+ GSGraph::Event.new('smartday', :access_token => 'access_token')
6
+ end
7
+
8
+ describe '#maybe' do
9
+ it 'should return maybe users as GSGraph::User' do
10
+ mock_graph :get, 'smartday/maybe', 'events/maybe/smartday_private', :access_token => 'access_token' do
11
+ event.maybe.each do |user|
12
+ user.should be_instance_of(GSGraph::User)
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ describe '#maybe?' do
19
+ context 'when maybe' do
20
+ it 'should return true' do
21
+ mock_graph :get, 'smartday/maybe/uid', 'events/invited/unsure', :access_token => 'access_token' do
22
+ event.maybe?(
23
+ GSGraph::User.new('uid')
24
+ ).should be_true
25
+ end
26
+ end
27
+ end
28
+
29
+ context 'otherwise' do
30
+ it 'should return false' do
31
+ mock_graph :get, 'smartday/maybe/uid', 'empty', :access_token => 'access_token' do
32
+ event.maybe?(
33
+ GSGraph::User.new('uid')
34
+ ).should be_false
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ describe '#maybe!' do
41
+ it 'should return true' do
42
+ mock_graph :post, 'smartday/maybe', 'events/maybe/post_with_valid_access_token' do
43
+ event.maybe!.should be_true
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe GSGraph::Connections::Members do
4
+ let :member do
5
+ GSGraph::User.new('member_id')
6
+ end
7
+
8
+ context 'when included in GSGraph::Group' do
9
+ describe '#members' do
10
+ it 'should return members as GSGraph::User' do
11
+ mock_graph :get, 'emacs/members', 'groups/members/emacs_private', :access_token => 'access_token' do
12
+ users = GSGraph::Group.new('emacs', :access_token => 'access_token').members
13
+ users.each do |user|
14
+ user.should be_instance_of GSGraph::User
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ describe '#member!' do
21
+ it :NOT_SUPPORTED_YET
22
+ end
23
+
24
+ describe '#unmember!' do
25
+ it :NOT_SUPPORTED_YET
26
+ end
27
+ end
28
+
29
+ context 'when included in GSGraph::FriendList' do
30
+ describe '#members' do
31
+ it 'should return members as GSGraph::User' do
32
+ mock_graph :get, 'list_id/members', 'friend_lists/members/sample', :access_token => 'access_token' do
33
+ users = GSGraph::FriendList.new('list_id', :access_token => 'access_token').members
34
+ users.each do |user|
35
+ user.should be_instance_of GSGraph::User
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ describe '#member!' do
42
+ it 'should return true' do
43
+ mock_graph :post, 'list_id/members/member_id', 'true', :access_token => 'access_token' do
44
+ GSGraph::FriendList.new('list_id', :access_token => 'access_token').member!(member).should be_true
45
+ end
46
+ end
47
+ end
48
+
49
+ describe '#unmember!' do
50
+ it 'should return true' do
51
+ mock_graph :delete, 'list_id/members/member_id', 'true', :access_token => 'access_token' do
52
+ GSGraph::FriendList.new('list_id', :access_token => 'access_token').unmember!(member).should be_true
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ describe GSGraph::Connections::Messages do
4
+ describe '#messages' do
5
+ it 'should return threads as GSGraph::Message' do
6
+ mock_graph :get, '12345/messages', 'thread/messages/private', :params => {:no_cache => 'true'}, :access_token => 'access_token' do
7
+ messages = GSGraph::Thread.new(12345, :access_token => 'access_token').messages(:no_cache => true)
8
+ messages.each do |message|
9
+ message.should be_instance_of(GSGraph::Message)
10
+ end
11
+ end
12
+ end
13
+
14
+ describe 'cached messages' do
15
+ context 'when cached' do
16
+ let(:thread) { GSGraph::Thread.new(12345, :access_token => 'access_token', :messages => {}) }
17
+
18
+ it 'should use cache' do
19
+ lambda do
20
+ thread.messages
21
+ end.should_not request_to '12345/messages?access_token=access_token'
22
+ end
23
+
24
+ context 'when options are specified' do
25
+ it 'should not use cache' do
26
+ lambda do
27
+ thread.messages(:no_cache => true)
28
+ end.should request_to '12345/messages?access_token=access_token&no_cache=true'
29
+ end
30
+ end
31
+ end
32
+
33
+ context 'otherwise' do
34
+ let(:thread) { GSGraph::Thread.new(12345, :access_token => 'access_token') }
35
+
36
+ it 'should not use cache' do
37
+ lambda do
38
+ thread.messages
39
+ end.should request_to '12345/messages?access_token=access_token'
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ describe '#message!' do
46
+ let(:thread) { GSGraph::Thread.new(12345, :access_token => 'access_token') }
47
+
48
+ it 'should return GSGraph::Message' do
49
+ mock_graph :post, '12345/messages', 'thread/messages/created', :access_token => 'access_token', :params => {
50
+ :message => 'Hello'
51
+ } do
52
+ message = thread.message! 'Hello'
53
+ message.should be_instance_of GSGraph::Message
54
+ message.message.should == 'Hello'
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe GSGraph::Connections::Milestones do
4
+ let(:page) do
5
+ GSGraph::Page.new('page_id', :access_token => 'page_token')
6
+ end
7
+
8
+ describe '#milestones' do
9
+ it 'should return an Array of GSGraph::Milestone' do
10
+ mock_graph :get, 'page_id/milestones', 'pages/milestones/list', :access_token => 'page_token' do
11
+ milestones = page.milestones
12
+ milestones.should be_instance_of GSGraph::Connection
13
+ milestones.each do |milestone|
14
+ milestone.should be_instance_of GSGraph::Milestone
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ describe '#milestone!' do
21
+ it 'should return generated milestone' do
22
+ started_at = 3.years.ago
23
+ mock_graph :post, 'page_id/milestones', 'pages/milestones/created', :access_token => 'page_token', :params => {
24
+ :title => 'Reached 1M users!',
25
+ :description => 'Finally we got 1M-th user!',
26
+ :start_time => started_at.to_s
27
+ } do
28
+ milestone = page.milestone!(
29
+ :title => 'Reached 1M users!',
30
+ :description => 'Finally we got 1M-th user!',
31
+ :start_time => started_at
32
+ )
33
+ milestone.should be_instance_of GSGraph::Milestone
34
+ milestone.title.should == 'Reached 1M users!'
35
+ milestone.description.should == 'Finally we got 1M-th user!'
36
+ milestone.start_time.should == started_at
37
+ end
38
+ end
39
+ end
40
+ end