facebooker 0.9.5 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +14 -0
- data/Manifest.txt +68 -14
- data/README +4 -2
- data/README.txt +22 -4
- data/Rakefile +42 -4
- data/TODO.txt +3 -9
- data/generators/facebook/facebook_generator.rb +14 -0
- data/{facebooker.yml.tpl → generators/facebook/templates/config/facebooker.yml} +12 -2
- data/generators/facebook/templates/public/javascripts/facebooker.js +106 -0
- data/generators/facebook_controller/USAGE +33 -0
- data/generators/facebook_controller/facebook_controller_generator.rb +40 -0
- data/generators/facebook_controller/templates/controller.rb +7 -0
- data/generators/facebook_controller/templates/functional_test.rb +11 -0
- data/generators/facebook_controller/templates/helper.rb +2 -0
- data/generators/facebook_controller/templates/view.fbml.erb +2 -0
- data/generators/facebook_controller/templates/view.html.erb +2 -0
- data/generators/facebook_publisher/facebook_publisher_generator.rb +14 -0
- data/generators/facebook_publisher/templates/create_facebook_templates.rb +15 -0
- data/generators/facebook_publisher/templates/publisher.rb +3 -0
- data/generators/facebook_scaffold/USAGE +27 -0
- data/generators/facebook_scaffold/facebook_scaffold_generator.rb +118 -0
- data/generators/facebook_scaffold/templates/controller.rb +93 -0
- data/generators/facebook_scaffold/templates/facebook_style.css +2579 -0
- data/generators/facebook_scaffold/templates/functional_test.rb +89 -0
- data/generators/facebook_scaffold/templates/helper.rb +2 -0
- data/generators/facebook_scaffold/templates/layout.fbml.erb +6 -0
- data/generators/facebook_scaffold/templates/layout.html.erb +17 -0
- data/generators/facebook_scaffold/templates/style.css +74 -0
- data/generators/facebook_scaffold/templates/view_edit.fbml.erb +13 -0
- data/generators/facebook_scaffold/templates/view_edit.html.erb +18 -0
- data/generators/facebook_scaffold/templates/view_index.fbml.erb +24 -0
- data/generators/facebook_scaffold/templates/view_index.html.erb +24 -0
- data/generators/facebook_scaffold/templates/view_new.fbml.erb +12 -0
- data/generators/facebook_scaffold/templates/view_new.html.erb +17 -0
- data/generators/facebook_scaffold/templates/view_show.fbml.erb +10 -0
- data/generators/facebook_scaffold/templates/view_show.html.erb +10 -0
- data/generators/publisher/publisher_generator.rb +14 -0
- data/generators/xd_receiver/templates/xd_receiver.html +10 -0
- data/generators/xd_receiver/xd_receiver_generator.rb +9 -0
- data/init.rb +30 -12
- data/install.rb +10 -3
- data/lib/facebooker.rb +139 -30
- data/lib/facebooker/adapters/adapter_base.rb +87 -0
- data/lib/facebooker/adapters/bebo_adapter.rb +75 -0
- data/lib/facebooker/adapters/facebook_adapter.rb +48 -0
- data/lib/facebooker/admin.rb +42 -0
- data/lib/facebooker/batch_request.rb +44 -0
- data/lib/facebooker/data.rb +24 -5
- data/lib/facebooker/feed.rb +18 -5
- data/lib/facebooker/logging.rb +51 -0
- data/lib/facebooker/model.rb +18 -1
- data/lib/facebooker/{affiliation.rb → models/affiliation.rb} +0 -0
- data/lib/facebooker/{album.rb → models/album.rb} +0 -0
- data/lib/facebooker/models/applicationproperties.rb +39 -0
- data/lib/facebooker/{cookie.rb → models/cookie.rb} +0 -0
- data/lib/facebooker/{education_info.rb → models/education_info.rb} +0 -0
- data/lib/facebooker/{event.rb → models/event.rb} +2 -0
- data/lib/facebooker/models/friend_list.rb +16 -0
- data/lib/facebooker/{group.rb → models/group.rb} +1 -0
- data/lib/facebooker/models/info_item.rb +10 -0
- data/lib/facebooker/models/info_section.rb +10 -0
- data/lib/facebooker/{location.rb → models/location.rb} +0 -0
- data/lib/facebooker/{notifications.rb → models/notifications.rb} +0 -0
- data/lib/facebooker/models/page.rb +27 -0
- data/lib/facebooker/{photo.rb → models/photo.rb} +4 -1
- data/lib/facebooker/{tag.rb → models/tag.rb} +0 -0
- data/lib/facebooker/models/user.rb +394 -0
- data/lib/facebooker/{work_info.rb → models/work_info.rb} +0 -0
- data/lib/facebooker/parser.rb +201 -19
- data/lib/facebooker/rails/controller.rb +129 -21
- data/lib/facebooker/rails/facebook_form_builder.rb +3 -3
- data/lib/facebooker/rails/facebook_pretty_errors.rb +14 -0
- data/lib/facebooker/rails/facebook_request_fix.rb +10 -0
- data/lib/facebooker/rails/facebook_session_handling.rb +12 -1
- data/lib/facebooker/rails/facebook_url_helper.rb +192 -0
- data/lib/facebooker/rails/facebook_url_rewriting.rb +11 -3
- data/lib/facebooker/rails/helpers.rb +180 -34
- data/lib/facebooker/rails/helpers/fb_connect.rb +38 -0
- data/lib/facebooker/rails/profile_publisher_extensions.rb +42 -0
- data/lib/facebooker/rails/publisher.rb +513 -0
- data/lib/facebooker/rails/routing.rb +1 -1
- data/lib/facebooker/rails/test_helpers.rb +75 -3
- data/lib/facebooker/server_cache.rb +3 -3
- data/lib/facebooker/service.rb +74 -7
- data/lib/facebooker/session.rb +245 -68
- data/lib/facebooker/version.rb +3 -3
- data/lib/tasks/facebooker.rake +4 -2
- data/lib/tasks/tunnel.rake +14 -7
- data/rails/init.rb +1 -0
- data/templates/layout.erb +24 -0
- data/test/adapters_test.rb +98 -0
- data/test/batch_request_test.rb +82 -0
- data/test/facebook_admin_test.rb +102 -0
- data/test/facebook_cache_test.rb +1 -0
- data/test/facebook_data_test.rb +36 -0
- data/test/facebooker_test.rb +221 -80
- data/test/logging_test.rb +43 -0
- data/test/model_test.rb +12 -0
- data/test/publisher_test.rb +458 -0
- data/test/rails_integration_test.rb +538 -33
- data/test/session_test.rb +223 -6
- data/test/test_helper.rb +8 -2
- data/test/user_test.rb +191 -2
- metadata +99 -18
- data/lib/facebooker/user.rb +0 -200
data/test/facebooker_test.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require 'net/http_multipart_post'
|
2
3
|
class TestFacebooker < Test::Unit::TestCase
|
3
4
|
|
4
5
|
def setup
|
5
6
|
@api_key = "95a71599e8293s66f1f0a6f4aeab3df7"
|
6
7
|
@secret_key = "3e4du8eea435d8e205a6c9b5d095bed1"
|
8
|
+
ENV["FACEBOOK_API_KEY"] = @api_key
|
9
|
+
ENV["FACEBOOK_SECRET_KEY"] = @secret_key
|
7
10
|
@session = Facebooker::Session.create(@api_key, @secret_key)
|
8
11
|
@desktop_session = Facebooker::Session::Desktop.create(@api_key, @secret_key)
|
9
12
|
@service = Facebooker::Service.new('http://apibase.com', '/api/path', @api_key)
|
@@ -30,15 +33,15 @@ class TestFacebooker < Test::Unit::TestCase
|
|
30
33
|
assert_equal("http://www.facebook.com/login.php?api_key=#{@api_key}&v=1.0&auth_token=3e4a22bb2f5ed75114b0fc9995ea85f1", @desktop_session.login_url)
|
31
34
|
end
|
32
35
|
|
33
|
-
def test_serivce_post_file_delegates_to_post_multipart_form
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
36
|
+
# def test_serivce_post_file_delegates_to_post_multipart_form
|
37
|
+
# # flexmock(@service).should_receive(:url).and_return('url')
|
38
|
+
# # flexmock(Net::HTTP).expects(:post_multipart_form).with('url', {:method => 'facebook.auth.createToken'}).returns(example_auth_token_xml)
|
39
|
+
#
|
40
|
+
# res = mock(:content_type => 'text/html', :code => '200', :body => '<html><body>my blog</body></html>')
|
41
|
+
# Net::HTTP.stubs(:get_response).once.with(uri).returns res
|
42
|
+
#
|
43
|
+
# @service.post_file(:method => 'facebook.auth.createToken')
|
44
|
+
# end
|
42
45
|
|
43
46
|
def test_desktop_session_be_secured_and_activated_after_receiving_auth_token_and_logging_in
|
44
47
|
establish_session
|
@@ -58,11 +61,15 @@ class TestFacebooker < Test::Unit::TestCase
|
|
58
61
|
end
|
59
62
|
|
60
63
|
def test_can_get_current_users_friends
|
61
|
-
|
62
|
-
mock_http.should_receive(:post_form).and_return(example_friends_xml).once.ordered(:posts)
|
64
|
+
expect_http_posts_with_responses(example_friends_xml)
|
63
65
|
assert_equal([222333, 1240079], @session.user.friends.map{|friend| friend.id})
|
64
66
|
end
|
65
67
|
|
68
|
+
def test_can_get_current_users_friend_lists
|
69
|
+
expect_http_posts_with_responses(example_friend_lists_xml)
|
70
|
+
assert_equal([12089150545, 16361710545], @session.user.friend_lists.map{|friend_list| friend_list.flid})
|
71
|
+
end
|
72
|
+
|
66
73
|
def test_can_get_info_for_instance_of_user
|
67
74
|
populate_user_info
|
68
75
|
@session.user.first_name = "Dave"
|
@@ -90,10 +97,16 @@ class TestFacebooker < Test::Unit::TestCase
|
|
90
97
|
assert_equal('I rule', friend.status.message)
|
91
98
|
assert_equal(nil, friend.hometown_location)
|
92
99
|
end
|
93
|
-
|
100
|
+
|
101
|
+
def test_can_handle_nil_data
|
102
|
+
friends = populate_session_friends_with_nil_data
|
103
|
+
friend = friends.detect{|f| f.id == 222333}
|
104
|
+
assert_equal(nil,friend.current_location)
|
105
|
+
assert_equal(nil,friend.pic)
|
106
|
+
end
|
107
|
+
|
94
108
|
def test_session_can_expire_on_server_and_client_handles_appropriately
|
95
|
-
|
96
|
-
mock_http.should_receive(:post_form).and_return(example_session_expired_error_response).once.ordered(:posts)
|
109
|
+
expect_http_posts_with_responses(example_session_expired_error_response)
|
97
110
|
assert_raises(Facebooker::Session::SessionExpired) {
|
98
111
|
@session.user.friends
|
99
112
|
}
|
@@ -101,8 +114,7 @@ class TestFacebooker < Test::Unit::TestCase
|
|
101
114
|
|
102
115
|
|
103
116
|
def test_can_publish_story_to_users_feed
|
104
|
-
|
105
|
-
mock_http.should_receive(:post_form).and_return(example_publish_story_xml).once.ordered(:posts)
|
117
|
+
expect_http_posts_with_responses(example_publish_story_xml)
|
106
118
|
assert_nothing_raised {
|
107
119
|
assert(@session.user.publish_story((s = Facebooker::Feed::Story.new; s.title = 'o hai'; s.body = '4srsly'; s)))
|
108
120
|
}
|
@@ -110,22 +122,19 @@ class TestFacebooker < Test::Unit::TestCase
|
|
110
122
|
|
111
123
|
|
112
124
|
def test_can_publish_action_to_users_feed
|
113
|
-
|
114
|
-
mock_http.should_receive(:post_form).and_return(example_publish_action_xml).once.ordered(:posts)
|
125
|
+
expect_http_posts_with_responses(example_publish_action_xml)
|
115
126
|
assert_nothing_raised {
|
116
127
|
assert(@session.user.publish_action((s = Facebooker::Feed::Action.new; s.title = 'o hai'; s.body = '4srsly'; s)))
|
117
128
|
}
|
118
129
|
end
|
119
130
|
|
120
131
|
def test_can_publish_templatized_action_to_users_feed
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
assert(@session.user.publish_templatized_action(action))
|
128
|
-
}
|
132
|
+
expect_http_posts_with_responses(example_publish_templatized_action_xml)
|
133
|
+
assert_nothing_raised {
|
134
|
+
action = Facebooker::Feed::TemplatizedAction.new
|
135
|
+
action.title_template = "{actor} did something"
|
136
|
+
assert(@session.user.publish_templatized_action(action))
|
137
|
+
}
|
129
138
|
end
|
130
139
|
|
131
140
|
def test_can_publish_templatized_action_to_users_feed_with_params_as_string
|
@@ -145,41 +154,42 @@ class TestFacebooker < Test::Unit::TestCase
|
|
145
154
|
action.title_data=hash
|
146
155
|
assert_equal action.to_params[:title_data],json_data
|
147
156
|
end
|
148
|
-
|
157
|
+
|
158
|
+
def test_can_deactivate_template_bundle_by_id
|
159
|
+
expect_http_posts_with_responses(example_deactivate_template_bundle_by_id_xml)
|
160
|
+
assert_equal true, @session.post('facebook.feed.deactivateTemplateBundleByID', :template_bundle_id => 123)
|
161
|
+
end
|
162
|
+
|
149
163
|
def test_can_get_notifications_for_logged_in_user
|
150
|
-
|
151
|
-
|
152
|
-
assert_equal("
|
153
|
-
assert_equal("
|
154
|
-
assert_equal("1", @session.user.notifications.shares.unread)
|
164
|
+
expect_http_posts_with_responses(example_notifications_get_xml)
|
165
|
+
assert_equal("1", @session.user.notifications.messages.unread)
|
166
|
+
assert_equal("0", @session.user.notifications.pokes.unread)
|
167
|
+
assert_equal("1", @session.user.notifications.shares.unread)
|
155
168
|
end
|
156
169
|
|
157
170
|
def test_can_send_notifications
|
158
|
-
|
159
|
-
mock_http.should_receive(:post_form).and_return(example_notifications_send_xml).once.ordered(:posts)
|
171
|
+
expect_http_posts_with_responses(example_notifications_send_xml)
|
160
172
|
assert_nothing_raised {
|
161
173
|
user_ids = [123, 321]
|
162
174
|
notification_fbml = "O HAI!!!"
|
163
175
|
optional_email_fbml = "This would be in the email. If this is not passed, facebook sends no mailz!"
|
164
176
|
assert_equal('http://www.facebook.com/send_email.php?from=211031&id=52', @session.send_notification(user_ids, notification_fbml, optional_email_fbml))
|
165
177
|
}
|
166
|
-
end
|
178
|
+
end
|
167
179
|
|
168
180
|
def test_can_send_emails
|
169
|
-
|
170
|
-
mock_http.should_receive(:post_form).and_return(example_notifications_send_email_xml).once.ordered(:posts)
|
181
|
+
expect_http_posts_with_responses(example_notifications_send_email_xml)
|
171
182
|
assert_nothing_raised {
|
172
183
|
user_ids = [123, 321]
|
173
184
|
text = "Hi I am the text part of the email."
|
174
|
-
fbml = "Hi I am the fbml version of the <b>email</a>"
|
185
|
+
fbml = "Hi I am the fbml version of the <b>email</a>"
|
175
186
|
subject = "Somethign you should really pay attention to."
|
176
187
|
assert_equal('123,321', @session.send_email(user_ids, subject,text,fbml ))
|
177
188
|
}
|
178
189
|
end
|
179
190
|
|
180
191
|
def test_can_find_friends_who_have_installed_app
|
181
|
-
|
182
|
-
mock_http.should_receive(:post_form).and_return(example_app_users_xml).once.ordered(:posts)
|
192
|
+
expect_http_posts_with_responses(example_app_users_xml)
|
183
193
|
assert_equal(2, @session.user.friends_with_this_app.size)
|
184
194
|
assert_equal([222333, 1240079], @session.user.friends_with_this_app.map{|f| f.id})
|
185
195
|
end
|
@@ -192,7 +202,7 @@ class TestFacebooker < Test::Unit::TestCase
|
|
192
202
|
assert_not_nil(reloaded_session.instance_variable_get(iv_name))
|
193
203
|
end
|
194
204
|
assert_nil(reloaded_session.user.instance_variable_get("@friends"))
|
195
|
-
end
|
205
|
+
end
|
196
206
|
|
197
207
|
def test_sessions_can_be_infinite_or_can_expire
|
198
208
|
establish_session
|
@@ -205,22 +215,21 @@ class TestFacebooker < Test::Unit::TestCase
|
|
205
215
|
def test_session_can_tell_you_if_it_has_been_secured
|
206
216
|
mock = flexmock(Net::HTTP).should_receive(:post_form).and_return(example_auth_token_xml).once.ordered(:posts)
|
207
217
|
mock.should_receive(:post_form).and_return(example_get_session_xml.sub(/1173309298/, (Time.now + 60).to_i.to_s)).once.ordered(:posts)
|
208
|
-
@session.secure!
|
218
|
+
@session.secure!
|
209
219
|
assert(@session.secured?)
|
210
220
|
end
|
211
221
|
|
212
|
-
def test_can_get_photos_by_pids
|
213
|
-
|
214
|
-
|
215
|
-
photos = @session.get_photos([97503428461115590, 97503428461115573])
|
222
|
+
def test_can_get_photos_by_pids
|
223
|
+
expect_http_posts_with_responses(example_get_photo_xml)
|
224
|
+
photos = @session.get_photos([97503428461115590, 97503428461115573])
|
216
225
|
assert_equal 2, photos.size
|
217
226
|
assert_equal "Rooftop barbecues make me act funny", photos.first.caption
|
227
|
+
assert_equal 97503428461115590, photos[0].id
|
218
228
|
end
|
219
229
|
|
220
230
|
def test_can_get_photos_by_subject_and_album
|
221
|
-
|
222
|
-
|
223
|
-
photos = @session.get_photos(nil, 22701786, 97503428432802022 )
|
231
|
+
expect_http_posts_with_responses(example_get_photo_xml)
|
232
|
+
photos = @session.get_photos(nil, 22701786, 97503428432802022 )
|
224
233
|
assert_equal '97503428432802022', photos.first.aid
|
225
234
|
end
|
226
235
|
|
@@ -230,43 +239,38 @@ class TestFacebooker < Test::Unit::TestCase
|
|
230
239
|
end
|
231
240
|
|
232
241
|
def test_can_get_albums_for_user
|
233
|
-
|
234
|
-
mock_http.should_receive(:post_form).and_return(example_user_albums_xml).once.ordered(:posts)
|
242
|
+
expect_http_posts_with_responses(example_user_albums_xml)
|
235
243
|
assert_equal('Summertime is Best', @session.user.albums.first.name)
|
236
244
|
assert_equal(2, @session.user.albums.size)
|
237
245
|
end
|
238
246
|
|
239
247
|
def test_can_get_albums_by_album_ids
|
240
|
-
|
241
|
-
mock_http.should_receive(:post_form).and_return(example_user_albums_xml).once.ordered(:posts)
|
248
|
+
expect_http_posts_with_responses(example_user_albums_xml)
|
242
249
|
albums = @session.get_albums([97503428432802022, 97503428432797817] )
|
243
250
|
assert_equal('Summertime is Best', albums[0].name)
|
244
251
|
assert_equal('Bonofon\'s Recital', albums[1].name)
|
245
252
|
end
|
246
253
|
|
247
254
|
def test_can_create_album
|
248
|
-
|
249
|
-
mock_http.should_receive(:post_form).and_return(example_new_album_xml).once.ordered(:posts)
|
255
|
+
expect_http_posts_with_responses(example_new_album_xml)
|
250
256
|
assert_equal "My Empty Album", @session.user.create_album(:name => "My Empty Album", :location => "Limboland").name
|
251
|
-
end
|
257
|
+
end
|
252
258
|
|
253
259
|
def test_can_upload_photo
|
254
260
|
mock_http = establish_session
|
255
261
|
mock_http.should_receive(:post_multipart_form).and_return(example_upload_photo_xml).once.ordered(:posts)
|
256
262
|
f = Net::HTTP::MultipartPostFile.new("image.jpg", "image/jpeg", "RAW DATA")
|
257
263
|
assert_equal "Under the sunset", @session.user.upload_photo(f).caption
|
258
|
-
end
|
264
|
+
end
|
259
265
|
|
260
266
|
def test_can_get_photo_tags
|
261
|
-
|
262
|
-
mock_http.should_receive(:post_form).and_return(example_photo_tags_xml).once.ordered(:posts)
|
267
|
+
expect_http_posts_with_responses(example_photo_tags_xml)
|
263
268
|
assert_instance_of Facebooker::Tag, @session.get_tags(:pids => 97503428461115571 ).first
|
264
269
|
end
|
265
270
|
|
266
271
|
# TODO: how to test that tags were created properly? Response doesn't contain much
|
267
272
|
def test_can_tag_a_user_in_a_photo
|
268
|
-
|
269
|
-
mock_http.should_receive(:post_form).and_return(example_add_tag_xml).once.ordered(:posts)
|
273
|
+
expect_http_posts_with_responses(example_add_tag_xml)
|
270
274
|
assert !@session.add_tags(pid = 97503428461115571, x= 30.0, y = 62.5, tag_uid = 1234567890).nil?
|
271
275
|
end
|
272
276
|
|
@@ -274,26 +278,69 @@ class TestFacebooker < Test::Unit::TestCase
|
|
274
278
|
end
|
275
279
|
|
276
280
|
def test_can_get_coordinates_for_photo_tags
|
277
|
-
|
278
|
-
mock_http.should_receive(:post_form).and_return(example_photo_tags_xml).once.ordered(:posts)
|
281
|
+
expect_http_posts_with_responses(example_photo_tags_xml)
|
279
282
|
tag = @session.get_tags([97503428461115571]).first
|
280
283
|
assert_equal ['65.4248', '16.8627'], tag.coordinates
|
281
284
|
end
|
282
285
|
|
283
286
|
def test_can_get_app_profile_fbml_for_user
|
284
|
-
|
285
|
-
mock_http.should_receive(:post_form).and_return(example_get_fbml_xml).once.ordered(:posts)
|
287
|
+
expect_http_posts_with_responses(example_get_fbml_xml)
|
286
288
|
assert_match(/My profile!/, @session.user.profile_fbml)
|
287
289
|
end
|
288
290
|
|
289
291
|
def test_can_set_app_profile_fbml_for_user
|
290
|
-
|
291
|
-
mock_http.should_receive(:post_form).and_return(example_set_fbml_xml).once.ordered(:posts)
|
292
|
+
expect_http_posts_with_responses(example_set_fbml_xml)
|
292
293
|
assert_nothing_raised {
|
293
294
|
@session.user.profile_fbml = 'aha!'
|
294
295
|
}
|
295
296
|
end
|
296
297
|
|
298
|
+
def test_get_logged_in_user
|
299
|
+
expect_http_posts_with_responses(example_get_logged_in_user_xml)
|
300
|
+
assert_equal 1240077, @session.post('facebook.users.getLoggedInUser', :session_key => @session.session_key)
|
301
|
+
end
|
302
|
+
|
303
|
+
def test_pages_get_info
|
304
|
+
expect_http_posts_with_responses(example_pages_get_info_xml)
|
305
|
+
info = {
|
306
|
+
'page_id' => '4846711747',
|
307
|
+
'name' => 'Kronos Quartet',
|
308
|
+
'website' => 'http://www.kronosquartet.org',
|
309
|
+
'company_overview' => ""
|
310
|
+
}
|
311
|
+
assert_equal [info], @session.post('facebook.pages.getInfo', :fields => ['company_overview', 'website', 'name', 'page_id'].join(','), :page_ids => [4846711747].join(','))
|
312
|
+
end
|
313
|
+
|
314
|
+
def test_pages_is_admin_true
|
315
|
+
expect_http_posts_with_responses(example_pages_is_admin_true_xml)
|
316
|
+
assert_equal true, @session.post('facebook.pages.isAdmin', :page_id => 123)
|
317
|
+
end
|
318
|
+
|
319
|
+
def test_pages_is_admin_false
|
320
|
+
expect_http_posts_with_responses(example_pages_is_admin_false_xml)
|
321
|
+
assert_equal false, @session.post('facebook.pages.isAdmin', :page_id => 123)
|
322
|
+
end
|
323
|
+
|
324
|
+
def test_pages_is_fan_true
|
325
|
+
expect_http_posts_with_responses(example_pages_is_fan_true_xml)
|
326
|
+
assert_equal true, @session.post('facebook.pages.isFan', :page_id => 123)
|
327
|
+
end
|
328
|
+
|
329
|
+
def test_pages_is_fan_false
|
330
|
+
expect_http_posts_with_responses(example_pages_is_fan_false_xml)
|
331
|
+
assert_equal false, @session.post('facebook.pages.isFan', :page_id => 123)
|
332
|
+
end
|
333
|
+
|
334
|
+
def test_users_set_status_true
|
335
|
+
expect_http_posts_with_responses(example_users_set_status_true_xml)
|
336
|
+
assert_equal true, @session.post('facebook.users.setStatus', :uid => 123, :status => 'message')
|
337
|
+
end
|
338
|
+
|
339
|
+
def test_users_set_status_false
|
340
|
+
expect_http_posts_with_responses(example_users_set_status_false_xml)
|
341
|
+
assert_equal false, @session.post('facebook.users.setStatus', :uid => 123, :status => 'message')
|
342
|
+
end
|
343
|
+
|
297
344
|
def test_desktop_apps_cannot_request_to_get_or_set_profile_fbml_for_any_user_other_than_logged_in_user
|
298
345
|
mock_http = establish_session(@desktop_session)
|
299
346
|
mock_http.should_receive(:post_form).and_return(example_friends_xml).once.ordered(:posts)
|
@@ -313,29 +360,85 @@ class TestFacebooker < Test::Unit::TestCase
|
|
313
360
|
end
|
314
361
|
|
315
362
|
def populate_user_info_with_limited_fields
|
316
|
-
|
317
|
-
mock_http.should_receive(:post_form).and_return(example_limited_user_info_xml).once.ordered(:posts)
|
363
|
+
expect_http_posts_with_responses(example_limited_user_info_xml)
|
318
364
|
@session.user.populate(:affiliations, :status, :meeting_for)
|
319
365
|
end
|
320
366
|
|
321
367
|
def populate_session_friends
|
322
|
-
|
323
|
-
|
324
|
-
mock_http.should_receive(:post_form).and_return(example_user_info_xml).once.ordered(:posts)
|
325
|
-
@session.user.friends!
|
368
|
+
expect_http_posts_with_responses(example_friends_xml, example_user_info_xml)
|
369
|
+
@session.user.friends!
|
326
370
|
end
|
327
371
|
|
328
372
|
def populate_session_friends_with_limited_fields
|
329
|
-
|
330
|
-
|
331
|
-
mock_http.should_receive(:post_form).and_return(example_limited_user_info_xml).once.ordered(:posts)
|
332
|
-
@session.user.friends!(:affiliations, :status, :meeting_for)
|
373
|
+
expect_http_posts_with_responses(example_friends_xml, example_limited_user_info_xml)
|
374
|
+
@session.user.friends!(:affiliations, :status, :meeting_for)
|
333
375
|
end
|
334
|
-
|
376
|
+
|
377
|
+
def populate_session_friends_with_nil_data
|
378
|
+
expect_http_posts_with_responses(example_friends_xml, example_nil_user_info_xml)
|
379
|
+
@session.user.friends!(:name, :current_location, :pic)
|
380
|
+
end
|
381
|
+
|
335
382
|
def sample_args_to_post
|
336
383
|
{:method=>"facebook.auth.createToken", :sig=>"18b3dc4f5258a63c0ad641eebd3e3930"}
|
337
|
-
end
|
384
|
+
end
|
385
|
+
|
386
|
+
def example_pages_get_info_xml
|
387
|
+
<<-XML
|
388
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
389
|
+
<pages_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">
|
390
|
+
<page>
|
391
|
+
<page_id>4846711747</page_id>
|
392
|
+
<name>Kronos Quartet</name>
|
393
|
+
<website>http://www.kronosquartet.org</website>
|
394
|
+
<company_overview/>
|
395
|
+
</page>
|
396
|
+
</pages_getInfo_response>
|
397
|
+
XML
|
398
|
+
end
|
338
399
|
|
400
|
+
def example_pages_is_admin_true_xml
|
401
|
+
<<-XML
|
402
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
403
|
+
<pages_isAdmin_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">1</pages_isAdmin_response>
|
404
|
+
XML
|
405
|
+
end
|
406
|
+
|
407
|
+
def example_pages_is_admin_false_xml
|
408
|
+
<<-XML
|
409
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
410
|
+
<pages_isAdmin_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">0</pages_isAdmin_response>
|
411
|
+
XML
|
412
|
+
end
|
413
|
+
|
414
|
+
def example_pages_is_fan_true_xml
|
415
|
+
<<-XML
|
416
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
417
|
+
<pages_isFan_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">1</pages_isFan_response>
|
418
|
+
XML
|
419
|
+
end
|
420
|
+
|
421
|
+
def example_pages_is_fan_false_xml
|
422
|
+
<<-XML
|
423
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
424
|
+
<pages_isFan_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">0</pages_isFan_response>
|
425
|
+
XML
|
426
|
+
end
|
427
|
+
|
428
|
+
def example_users_set_status_true_xml
|
429
|
+
<<-XML
|
430
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
431
|
+
<users_setStatus_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">1</users_setStatus_response>
|
432
|
+
XML
|
433
|
+
end
|
434
|
+
|
435
|
+
def example_users_set_status_false_xml
|
436
|
+
<<-XML
|
437
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
438
|
+
<users_setStatus_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">0</users_setStatus_response>
|
439
|
+
XML
|
440
|
+
end
|
441
|
+
|
339
442
|
def example_set_fbml_xml
|
340
443
|
<<-XML
|
341
444
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -424,7 +527,14 @@ class TestFacebooker < Test::Unit::TestCase
|
|
424
527
|
</feed_publishTemplatizedAction_response>
|
425
528
|
XML
|
426
529
|
end
|
427
|
-
|
530
|
+
|
531
|
+
def example_deactivate_template_bundle_by_id_xml
|
532
|
+
<<-XML
|
533
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
534
|
+
<feed_deactivateTemplateBundleByID_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/">1</feed_deactivateTemplateBundleByID_response>
|
535
|
+
XML
|
536
|
+
end
|
537
|
+
|
428
538
|
def example_user_info_xml
|
429
539
|
<<-XML
|
430
540
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -563,6 +673,21 @@ class TestFacebooker < Test::Unit::TestCase
|
|
563
673
|
end
|
564
674
|
|
565
675
|
|
676
|
+
def example_nil_user_info_xml
|
677
|
+
<<-XML
|
678
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
679
|
+
<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">
|
680
|
+
<user>
|
681
|
+
<uid>222333</uid>
|
682
|
+
<name>Kevin Lochner</name>
|
683
|
+
<current_location xsi:nil="true"/>
|
684
|
+
<pic xsi:nil="true"/>
|
685
|
+
</user>
|
686
|
+
</users_getInfo_response>
|
687
|
+
XML
|
688
|
+
end
|
689
|
+
|
690
|
+
|
566
691
|
def example_friends_xml
|
567
692
|
<<-XML
|
568
693
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -573,6 +698,22 @@ class TestFacebooker < Test::Unit::TestCase
|
|
573
698
|
XML
|
574
699
|
end
|
575
700
|
|
701
|
+
def example_friend_lists_xml
|
702
|
+
<<-XML
|
703
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
704
|
+
<friends_getLists_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">
|
705
|
+
<friendlist>
|
706
|
+
<flid>12089150545</flid>
|
707
|
+
<name>Family</name>
|
708
|
+
</friendlist>
|
709
|
+
<friendlist>
|
710
|
+
<flid>16361710545</flid>
|
711
|
+
<name>Entrepreneuer</name>
|
712
|
+
</friendlist>
|
713
|
+
</friends_getLists_response>
|
714
|
+
XML
|
715
|
+
end
|
716
|
+
|
576
717
|
def example_get_logged_in_user_xml
|
577
718
|
<<-XML
|
578
719
|
<?xml version="1.0" encoding="UTF-8"?>
|