fb_graph 1.6.7 → 1.6.8
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/VERSION +1 -1
- data/fb_graph.gemspec +1 -1
- data/lib/fb_graph/node.rb +17 -11
- data/spec/fake_json/users/friends/arjun_private.json +1 -1
- data/spec/fb_graph/checkin_spec.rb +1 -1
- data/spec/fb_graph/connections/accounts_spec.rb +1 -1
- data/spec/fb_graph/connections/activities_spec.rb +1 -1
- data/spec/fb_graph/connections/albums_spec.rb +1 -1
- data/spec/fb_graph/connections/books_spec.rb +1 -1
- data/spec/fb_graph/connections/checkins_spec.rb +2 -2
- data/spec/fb_graph/connections/events_spec.rb +1 -1
- data/spec/fb_graph/connections/friends_spec.rb +7 -7
- data/spec/fb_graph/connections/groups_spec.rb +1 -1
- data/spec/fb_graph/connections/home_spec.rb +3 -3
- data/spec/fb_graph/connections/insights_spec.rb +1 -1
- data/spec/fb_graph/connections/likes_spec.rb +1 -1
- data/spec/fb_graph/connections/statuses_spec.rb +2 -2
- data/spec/fb_graph/user_spec.rb +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.6.
|
1
|
+
1.6.8
|
data/fb_graph.gemspec
CHANGED
data/lib/fb_graph/node.rb
CHANGED
@@ -107,20 +107,26 @@ module FbGraph
|
|
107
107
|
when Array
|
108
108
|
_response_.map!(&:with_indifferent_access)
|
109
109
|
when Hash
|
110
|
-
_response_
|
111
|
-
if _response_[:error]
|
112
|
-
case _response_[:error][:type]
|
113
|
-
when /OAuth/
|
114
|
-
raise Unauthorized.new(_response_[:error][:message])
|
115
|
-
else
|
116
|
-
raise BadRequest.new("#{_response_[:error][:type]} :: #{_response_[:error][:message]}")
|
117
|
-
end
|
118
|
-
else
|
119
|
-
_response_
|
120
|
-
end
|
110
|
+
_response_.with_indifferent_access
|
121
111
|
end
|
122
112
|
end
|
123
113
|
rescue RestClient::Exception => e
|
114
|
+
handle_restclient_error(e)
|
115
|
+
end
|
116
|
+
|
117
|
+
def handle_restclient_error(e)
|
118
|
+
_response_ = JSON.parse(e.http_body).with_indifferent_access
|
119
|
+
if _response_[:error]
|
120
|
+
case _response_[:error][:type]
|
121
|
+
when /OAuth/
|
122
|
+
raise Unauthorized.new(_response_[:error][:message])
|
123
|
+
else
|
124
|
+
raise BadRequest.new("#{_response_[:error][:type]} :: #{_response_[:error][:message]}")
|
125
|
+
end
|
126
|
+
else
|
127
|
+
raise Exception.new(e.http_code, e.message, e.http_body)
|
128
|
+
end
|
129
|
+
rescue JSON::ParserError
|
124
130
|
raise Exception.new(e.http_code, e.message, e.http_body)
|
125
131
|
end
|
126
132
|
end
|
@@ -16,7 +16,7 @@ end
|
|
16
16
|
|
17
17
|
describe FbGraph::Checkin, '.search' do
|
18
18
|
before do
|
19
|
-
fake_json(:get, 'search?type=checkin', 'checkins/search_public')
|
19
|
+
fake_json(:get, 'search?type=checkin', 'checkins/search_public', :status => [401, 'Unauthorized'])
|
20
20
|
fake_json(:get, 'search?type=checkin&access_token=access_token', 'checkins/search_private')
|
21
21
|
end
|
22
22
|
|
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '../../spec_helper')
|
|
3
3
|
describe FbGraph::Connections::Accounts, '#accounts' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
5
|
before do
|
6
|
-
fake_json(:get, 'matake/accounts', 'users/accounts/matake_public')
|
6
|
+
fake_json(:get, 'matake/accounts', 'users/accounts/matake_public', :status => [401, 'Unauthorized'])
|
7
7
|
fake_json(:get, 'matake/accounts?access_token=access_token', 'users/accounts/matake_private')
|
8
8
|
fake_json(:get, 'matake/accounts?access_token=access_token_with_manage_pages_permission', 'users/accounts/matake_private_with_manage_pages_permission')
|
9
9
|
end
|
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '../../spec_helper')
|
|
3
3
|
describe FbGraph::Connections::Activities, '#activities' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
5
|
before do
|
6
|
-
fake_json(:get, 'arjun/activities', 'users/activities/arjun_public')
|
6
|
+
fake_json(:get, 'arjun/activities', 'users/activities/arjun_public', :status => [401, 'Unauthorized'])
|
7
7
|
fake_json(:get, 'arjun/activities?access_token=access_token', 'users/activities/arjun_private')
|
8
8
|
end
|
9
9
|
|
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '../../spec_helper')
|
|
3
3
|
describe FbGraph::Connections::Albums, '#albums' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
5
|
before do
|
6
|
-
fake_json(:get, 'matake/albums', 'users/albums/matake_public')
|
6
|
+
fake_json(:get, 'matake/albums', 'users/albums/matake_public', :status => [401, 'Unauthorized'])
|
7
7
|
fake_json(:get, 'matake/albums?access_token=access_token', 'users/albums/matake_private')
|
8
8
|
end
|
9
9
|
|
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '../../spec_helper')
|
|
3
3
|
describe FbGraph::Connections::Books, '#books' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
5
|
before do
|
6
|
-
fake_json(:get, 'matake/books', 'users/books/matake_public')
|
6
|
+
fake_json(:get, 'matake/books', 'users/books/matake_public', :status => [401, 'Unauthorized'])
|
7
7
|
fake_json(:get, 'matake/books?access_token=access_token', 'users/books/matake_private')
|
8
8
|
end
|
9
9
|
|
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '../../spec_helper')
|
|
3
3
|
describe FbGraph::Connections::Checkins, '#checkins' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
5
|
before do
|
6
|
-
fake_json(:get, 'mattt/checkins', 'users/checkins/mattt_public')
|
6
|
+
fake_json(:get, 'mattt/checkins', 'users/checkins/mattt_public', :status => [401, 'Unauthorized'])
|
7
7
|
fake_json(:get, 'mattt/checkins?access_token=access_token', 'users/checkins/mattt_private')
|
8
8
|
end
|
9
9
|
|
@@ -55,7 +55,7 @@ describe FbGraph::Connections::Checkins, '#checkins' do
|
|
55
55
|
|
56
56
|
context 'when included by FbGraph::Page' do
|
57
57
|
before do
|
58
|
-
fake_json(:get, 'gowalla/checkins', 'pages/checkins/gowalla_public')
|
58
|
+
fake_json(:get, 'gowalla/checkins', 'pages/checkins/gowalla_public', :status => [401, 'Unauthorized'])
|
59
59
|
fake_json(:get, 'gowalla/checkins?access_token=access_token', 'pages/checkins/gowalla_private')
|
60
60
|
end
|
61
61
|
|
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '../../spec_helper')
|
|
3
3
|
describe FbGraph::Connections::Events, '#events' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
5
|
before do
|
6
|
-
fake_json(:get, 'matake/events', 'users/events/matake_public')
|
6
|
+
fake_json(:get, 'matake/events', 'users/events/matake_public', :status => [401, 'Unauthorized'])
|
7
7
|
fake_json(:get, 'matake/events?access_token=access_token', 'users/events/matake_private')
|
8
8
|
end
|
9
9
|
|
@@ -3,25 +3,25 @@ require File.join(File.dirname(__FILE__), '../../spec_helper')
|
|
3
3
|
describe FbGraph::Connections::Friends, '#friends' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
5
|
before do
|
6
|
-
fake_json(:get, 'me/friends', 'users/friends/me_public')
|
6
|
+
fake_json(:get, 'me/friends', 'users/friends/me_public', :status => [401, 'Unauthorized'])
|
7
7
|
fake_json(:get, 'me/friends?access_token=access_token', 'users/friends/me_private')
|
8
|
-
fake_json(:get, 'arjun/friends', 'users/friends/arjun_public')
|
9
|
-
fake_json(:get, 'arjun/friends?access_token=access_token', 'users/friends/arjun_private')
|
8
|
+
fake_json(:get, 'arjun/friends', 'users/friends/arjun_public', :status => [401, 'Unauthorized'])
|
9
|
+
fake_json(:get, 'arjun/friends?access_token=access_token', 'users/friends/arjun_private', :status => [401, 'Unauthorized'])
|
10
10
|
end
|
11
11
|
|
12
12
|
context 'when no access_token given' do
|
13
|
-
it 'should raise FbGraph::
|
13
|
+
it 'should raise FbGraph::Unauthorized' do
|
14
14
|
lambda do
|
15
15
|
FbGraph::User.new('arjun').friends
|
16
|
-
end.should raise_exception(FbGraph::
|
16
|
+
end.should raise_exception(FbGraph::Unauthorized)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'when identifier is not me' do
|
21
|
-
it 'should raise FbGraph::
|
21
|
+
it 'should raise FbGraph::Unauthorized' do
|
22
22
|
lambda do
|
23
23
|
FbGraph::User.new('arjun', :access_token => 'access_token').friends
|
24
|
-
end.should raise_exception(FbGraph::
|
24
|
+
end.should raise_exception(FbGraph::Unauthorized)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '../../spec_helper')
|
|
3
3
|
describe FbGraph::Connections::Groups, '#groups' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
5
|
before do
|
6
|
-
fake_json(:get, 'matake/groups', 'users/groups/matake_public')
|
6
|
+
fake_json(:get, 'matake/groups', 'users/groups/matake_public', :status => [401, 'Unauthorized'])
|
7
7
|
fake_json(:get, 'matake/groups?access_token=access_token', 'users/groups/matake_private')
|
8
8
|
end
|
9
9
|
|
@@ -3,10 +3,10 @@ require File.join(File.dirname(__FILE__), '../../spec_helper')
|
|
3
3
|
describe FbGraph::Connections::Home, '#home' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
5
|
before do
|
6
|
-
fake_json(:get, 'me/home', 'users/home/me_public')
|
6
|
+
fake_json(:get, 'me/home', 'users/home/me_public', :status => [401, 'Unauthorized'])
|
7
7
|
fake_json(:get, 'me/home?access_token=access_token', 'users/home/me_private')
|
8
|
-
fake_json(:get, 'arjun/home', 'users/home/arjun_public')
|
9
|
-
fake_json(:get, 'arjun/home?access_token=access_token', 'users/home/arjun_private')
|
8
|
+
fake_json(:get, 'arjun/home', 'users/home/arjun_public', :status => [400, 'BadRequest'])
|
9
|
+
fake_json(:get, 'arjun/home?access_token=access_token', 'users/home/arjun_private', :status => [400, 'BadRequest'])
|
10
10
|
end
|
11
11
|
|
12
12
|
context 'when no access_token given' do
|
@@ -4,7 +4,7 @@ describe FbGraph::Connections::Insights, '#insights' do
|
|
4
4
|
|
5
5
|
context 'when included by FbGraph::Page' do
|
6
6
|
before do
|
7
|
-
fake_json(:get, 'FbGraph/insights', 'pages/insights/FbGraph_public')
|
7
|
+
fake_json(:get, 'FbGraph/insights', 'pages/insights/FbGraph_public', :status => [401, 'Unauthorized'])
|
8
8
|
fake_json(:get, 'FbGraph/insights?access_token=access_token', 'pages/insights/FbGraph_private')
|
9
9
|
end
|
10
10
|
|
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '../../spec_helper')
|
|
3
3
|
describe FbGraph::Connections::Likes, '#likes' do
|
4
4
|
context 'when included by FbGraph::User' do
|
5
5
|
before do
|
6
|
-
fake_json(:get, 'arjun/likes', 'users/likes/arjun_public')
|
6
|
+
fake_json(:get, 'arjun/likes', 'users/likes/arjun_public', :status => [401, 'Unauthorized'])
|
7
7
|
fake_json(:get, 'arjun/likes?access_token=access_token', 'users/likes/arjun_private')
|
8
8
|
end
|
9
9
|
|
@@ -4,7 +4,7 @@ describe FbGraph::Connections::Statuses, '#statuses' do
|
|
4
4
|
|
5
5
|
context 'when included by FbGraph::User' do
|
6
6
|
before do
|
7
|
-
fake_json(:get, 'arjun/statuses', 'users/statuses/arjun_public')
|
7
|
+
fake_json(:get, 'arjun/statuses', 'users/statuses/arjun_public', :status => [401, 'Unauthorized'])
|
8
8
|
fake_json(:get, 'arjun/statuses?access_token=access_token', 'users/statuses/arjun_private')
|
9
9
|
end
|
10
10
|
|
@@ -38,7 +38,7 @@ describe FbGraph::Connections::Statuses, '#statuses' do
|
|
38
38
|
|
39
39
|
context 'when included by FbGraph::Page' do
|
40
40
|
before do
|
41
|
-
fake_json(:get, 'platform/statuses', 'pages/statuses/platform_public')
|
41
|
+
fake_json(:get, 'platform/statuses', 'pages/statuses/platform_public', :status => [401, 'Unauthorized'])
|
42
42
|
fake_json(:get, 'platform/statuses?access_token=access_token', 'pages/statuses/platform_private')
|
43
43
|
end
|
44
44
|
|
data/spec/fb_graph/user_spec.rb
CHANGED
@@ -33,7 +33,7 @@ end
|
|
33
33
|
|
34
34
|
describe FbGraph::User, '.fetch' do
|
35
35
|
before do
|
36
|
-
fake_json(:get, 'me', 'users/me_public')
|
36
|
+
fake_json(:get, 'me', 'users/me_public', :status => [401, 'Unauthorized'])
|
37
37
|
fake_json(:get, 'me?access_token=access_token', 'users/me_private')
|
38
38
|
fake_json(:get, 'arjun', 'users/arjun_public')
|
39
39
|
fake_json(:get, 'arjun?access_token=access_token', 'users/arjun_private')
|
metadata
CHANGED