fb_graph2 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/fb_graph2/auth.rb +1 -1
- data/lib/fb_graph2/collection.rb +2 -3
- data/spec/fb_graph2/{application_spec.rb → app_spec.rb} +1 -1
- data/spec/fb_graph2/auth_spec.rb +38 -0
- data/spec/fb_graph2/node_spec.rb +4 -4
- data/spec/fb_graph2/page_spec.rb +61 -0
- data/spec/mock_json/error/400/191.json +7 -0
- data/spec/mock_json/page/blocked.json +5 -7
- data/spec/mock_json/page/with_optional_fields.json +42 -0
- data/spec/mock_json/token_response.json +1 -0
- data/spec/mock_json/user/notifications.json +20 -86
- data/spec/spec_helper/mock_graph.rb +2 -2
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7000a466f8c2cf12f0fca401eb5fdd1651745392
|
4
|
+
data.tar.gz: 4cc82ba45ae78798767f6f2191e5d9496d790442
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd8d385375e635ee8655d78e60dcfb1f1722765f4296b110a7257d6180ffde0a87ae5bd43c445738524885e84e38f16068c76ad707ab1b21088960d5063bec34
|
7
|
+
data.tar.gz: a942c1adad9ecf5b3c29713e61a43805fa82d59060609e6a42aa7d878b302af5423a924ddd105cf8b137ad9e7175af1464e281b79d4e6f2681003e0596b93f2b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/fb_graph2/auth.rb
CHANGED
data/lib/fb_graph2/collection.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module FbGraph2
|
2
2
|
class Collection < Array
|
3
|
-
attr_accessor :before, :after, :next, :previous, :order, :total_count
|
3
|
+
attr_accessor :before, :after, :next, :previous, :order, :total_count, :summary
|
4
4
|
|
5
5
|
def initialize(collection = [])
|
6
6
|
collection = normalize collection
|
@@ -34,8 +34,7 @@ module FbGraph2
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def summarize(summary)
|
37
|
-
|
38
|
-
summary = Hash(summary)
|
37
|
+
self.summary = summary
|
39
38
|
self.order = summary.try(:[], :order)
|
40
39
|
self.total_count = summary.try(:[], :total_count)
|
41
40
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FbGraph2::Auth do
|
4
|
+
describe '.app' do
|
5
|
+
subject { instance }
|
6
|
+
let(:instance) { FbGraph2::Auth.new 'client_id', 'client_secret' }
|
7
|
+
|
8
|
+
it { should be_a Rack::OAuth2::Client }
|
9
|
+
|
10
|
+
describe 'fb_exchange_token grant' do
|
11
|
+
it do
|
12
|
+
instance.fb_exchange_token = 'short_lived_access_token'
|
13
|
+
access_token = mock_graph :post, 'oauth/access_token', 'token_response', params: {
|
14
|
+
grant_type: 'fb_exchange_token',
|
15
|
+
fb_exchange_token: 'short_lived_access_token',
|
16
|
+
client_id: 'client_id',
|
17
|
+
client_secret: 'client_secret'
|
18
|
+
}, disable_api_versioning: true do
|
19
|
+
instance.access_token!
|
20
|
+
end
|
21
|
+
access_token.should be_instance_of Rack::OAuth2::AccessToken::Legacy
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when error occured' do
|
26
|
+
it do
|
27
|
+
expect do
|
28
|
+
mock_graph :post, 'oauth/access_token', 'error/400/191', status: [400, 'Bad Request'], disable_api_versioning: true do
|
29
|
+
instance.authorization_code = 'auth_code'
|
30
|
+
instance.access_token!
|
31
|
+
end
|
32
|
+
end.to raise_error(FbGraph2::Exception) do |e|
|
33
|
+
e.message.should == 'Missing redirect_uri parameter.'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/fb_graph2/node_spec.rb
CHANGED
@@ -22,7 +22,7 @@ describe FbGraph2::Node do
|
|
22
22
|
it 'should use api_version globally' do
|
23
23
|
expect do
|
24
24
|
instance.fetch
|
25
|
-
end.to request_to 'v2.x/identifier', :get,
|
25
|
+
end.to request_to 'v2.x/identifier', :get, disable_api_versioning: true
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -30,7 +30,7 @@ describe FbGraph2::Node do
|
|
30
30
|
it 'should use api_version globally' do
|
31
31
|
expect do
|
32
32
|
instance.edge :foo
|
33
|
-
end.to request_to 'v2.x/identifier/foo', :get,
|
33
|
+
end.to request_to 'v2.x/identifier/foo', :get, disable_api_versioning: true
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -40,7 +40,7 @@ describe FbGraph2::Node do
|
|
40
40
|
it 'should use api_version locally' do
|
41
41
|
expect do
|
42
42
|
instance.fetch nil, api_version: 'v2.y'
|
43
|
-
end.to request_to 'v2.y/identifier', :get,
|
43
|
+
end.to request_to 'v2.y/identifier', :get, disable_api_versioning: true
|
44
44
|
FbGraph2.api_version.should == @original
|
45
45
|
end
|
46
46
|
end
|
@@ -49,7 +49,7 @@ describe FbGraph2::Node do
|
|
49
49
|
it 'should use api_version locally' do
|
50
50
|
expect do
|
51
51
|
instance.edge :foo, {}, api_version: 'v2.y'
|
52
|
-
end.to request_to 'v2.y/identifier/foo', :get,
|
52
|
+
end.to request_to 'v2.y/identifier/foo', :get, disable_api_versioning: true
|
53
53
|
FbGraph2.api_version.should == @original
|
54
54
|
end
|
55
55
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FbGraph2::Page do
|
4
|
+
context 'with optional fields' do
|
5
|
+
subject { page }
|
6
|
+
let(:page) do
|
7
|
+
attributes = mock_json 'page/with_optional_fields'
|
8
|
+
FbGraph2::Page.new attributes[:id], attributes
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#context' do
|
12
|
+
subject { page.context }
|
13
|
+
it { should be_instance_of FbGraph2::Struct::Context::PageContext }
|
14
|
+
|
15
|
+
describe 'friends_who_like' do
|
16
|
+
subject { page.context.friends_who_like }
|
17
|
+
it { should be_instance_of FbGraph2::Collection }
|
18
|
+
it { should be_blank }
|
19
|
+
its(:total_count) { should == 14 }
|
20
|
+
its(:summary) { should include :social_sentence }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#parking' do
|
25
|
+
subject { page.parking }
|
26
|
+
[:street, :lot, :valet].each do |key|
|
27
|
+
its(key) { should == false }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#restaurant_services' do
|
32
|
+
subject { page.restaurant_services }
|
33
|
+
[:kids, :delivery, :catering, :waiter, :outdoor, :takeout].each do |key|
|
34
|
+
its(key) { should == false }
|
35
|
+
end
|
36
|
+
[:groups, :reserve, :walkins].each do |key|
|
37
|
+
its(key) { should == true }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#restaurant_specialties' do
|
42
|
+
subject { page.restaurant_specialties }
|
43
|
+
[:coffee, :drinks, :breakfast, :lunch].each do |key|
|
44
|
+
its(key) { should == false }
|
45
|
+
end
|
46
|
+
[:dinner].each do |key|
|
47
|
+
its(key) { should == true }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#payment_options' do
|
52
|
+
subject { page.payment_options }
|
53
|
+
[:cash_only, :discover].each do |key|
|
54
|
+
its(key) { should == false }
|
55
|
+
end
|
56
|
+
[:amex, :mastercard, :visa].each do |key|
|
57
|
+
its(key) { should == true }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -1,11 +1,9 @@
|
|
1
1
|
{
|
2
|
-
"data": [
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
}
|
7
|
-
],
|
2
|
+
"data": [{
|
3
|
+
"name": "Jr Nov",
|
4
|
+
"id": "1575327134"
|
5
|
+
}],
|
8
6
|
"paging": {
|
9
7
|
"next": "https://graph.facebook.com/v2.0/117513961602338/blocked?limit=5000&offset=5000&__after_id=enc_AewU3hSo5zqbS5KA0i0lJYmPrLn57SMSo645aYB7BTPg1PSawPvlM9mRI_3Y_dcpeDI"
|
10
8
|
}
|
11
|
-
}
|
9
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
{
|
2
|
+
"context": {
|
3
|
+
"friends_who_like": {
|
4
|
+
"data": [],
|
5
|
+
"summary": {
|
6
|
+
"social_sentence": "14 of your friends like this.",
|
7
|
+
"total_count": 14
|
8
|
+
}
|
9
|
+
}
|
10
|
+
},
|
11
|
+
"parking": {
|
12
|
+
"lot": 0,
|
13
|
+
"street": 0,
|
14
|
+
"valet": 0
|
15
|
+
},
|
16
|
+
"restaurant_services": {
|
17
|
+
"delivery": 0,
|
18
|
+
"catering": 0,
|
19
|
+
"groups": 1,
|
20
|
+
"kids": 0,
|
21
|
+
"outdoor": 0,
|
22
|
+
"reserve": 1,
|
23
|
+
"takeout": 0,
|
24
|
+
"waiter": 0,
|
25
|
+
"walkins": 1
|
26
|
+
},
|
27
|
+
"restaurant_specialties": {
|
28
|
+
"breakfast": 0,
|
29
|
+
"coffee": 0,
|
30
|
+
"dinner": 1,
|
31
|
+
"drinks": 0,
|
32
|
+
"lunch": 0
|
33
|
+
},
|
34
|
+
"payment_options": {
|
35
|
+
"amex": 1,
|
36
|
+
"cash_only": 0,
|
37
|
+
"discover": 0,
|
38
|
+
"mastercard": 1,
|
39
|
+
"visa": 1
|
40
|
+
},
|
41
|
+
"id": "139296106095829"
|
42
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
access_token=access_token&expires=5183975
|
@@ -1,111 +1,45 @@
|
|
1
1
|
{
|
2
2
|
"data": [{
|
3
|
-
"id": "
|
3
|
+
"id": "notif_579612276_373456430",
|
4
4
|
"from": {
|
5
|
-
"id": "
|
6
|
-
"name": "
|
5
|
+
"id": "583017165143721",
|
6
|
+
"name": "Akira Otaishi"
|
7
7
|
},
|
8
8
|
"to": {
|
9
9
|
"id": "579612276",
|
10
10
|
"name": "Nov Matake"
|
11
11
|
},
|
12
|
-
"created_time": "2014-
|
13
|
-
"updated_time": "2014-
|
14
|
-
"title": "
|
15
|
-
"link": "http://www.facebook.com/
|
12
|
+
"created_time": "2014-08-27T18:48:07+0000",
|
13
|
+
"updated_time": "2014-08-27T18:48:07+0000",
|
14
|
+
"title": "Akira Otaishi invited you to his event あんしんかんcafe vol.4 ~ネット選挙をめぐるビジネス&セキュリティ~.",
|
15
|
+
"link": "http://www.facebook.com/events/339815099528481/",
|
16
16
|
"application": {
|
17
|
-
"name": "
|
18
|
-
"id": "
|
19
|
-
},
|
20
|
-
"unread": 1,
|
21
|
-
"object": {
|
22
|
-
"name": "クロサカさんの仕事部屋",
|
23
|
-
"id": "597190250369020"
|
24
|
-
}
|
25
|
-
}, {
|
26
|
-
"id": "notif_579612276_360668511",
|
27
|
-
"from": {
|
28
|
-
"id": "824378870925480",
|
29
|
-
"name": "ちゃちゃき まさゆき"
|
30
|
-
},
|
31
|
-
"to": {
|
32
|
-
"id": "579612276",
|
33
|
-
"name": "Nov Matake"
|
34
|
-
},
|
35
|
-
"created_time": "2014-06-02T14:57:39+0000",
|
36
|
-
"updated_time": "2014-06-02T14:57:39+0000",
|
37
|
-
"title": "ちゃちゃき まさゆき posted in DevLOVE Park: \"こんにちは。..\"",
|
38
|
-
"link": "http://www.facebook.com/groups/devlovepark/763062600400231/",
|
39
|
-
"application": {
|
40
|
-
"name": "Groups",
|
41
|
-
"id": "2361831622"
|
17
|
+
"name": "Events",
|
18
|
+
"id": "141157392619610"
|
42
19
|
},
|
43
20
|
"unread": 1
|
44
21
|
}, {
|
45
|
-
"id": "
|
22
|
+
"id": "notif_579612276_373364015",
|
46
23
|
"from": {
|
47
|
-
"id": "
|
48
|
-
"name": "
|
24
|
+
"id": "631020523647805",
|
25
|
+
"name": "Shota Kawaminami"
|
49
26
|
},
|
50
27
|
"to": {
|
51
28
|
"id": "579612276",
|
52
29
|
"name": "Nov Matake"
|
53
30
|
},
|
54
|
-
"created_time": "2014-
|
55
|
-
"updated_time": "2014-
|
56
|
-
"title": "
|
57
|
-
"link": "http://www.facebook.com/
|
31
|
+
"created_time": "2014-08-27T05:28:07+0000",
|
32
|
+
"updated_time": "2014-08-27T05:28:07+0000",
|
33
|
+
"title": "Shota Kawaminami shared your link.",
|
34
|
+
"link": "http://www.facebook.com/shota.kawaminami/posts/700333850049805",
|
58
35
|
"application": {
|
59
36
|
"name": "Links",
|
60
37
|
"id": "2309869772"
|
61
38
|
},
|
62
|
-
"unread": 1
|
63
|
-
"object": {
|
64
|
-
"id": "689134294485152_695439827187932",
|
65
|
-
"from": {
|
66
|
-
"id": "689134294485152",
|
67
|
-
"name": "Shunya Iriki"
|
68
|
-
},
|
69
|
-
"story": "Shunya Iriki shared a link.",
|
70
|
-
"story_tags": {
|
71
|
-
"0": [{
|
72
|
-
"id": "689134294485152",
|
73
|
-
"name": "Shunya Iriki",
|
74
|
-
"offset": 0,
|
75
|
-
"length": 12,
|
76
|
-
"type": "user"
|
77
|
-
}]
|
78
|
-
},
|
79
|
-
"picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQCtEdPdezKIoUxo&w=154&h=154&url=http%3A%2F%2Fi.yimg.jp%2Fi%2Fdocs%2Frelease%2Ffbicon.jpg",
|
80
|
-
"link": "http://docs.yahoo.co.jp/docs/info/terms/chapter1.html#cf2nd",
|
81
|
-
"name": "ヤフー株式会社 - サービス利用規約 第1編 基本ガイドライン",
|
82
|
-
"caption": "docs.yahoo.co.jp",
|
83
|
-
"description": "Yahoo! JAPANのサービス利用規約、第1編 基本ガイドラインは当社のサービスをご利用になるすべての方に共通して適用されます。",
|
84
|
-
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yD/r/aS8ecmYRys0.gif",
|
85
|
-
"actions": [{
|
86
|
-
"name": "Comment",
|
87
|
-
"link": "https://www.facebook.com/100001657627507/posts/695439827187932"
|
88
|
-
}, {
|
89
|
-
"name": "Like",
|
90
|
-
"link": "https://www.facebook.com/100001657627507/posts/695439827187932"
|
91
|
-
}],
|
92
|
-
"privacy": {
|
93
|
-
"value": ""
|
94
|
-
},
|
95
|
-
"type": "link",
|
96
|
-
"status_type": "shared_story",
|
97
|
-
"application": {
|
98
|
-
"name": "Facebook for iPhone",
|
99
|
-
"namespace": "fbiphone",
|
100
|
-
"id": "6628568379"
|
101
|
-
},
|
102
|
-
"created_time": "2014-06-02T12:46:26+0000",
|
103
|
-
"updated_time": "2014-06-02T12:46:26+0000"
|
104
|
-
}
|
39
|
+
"unread": 1
|
105
40
|
}],
|
106
41
|
"paging": {
|
107
|
-
"previous": "https://graph.facebook.com/v2.
|
108
|
-
"next": "https://graph.facebook.com/v2.
|
109
|
-
}
|
110
|
-
"summary": []
|
42
|
+
"previous": "https://graph.facebook.com/v2.1/579612276/notifications?limit=5000&since=1409272999&__paging_token=enc_Aewp7NBZ5fIN12MTyeJziuFNDceCydTGsvVqg-hwrjPZBCnWi-W_fjsS1bNaXkZ9K-tS8wFhFQw4pOajivn20h3c",
|
43
|
+
"next": "https://graph.facebook.com/v2.1/579612276/notifications?limit=5000&until=1408919679&__paging_token=enc_Aey6fAeKsVGCSCKsplC0g1FGjchGgmGajndTVwb-tzE0q7A8nT6C_1iVdwBRzXWdt3zKHh3yOjq6caxNtsTrD58s"
|
44
|
+
}
|
111
45
|
}
|
@@ -14,7 +14,7 @@ module MockGraph
|
|
14
14
|
response = yield
|
15
15
|
a_request(
|
16
16
|
method,
|
17
|
-
endpoint_for(path)
|
17
|
+
endpoint_for(path, options)
|
18
18
|
).with(
|
19
19
|
request_for(method, options)
|
20
20
|
).should have_been_made.once
|
@@ -40,7 +40,7 @@ module MockGraph
|
|
40
40
|
private
|
41
41
|
|
42
42
|
def endpoint_for(path, options = {})
|
43
|
-
api_version = unless options[:
|
43
|
+
api_version = unless options[:disable_api_versioning]
|
44
44
|
options[:api_version] || FbGraph2.api_version
|
45
45
|
end
|
46
46
|
File.join FbGraph2.root_url, api_version.to_s, path
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fb_graph2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nov matake
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -283,7 +283,8 @@ files:
|
|
283
283
|
- lib/fb_graph2/user.rb
|
284
284
|
- lib/fb_graph2/util.rb
|
285
285
|
- lib/fb_graph2/video.rb
|
286
|
-
- spec/fb_graph2/
|
286
|
+
- spec/fb_graph2/app_spec.rb
|
287
|
+
- spec/fb_graph2/auth_spec.rb
|
287
288
|
- spec/fb_graph2/collection_spec.rb
|
288
289
|
- spec/fb_graph2/edge/accounts_spec.rb
|
289
290
|
- spec/fb_graph2/edge/achievements_spec.rb
|
@@ -324,6 +325,7 @@ files:
|
|
324
325
|
- spec/fb_graph2/edge_spec.rb
|
325
326
|
- spec/fb_graph2/node_spec.rb
|
326
327
|
- spec/fb_graph2/node_subclass_spec.rb
|
328
|
+
- spec/fb_graph2/page_spec.rb
|
327
329
|
- spec/fb_graph2/request_filter/authenticator_spec.rb
|
328
330
|
- spec/fb_graph2/request_filter/debugger_spec.rb
|
329
331
|
- spec/fb_graph2/user_spec.rb
|
@@ -333,6 +335,7 @@ files:
|
|
333
335
|
- spec/mock_json/app/subscriptions.json
|
334
336
|
- spec/mock_json/app/test_users.json
|
335
337
|
- spec/mock_json/blank_collection.json
|
338
|
+
- spec/mock_json/error/400/191.json
|
336
339
|
- spec/mock_json/error/400/2500.json
|
337
340
|
- spec/mock_json/error/invalid_format.json
|
338
341
|
- spec/mock_json/page/admins.json
|
@@ -340,6 +343,7 @@ files:
|
|
340
343
|
- spec/mock_json/page/blocked.json
|
341
344
|
- spec/mock_json/page/milestones.json
|
342
345
|
- spec/mock_json/page/promotable_posts.json
|
346
|
+
- spec/mock_json/page/with_optional_fields.json
|
343
347
|
- spec/mock_json/post/comments.json
|
344
348
|
- spec/mock_json/post/comments_with_summary.json
|
345
349
|
- spec/mock_json/post/liked_and_commented.json
|
@@ -347,6 +351,7 @@ files:
|
|
347
351
|
- spec/mock_json/post/shared_posts.json
|
348
352
|
- spec/mock_json/success_true.json
|
349
353
|
- spec/mock_json/success_with_id.json
|
354
|
+
- spec/mock_json/token_response.json
|
350
355
|
- spec/mock_json/true.json
|
351
356
|
- spec/mock_json/user/accounts.json
|
352
357
|
- spec/mock_json/user/achievements.json
|