mmangino-facebooker 1.0.31 → 1.0.32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +7 -0
- data/facebooker.gemspec +9 -14
- data/generators/facebook/templates/public/javascripts/facebooker.js +2 -18
- data/install.rb +1 -1
- data/lib/facebooker/adapters/bebo_adapter.rb +9 -9
- data/lib/facebooker/data.rb +14 -14
- data/lib/facebooker/models/user.rb +56 -28
- data/lib/facebooker/parser.rb +155 -127
- data/lib/facebooker/rails/extensions/rack_setup.rb +7 -1
- data/lib/facebooker/rails/publisher.rb +4 -0
- data/lib/facebooker/service.rb +17 -9
- data/lib/facebooker/session.rb +3 -1
- data/lib/facebooker/version.rb +1 -1
- data/lib/facebooker.rb +19 -16
- data/test/facebooker/data_test.rb +14 -14
- data/test/facebooker/models/user_test.rb +60 -48
- data/test/facebooker/rails/publisher_test.rb +4 -0
- data/test/facebooker/session_test.rb +73 -73
- data/test/facebooker_test.rb +1 -1
- data/test/test_helper.rb +10 -3
- metadata +8 -8
data/lib/facebooker/service.rb
CHANGED
@@ -12,7 +12,7 @@ module Facebooker
|
|
12
12
|
@api_path = api_path
|
13
13
|
@api_key = api_key
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
# TODO: support ssl
|
17
17
|
def post(params)
|
18
18
|
attempt = 0
|
@@ -23,7 +23,7 @@ module Facebooker
|
|
23
23
|
retry
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def post_form(url,params)
|
28
28
|
if Facebooker.use_curl?
|
29
29
|
post_form_with_curl(url,params)
|
@@ -31,15 +31,20 @@ module Facebooker
|
|
31
31
|
post_form_with_net_http(url,params)
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
def post_form_with_net_http(url,params)
|
36
|
-
|
36
|
+
post_params = {}
|
37
|
+
params.each do |k,v|
|
38
|
+
post_params[k] = v
|
39
|
+
post_params[k] = Facebooker.json_encode(v) if Array === v
|
40
|
+
end
|
41
|
+
Net::HTTP.post_form(url, post_params)
|
37
42
|
end
|
38
|
-
|
43
|
+
|
39
44
|
def post_form_with_curl(url,params,multipart=false)
|
40
45
|
response = Curl::Easy.http_post(url.to_s, *to_curb_params(params)) do |c|
|
41
46
|
c.multipart_form_post = multipart
|
42
|
-
c.timeout = Facebooker.timeout
|
47
|
+
c.timeout = Facebooker.timeout
|
43
48
|
end
|
44
49
|
response.body_str
|
45
50
|
end
|
@@ -67,14 +72,14 @@ module Facebooker
|
|
67
72
|
base ||= @api_base
|
68
73
|
URI.parse('http://'+ base + @api_path)
|
69
74
|
end
|
70
|
-
|
75
|
+
|
71
76
|
# Net::HTTP::MultipartPostFile
|
72
77
|
def multipart_post_file?(object)
|
73
78
|
object.respond_to?(:content_type) &&
|
74
79
|
object.respond_to?(:data) &&
|
75
80
|
object.respond_to?(:filename)
|
76
81
|
end
|
77
|
-
|
82
|
+
|
78
83
|
def to_curb_params(params)
|
79
84
|
parray = []
|
80
85
|
params.each_pair do |k,v|
|
@@ -85,7 +90,10 @@ module Facebooker
|
|
85
90
|
field.content = v.data
|
86
91
|
parray << field
|
87
92
|
else
|
88
|
-
parray << Curl::PostField.content(
|
93
|
+
parray << Curl::PostField.content(
|
94
|
+
k.to_s,
|
95
|
+
Array === v ? Facebooker.json_encode(v) : v.to_s
|
96
|
+
)
|
89
97
|
end
|
90
98
|
end
|
91
99
|
parray
|
data/lib/facebooker/session.rb
CHANGED
@@ -589,7 +589,9 @@ module Facebooker
|
|
589
589
|
|
590
590
|
def signature_for(params)
|
591
591
|
raw_string = params.inject([]) do |collection, pair|
|
592
|
-
collection << pair.
|
592
|
+
collection << pair.map { |x|
|
593
|
+
Array === x ? Facebooker.json_encode(x) : x
|
594
|
+
}.join("=")
|
593
595
|
collection
|
594
596
|
end.sort.join
|
595
597
|
Digest::MD5.hexdigest([raw_string, secret_for_method(params[:method])].join)
|
data/lib/facebooker/version.rb
CHANGED
data/lib/facebooker.rb
CHANGED
@@ -1,26 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
JSON.parse(str)
|
7
|
-
end
|
1
|
+
unless defined?(ActiveSupport) and defined?(ActiveSupport::JSON)
|
2
|
+
require 'json'
|
3
|
+
module Facebooker
|
4
|
+
def self.json_decode(str)
|
5
|
+
JSON.parse(str)
|
8
6
|
end
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
|
8
|
+
def self.json_encode(o)
|
9
|
+
JSON.dump(o)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
else
|
13
|
+
module Facebooker
|
14
|
+
def self.json_decode(str)
|
15
|
+
ActiveSupport::JSON.decode(str)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.json_encode(o)
|
19
|
+
ActiveSupport::JSON.encode(o)
|
14
20
|
end
|
15
21
|
end
|
16
|
-
rescue
|
17
|
-
require 'json'
|
18
22
|
end
|
23
|
+
|
19
24
|
require 'zlib'
|
20
25
|
require 'digest/md5'
|
21
26
|
|
22
|
-
|
23
|
-
|
24
27
|
module Facebooker
|
25
28
|
|
26
29
|
@facebooker_configuration = {}
|
@@ -6,46 +6,46 @@ class Facebooker::DataTest < Test::Unit::TestCase
|
|
6
6
|
#make sure we use net::http since that's what the tests expect
|
7
7
|
Facebooker.use_curl=false
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def test_can_ask_facebook_to_set_a_cookies
|
11
11
|
expect_http_posts_with_responses(example_set_cookie_xml)
|
12
12
|
assert(@session.data.set_cookie(12345, 'name', 'value'))
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def test_can_ask_facebook_to_get_cookies
|
16
16
|
expect_http_posts_with_responses(example_get_cookies_xml)
|
17
17
|
assert(@session.data.get_cookies(12345))
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def test_can_get_cookies_for_user
|
21
21
|
mock_http = establish_session
|
22
22
|
mock_http.should_receive(:post_form).and_return(example_get_cookies_xml).once.ordered(:posts)
|
23
|
-
cookies = @session.data.get_cookies(508508326)
|
23
|
+
cookies = @session.data.get_cookies(508508326)
|
24
24
|
assert_equal 'Foo', cookies.first.name
|
25
25
|
assert_equal 'Bar', cookies.first.value
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def test_can_ask_facebook_to_set_a_preference
|
29
29
|
expect_http_posts_with_responses(example_set_preference_xml)
|
30
30
|
assert(@session.data.set_preference(0, 'hello'))
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def test_can_ask_facebook_to_get_preference
|
34
34
|
expect_http_posts_with_responses(example_get_preference_xml)
|
35
35
|
assert(@session.data.get_preference(0))
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def test_can_get_preference
|
39
39
|
mock_http = establish_session
|
40
40
|
mock_http.should_receive(:post_form).and_return(example_get_preference_xml).once.ordered(:posts)
|
41
|
-
assert_equal 'hello', @session.data.get_preference(0)
|
41
|
+
assert_equal 'hello', @session.data.get_preference(0)
|
42
42
|
end
|
43
43
|
|
44
44
|
private
|
45
45
|
def example_set_cookie_xml
|
46
46
|
<<-XML
|
47
47
|
<?xml version="1.0" encoding="UTF-8"?>
|
48
|
-
<data_setCookie_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
48
|
+
<data_setCookie_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
49
49
|
xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">1</data_setCookie_response>
|
50
50
|
XML
|
51
51
|
end
|
@@ -53,7 +53,7 @@ class Facebooker::DataTest < Test::Unit::TestCase
|
|
53
53
|
def example_get_cookies_xml
|
54
54
|
<<-XML
|
55
55
|
<?xml version="1.0" encoding="UTF-8"?>
|
56
|
-
<data_getCookie_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
56
|
+
<data_getCookie_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
57
57
|
xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">
|
58
58
|
<cookies>
|
59
59
|
<uid>508508326</uid>
|
@@ -65,11 +65,11 @@ class Facebooker::DataTest < Test::Unit::TestCase
|
|
65
65
|
</data_getCookie_response>
|
66
66
|
XML
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
def example_set_preference_xml
|
70
70
|
<<-XML
|
71
71
|
<?xml version="1.0" encoding="UTF-8"?>
|
72
|
-
<data_setUserPreference_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
72
|
+
<data_setUserPreference_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
73
73
|
xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd"/>
|
74
74
|
XML
|
75
75
|
end
|
@@ -77,10 +77,10 @@ class Facebooker::DataTest < Test::Unit::TestCase
|
|
77
77
|
def example_get_preference_xml
|
78
78
|
<<-XML
|
79
79
|
<?xml version="1.0" encoding="UTF-8"?>
|
80
|
-
<data_getUserPreference_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
80
|
+
<data_getUserPreference_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
81
81
|
xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">
|
82
82
|
hello
|
83
83
|
</data_getUserPreference_response>
|
84
84
|
XML
|
85
85
|
end
|
86
|
-
end
|
86
|
+
end
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
|
2
2
|
require 'active_support'
|
3
3
|
|
4
4
|
class Facebooker::UserTest < Test::Unit::TestCase
|
5
|
-
|
5
|
+
|
6
6
|
def setup
|
7
7
|
@session = Facebooker::Session.create('apikey', 'secretkey')
|
8
8
|
@user = Facebooker::User.new(1234, @session)
|
@@ -10,19 +10,19 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
10
10
|
ENV['FACEBOOK_CANVAS_PATH'] ='facebook_app_name'
|
11
11
|
ENV['FACEBOOK_API_KEY'] = '1234567'
|
12
12
|
ENV['FACEBOOK_SECRET_KEY'] = '7654321'
|
13
|
-
|
13
|
+
|
14
14
|
@user.friends = [@other_user]
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def test_has_permission
|
18
18
|
expect_http_posts_with_responses(has_app_permission_response_xml)
|
19
19
|
assert @user.has_permission?("status_update")
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def test_can_ask_user_if_he_or_she_is_friends_with_another_user
|
23
23
|
assert(@user.friends_with?(@other_user))
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def test_can_ask_user_if_he_or_she_is_friends_with_another_user_by_user_id
|
27
27
|
assert(@user.friends_with?(@other_user.id))
|
28
28
|
end
|
@@ -35,14 +35,14 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
35
35
|
def test_uid_is_always_an_integer
|
36
36
|
assert_equal 1234, Facebooker::User.new(:uid => "1234").uid
|
37
37
|
assert_equal 1234, Facebooker::User.new(:id => "1234").uid
|
38
|
-
|
38
|
+
|
39
39
|
assert_equal 1234, Facebooker::User.new(:uid => "1234").id
|
40
40
|
assert_equal 1234, Facebooker::User.new(:id => "1234").id
|
41
|
-
|
41
|
+
|
42
42
|
assert_equal 1234, Facebooker::User.new(:uid => "1234").facebook_id
|
43
43
|
assert_equal 1234, Facebooker::User.new(:id => "1234").facebook_id
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
def test_cast_to_friend_list_id_with_nil
|
47
47
|
assert_nil @user.cast_to_friend_list_id(nil)
|
48
48
|
end
|
@@ -56,7 +56,7 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
56
56
|
def test_cast_to_friend_list_id_with_friend_list
|
57
57
|
assert_equal 199,@user.cast_to_friend_list_id(Facebooker::FriendList.new(:flid=>199,:name=>"Work"))
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
def test_cast_to_friend_list_id_with_invalid_string_raises
|
61
61
|
@user.expects(:friend_lists).returns([Facebooker::FriendList.new(:flid=>1,:name=>"Not Picked")])
|
62
62
|
assert_nil @user.cast_to_friend_list_id("Something")
|
@@ -64,7 +64,7 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
64
64
|
rescue Facebooker::Session::InvalidFriendList
|
65
65
|
nil
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
def test_can_create_from_current_session
|
69
69
|
Facebooker::Session.expects(:current).returns("current")
|
70
70
|
user=Facebooker::User.new(1)
|
@@ -74,7 +74,7 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
74
74
|
def test_raises_when_no_session_bound
|
75
75
|
assert_raises(Facebooker::Model::UnboundSessionException) { Facebooker::User.new(1, nil).populate }
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
def test_can_set_mobile_fbml
|
79
79
|
@user.expects(:set_profile_fbml).with(nil,"test",nil,nil)
|
80
80
|
@user.mobile_fbml="test"
|
@@ -87,52 +87,58 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
87
87
|
@user.expects(:set_profile_fbml).with("test",nil,nil,nil)
|
88
88
|
@user.profile_fbml="test"
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
def test_can_set_profile_main
|
92
92
|
@user.expects(:set_profile_fbml).with(nil,nil,nil,"test")
|
93
93
|
@user.profile_main="test"
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
def test_can_call_set_profile_fbml
|
97
97
|
@session.expects(:post).with('facebook.profile.setFBML', {:uid=>1234,:profile=>"profile",:profile_action=>"action",:mobile_profile=>"mobile"},false)
|
98
98
|
@user.set_profile_fbml("profile","mobile","action")
|
99
99
|
end
|
100
|
-
|
100
|
+
|
101
101
|
def test_can_call_set_profile_fbml_with_profile_main
|
102
102
|
@session.expects(:post).with('facebook.profile.setFBML', {:uid=>1234,:profile=>"profile",:profile_action=>"action",:mobile_profile=>"mobile", :profile_main => 'profile_main'},false)
|
103
103
|
@user.set_profile_fbml("profile","mobile","action",'profile_main')
|
104
104
|
end
|
105
|
-
|
105
|
+
|
106
106
|
def test_can_get_profile_photos
|
107
107
|
@user.expects(:profile_photos)
|
108
108
|
@user.profile_photos
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
def test_can_set_cookie
|
112
112
|
@user.expects(:set_cookie).with('name', 'value')
|
113
113
|
@user.set_cookie('name', 'value')
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
def test_can_get_cookies
|
117
117
|
@user.expects(:get_cookies).with('name')
|
118
118
|
@user.get_cookies('name')
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
def test_get_profile_photos
|
122
122
|
@user = Facebooker::User.new(548871286, @session)
|
123
|
-
expect_http_posts_with_responses(example_profile_photos_get_xml)
|
123
|
+
expect_http_posts_with_responses(example_profile_photos_get_xml)
|
124
124
|
photos = @user.profile_photos
|
125
125
|
assert_equal "2357384227378429949", photos.first.aid
|
126
126
|
end
|
127
|
-
|
127
|
+
|
128
|
+
def test_publish_to
|
129
|
+
@user = Facebooker::User.new(548871286, @session)
|
130
|
+
expect_http_posts_with_responses(example_profile_publish_to_get_xml)
|
131
|
+
@user.publish_to(@other_user, :message => 'i love you man')
|
132
|
+
end
|
133
|
+
|
128
134
|
def test_can_send_email
|
129
135
|
@user.expects(:send_email).with("subject", "body text")
|
130
136
|
@user.send_email("subject", "body text")
|
131
|
-
|
137
|
+
|
132
138
|
@user.expects(:send_email).with("subject", nil, "body fbml")
|
133
139
|
@user.send_email("subject", nil, "body fbml")
|
134
140
|
end
|
135
|
-
|
141
|
+
|
136
142
|
def test_doesnt_post_to_facebook_when_assigning_status
|
137
143
|
@session.expects(:post).never
|
138
144
|
@user.status="my status"
|
@@ -141,7 +147,7 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
141
147
|
@session.expects(:post).with('facebook.users.setStatus', {:status=>"my status",:status_includes_verb=>1, :uid => @user.uid}, false)
|
142
148
|
@user.set_status("my status")
|
143
149
|
end
|
144
|
-
|
150
|
+
|
145
151
|
def test_get_events
|
146
152
|
@user = Facebooker::User.new(9507801, @session)
|
147
153
|
expect_http_posts_with_responses(example_events_get_xml)
|
@@ -158,33 +164,33 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
158
164
|
@session.expects(:post).never
|
159
165
|
assert_equal 1,@user.events.first.eid
|
160
166
|
end
|
161
|
-
|
162
|
-
|
167
|
+
|
168
|
+
|
163
169
|
def test_to_s
|
164
170
|
assert_equal("1234",@user.to_s)
|
165
171
|
end
|
166
|
-
|
172
|
+
|
167
173
|
def test_equality_with_same_id
|
168
174
|
assert_equal @user, @user.dup
|
169
175
|
assert_equal @user, Facebooker::User.new(:id => @user.id)
|
170
176
|
end
|
171
|
-
|
177
|
+
|
172
178
|
def test_not_equal_to_differnt_class
|
173
179
|
assert_not_equal @user, flexmock(:id => @user.id)
|
174
180
|
end
|
175
|
-
|
181
|
+
|
176
182
|
def test_hash_email
|
177
183
|
assert_equal "4228600737_c96da02bba97aedfd26136e980ae3761", Facebooker::User.hash_email("mary@example.com")
|
178
184
|
end
|
179
185
|
def test_hash_email_not_normalized
|
180
186
|
assert_equal "4228600737_c96da02bba97aedfd26136e980ae3761", Facebooker::User.hash_email(" MaRy@example.com ")
|
181
187
|
end
|
182
|
-
|
188
|
+
|
183
189
|
def test_register_with_array
|
184
190
|
expect_http_posts_with_responses(register_response_xml)
|
185
191
|
assert_equal ["4228600737_c96da02bba97aedfd26136e980ae3761"],Facebooker::User.register([{:email=>"mary@example.com",:account_id=>1}])
|
186
192
|
end
|
187
|
-
|
193
|
+
|
188
194
|
def test_unregister_with_array
|
189
195
|
expect_http_posts_with_responses(unregister_response_xml)
|
190
196
|
assert_equal ["4228600737_c96da02bba97aedfd26136e980ae3761"],Facebooker::User.unregister(["4228600737_c96da02bba97aedfd26136e980ae3761"])
|
@@ -194,7 +200,7 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
194
200
|
expect_http_posts_with_responses(unregister_response_xml)
|
195
201
|
assert_equal ["mary@example.com"],Facebooker::User.unregister_emails(["mary@example.com"])
|
196
202
|
end
|
197
|
-
|
203
|
+
|
198
204
|
def test_register_with_array_raises_if_not_all_success
|
199
205
|
expect_http_posts_with_responses(register_response_xml)
|
200
206
|
assert_equal ["4228600737_c96da02bba97aedfd26136e980ae3761"],Facebooker::User.register([{:email=>"mary@example.com",:account_id=>1},{:email=>"mike@example.com",:account_id=>2}])
|
@@ -202,7 +208,7 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
202
208
|
rescue Facebooker::Session::UserRegistrationFailed => e
|
203
209
|
assert_equal({:email=>"mike@example.com",:account_id=>2},e.failed_users.first)
|
204
210
|
end
|
205
|
-
|
211
|
+
|
206
212
|
def test_unregister_with_array_raises_if_not_all_success
|
207
213
|
expect_http_posts_with_responses(unregister_response_xml)
|
208
214
|
assert_equal ["4228600737_c96da02bba97aedfd26136e980ae3761"],Facebooker::User.unregister(["4228600737_c96da02bba97aedfd26136e980ae3761","3587916587_791214eb452bf4de30e957d65a0234d4"])
|
@@ -219,19 +225,19 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
219
225
|
assert_equal("mike@example.com",e.failed_users.first)
|
220
226
|
end
|
221
227
|
|
222
|
-
|
228
|
+
|
223
229
|
def test_get_locale
|
224
230
|
@user = Facebooker::User.new(9507801, @session)
|
225
231
|
expect_http_posts_with_responses(example_users_get_info_xml)
|
226
232
|
assert_equal "en_US", @user.locale
|
227
233
|
end
|
228
|
-
|
234
|
+
|
229
235
|
def test_get_profile_url
|
230
236
|
@user = Facebooker::User.new(8055, @session)
|
231
237
|
expect_http_posts_with_responses(example_users_get_info_xml)
|
232
238
|
assert_equal "http://www.facebook.com/profile.php?id=8055", @user.profile_url
|
233
239
|
end
|
234
|
-
|
240
|
+
|
235
241
|
private
|
236
242
|
def example_profile_photos_get_xml
|
237
243
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
@@ -262,7 +268,7 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
262
268
|
</photo>
|
263
269
|
</photos_get_response>"
|
264
270
|
end
|
265
|
-
|
271
|
+
|
266
272
|
def example_events_get_xml
|
267
273
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
268
274
|
<events_get_response xmlns=\"http://api.facebook.com/1.0/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd\" list=\"true\">
|
@@ -294,31 +300,31 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
294
300
|
</event>
|
295
301
|
</events_get_response>"
|
296
302
|
end
|
297
|
-
|
303
|
+
|
298
304
|
def example_users_get_info_xml
|
299
305
|
<<-XML
|
300
306
|
<?xml version="1.0" encoding="UTF-8"?> <users_getInfo_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true"> <user> <uid>8055</uid> <about_me>This field perpetuates the glorification of the ego. Also, it has a character limit.</about_me> <activities>Here: facebook, etc. There: Glee Club, a capella, teaching.</activities> <affiliations list="true"> <affiliation> <nid>50453093</nid> <name>Facebook Developers</name> <type>work</type> <status/> <year/> </affiliation> </affiliations> <birthday>November 3</birthday> <books>The Brothers K, GEB, Ken Wilber, Zen and the Art, Fitzgerald, The Emporer's New Mind, The Wonderful Story of Henry Sugar</books> <current_location> <city>Palo Alto</city> <state>CA</state> <country>United States</country> <zip>94303</zip> </current_location> <education_history list="true"> <education_info> <name>Harvard</name> <year>2003</year> <concentrations list="true"> <concentration>Applied Mathematics</concentration> <concentration>Computer Science</concentration> </concentrations> </education_info> </education_history> <first_name>Dave</first_name> <hometown_location> <city>York</city> <state>PA</state> <country>United States</country> </hometown_location> <hs_info> <hs1_name>Central York High School</hs1_name> <hs2_name/> <grad_year>1999</grad_year> <hs1_id>21846</hs1_id> <hs2_id>0</hs2_id> </hs_info> <is_app_user>1</is_app_user> <has_added_app>1</has_added_app> <interests>coffee, computers, the funny, architecture, code breaking,snowboarding, philosophy, soccer, talking to strangers</interests> <last_name>Fetterman</last_name> <locale>en_US</locale> <meeting_for list="true"> <seeking>Friendship</seeking> </meeting_for> <meeting_sex list="true"> <sex>female</sex> </meeting_sex> <movies>Tommy Boy, Billy Madison, Fight Club, Dirty Work, Meet the Parents, My Blue Heaven, Office Space </movies> <music>New Found Glory, Daft Punk, Weezer, The Crystal Method, Rage, the KLF, Green Day, Live, Coldplay, Panic at the Disco, Family Force 5</music> <name>Dave Fetterman</name> <notes_count>0</notes_count> <pic>http://photos-055.facebook.com/ip007/profile3/1271/65/s8055_39735.jpg</pic> <pic_big>http://photos-055.facebook.com/ip007/profile3/1271/65/n8055_39735.jpg</pic_big> <pic_small>http://photos-055.facebook.com/ip007/profile3/1271/65/t8055_39735.jpg</pic_small> <pic_square>http://photos-055.facebook.com/ip007/profile3/1271/65/q8055_39735.jpg</pic_square> <political>Moderate</political> <profile_update_time>1170414620</profile_update_time> <profile_url>http://www.facebook.com/profile.php?id=8055</profile_url> <quotes/> <relationship_status>In a Relationship</relationship_status> <religion/> <sex>male</sex> <significant_other_id xsi:nil="true"/> <status> <message>Fast Company, November issue, page 84</message> <time>1193075616</time> </status> <timezone>-8</timezone> <tv>cf. Bob Trahan</tv> <wall_count>121</wall_count> <work_history list="true"> <work_info> <location> <city>Palo Alto</city> <state>CA</state> <country>United States</country> </location> <company_name>Facebook</company_name> <position>Software Engineer</position> <description>Tech Lead, Facebook Platform</description> <start_date>2006-01</start_date> <end_date/> </work_info> </work_history> </user> </users_getInfo_response>
|
301
307
|
XML
|
302
308
|
end
|
303
|
-
|
309
|
+
|
304
310
|
def register_response_xml
|
305
311
|
<<-XML
|
306
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
307
|
-
<connect_registerUsers_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/facebook.xsd" list="true">
|
308
|
-
<connect_registerUsers_response_elt>4228600737_c96da02bba97aedfd26136e980ae3761</connect_registerUsers_response_elt>
|
312
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
313
|
+
<connect_registerUsers_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/facebook.xsd" list="true">
|
314
|
+
<connect_registerUsers_response_elt>4228600737_c96da02bba97aedfd26136e980ae3761</connect_registerUsers_response_elt>
|
309
315
|
</connect_registerUsers_response>
|
310
316
|
XML
|
311
317
|
end
|
312
|
-
|
318
|
+
|
313
319
|
def unregister_response_xml
|
314
320
|
<<-XML
|
315
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
316
|
-
<connect_unregisterUsers_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/facebook.xsd" list="true">
|
317
|
-
<connect_unregisterUsers_response_elt>4228600737_c96da02bba97aedfd26136e980ae3761</connect_unregisterUsers_response_elt>
|
321
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
322
|
+
<connect_unregisterUsers_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/facebook.xsd" list="true">
|
323
|
+
<connect_unregisterUsers_response_elt>4228600737_c96da02bba97aedfd26136e980ae3761</connect_unregisterUsers_response_elt>
|
318
324
|
</connect_unregisterUsers_response>
|
319
325
|
XML
|
320
|
-
end
|
321
|
-
|
326
|
+
end
|
327
|
+
|
322
328
|
def has_app_permission_response_xml
|
323
329
|
<<-XML
|
324
330
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -327,5 +333,11 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
327
333
|
xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">1</users_hasAppPermission_response>
|
328
334
|
XML
|
329
335
|
end
|
330
|
-
|
336
|
+
|
337
|
+
def example_profile_publish_to_get_xml
|
338
|
+
<<-eoxml
|
339
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
340
|
+
<stream_publish_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">703826862_78463536862</stream_publish_response>
|
341
|
+
eoxml
|
342
|
+
end
|
331
343
|
end
|
@@ -427,6 +427,10 @@ class Facebooker::Rails::Publisher::PublisherTest < Test::Unit::TestCase
|
|
427
427
|
assert_equal('http://apps.facebook.com/mike/pokes/do/1',route_image.href)
|
428
428
|
end
|
429
429
|
|
430
|
+
def test_image_holder_equality
|
431
|
+
assert_equal TestPublisher::ImageHolder.new('image.png', 'raw_string'), TestPublisher::ImageHolder.new('image.png', 'raw_string')
|
432
|
+
end
|
433
|
+
|
430
434
|
def test_image_to_json_puts_src_first
|
431
435
|
string_image = TestPublisher.new.image('image.png', 'raw_string')
|
432
436
|
assert_equal "{\"src\":\"/images/image.png\", \"href\":\"raw_string\"}",string_image.to_json
|