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
@@ -6,9 +6,9 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
6
6
|
|
7
7
|
def setup
|
8
8
|
ENV['FACEBOOK_API_KEY'] = '1234567'
|
9
|
-
ENV['FACEBOOK_SECRET_KEY'] = '7654321'
|
10
|
-
Facebooker.current_adapter = nil
|
11
|
-
@session = Facebooker::Session.create('whatever', 'doesnotmatterintest')
|
9
|
+
ENV['FACEBOOK_SECRET_KEY'] = '7654321'
|
10
|
+
Facebooker.current_adapter = nil
|
11
|
+
@session = Facebooker::Session.create('whatever', 'doesnotmatterintest')
|
12
12
|
Facebooker.use_curl=false
|
13
13
|
end
|
14
14
|
|
@@ -32,7 +32,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
32
32
|
flexmock(File).should_receive(:read).with(File.expand_path("~/.facebookerrc")).once.and_return('{:api => "foo"}')
|
33
33
|
assert_equal('foo', Facebooker::Session.api_key)
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def test_if_environment_and_file_fail_to_match_then_an_exception_is_raised
|
37
37
|
ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'] = nil
|
38
38
|
flexmock(File).should_receive(:read).with(File.expand_path("~/.facebookerrc")).once.and_return {raise Errno::ENOENT, "No such file"}
|
@@ -40,24 +40,24 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
40
40
|
Facebooker::Session.api_key
|
41
41
|
}
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
def test_marshal_stores_api_key
|
45
45
|
data = Marshal.dump(@session)
|
46
46
|
loaded_session = Marshal.load(data)
|
47
47
|
assert_equal 'whatever', loaded_session.instance_variable_get("@api_key")
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
def test_marshal_stores_secret_key
|
51
51
|
data = Marshal.dump(@session)
|
52
52
|
loaded_session = Marshal.load(data)
|
53
|
-
assert_equal 'doesnotmatterintest', loaded_session.instance_variable_get("@secret_key")
|
53
|
+
assert_equal 'doesnotmatterintest', loaded_session.instance_variable_get("@secret_key")
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
def test_configuration_file_path_can_be_set_explicitly
|
57
57
|
Facebooker::Session.configuration_file_path = '/tmp/foo'
|
58
58
|
assert_equal('/tmp/foo', Facebooker::Session.configuration_file_path)
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
def test_session_can_be_secured_with_existing_values
|
62
62
|
session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
63
63
|
session.secure_with!("a session key", "123456", Time.now.to_i + 60)
|
@@ -74,31 +74,31 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
74
74
|
assert_equal 'a session key', session.session_key
|
75
75
|
assert_equal 321, session.user.to_i
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
# The Facebook API for this is hideous. Oh well.
|
79
79
|
def test_can_ask_session_to_check_friendship_between_pairs_of_users
|
80
80
|
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
81
81
|
mock_http = establish_session
|
82
82
|
mock_http.should_receive(:post_form).and_return(example_check_friendship_xml).once.ordered(:posts)
|
83
|
-
assert_equal({[222332, 222333] => true, [1240077, 1240079] => false}, @session.check_friendship([[222332, 222333], [1240077, 1240079]]))
|
83
|
+
assert_equal({[222332, 222333] => true, [1240077, 1240079] => false}, @session.check_friendship([[222332, 222333], [1240077, 1240079]]))
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
def test_facebook_can_claim_ignorance_as_to_friend_relationships
|
87
87
|
mock_http = establish_session
|
88
|
-
mock_http.should_receive(:post_form).and_return(example_check_friendship_with_unknown_result).once.ordered(:posts)
|
89
|
-
assert_equal({[1240077, 1240079] => nil}, @session.check_friendship([[1240077, 1240079]]))
|
88
|
+
mock_http.should_receive(:post_form).and_return(example_check_friendship_with_unknown_result).once.ordered(:posts)
|
89
|
+
assert_equal({[1240077, 1240079] => nil}, @session.check_friendship([[1240077, 1240079]]))
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
92
|
def test_can_query_with_fql
|
93
93
|
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
94
|
-
expect_http_posts_with_responses(example_fql_for_multiple_photos_xml)
|
94
|
+
expect_http_posts_with_responses(example_fql_for_multiple_photos_xml)
|
95
95
|
response = @session.fql_query('Lets be frank. We are not testing the query here')
|
96
|
-
assert_kind_of(Facebooker::Photo, response.first)
|
96
|
+
assert_kind_of(Facebooker::Photo, response.first)
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
def test_anonymous_fql_results_get_put_in_a_positioned_array_on_the_model
|
100
100
|
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
101
|
-
expect_http_posts_with_responses(example_fql_for_multiple_photos_with_anon_xml)
|
101
|
+
expect_http_posts_with_responses(example_fql_for_multiple_photos_with_anon_xml)
|
102
102
|
response = @session.fql_query('Lets be frank. We are not testing the query here')
|
103
103
|
assert_kind_of(Facebooker::Photo, response.first)
|
104
104
|
response.each do |photo|
|
@@ -107,11 +107,11 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
107
107
|
end
|
108
108
|
def test_no_results_returns_empty_array
|
109
109
|
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
110
|
-
expect_http_posts_with_responses(no_results_fql)
|
110
|
+
expect_http_posts_with_responses(no_results_fql)
|
111
111
|
response = @session.fql_query('Lets be frank. We are not testing the query here')
|
112
112
|
assert_equal [],response
|
113
113
|
end
|
114
|
-
|
114
|
+
|
115
115
|
def test_can_fql_query_for_event_members
|
116
116
|
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
117
117
|
expect_http_posts_with_responses(example_fql_query_event_members_xml)
|
@@ -119,7 +119,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
119
119
|
assert_kind_of(Facebooker::Event::Attendance, response.first)
|
120
120
|
assert_equal('attending', response.first.rsvp_status)
|
121
121
|
end
|
122
|
-
|
122
|
+
|
123
123
|
def test_can_query_for_event_members
|
124
124
|
expect_http_posts_with_responses(example_event_members_xml)
|
125
125
|
event_attendances = @session.event_members(69)
|
@@ -128,19 +128,19 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
128
128
|
assert_equal(["1240077", "222332", "222333", "222335", "222336"], event_attendances.map{|ea| ea.uid}.sort)
|
129
129
|
assert_equal 5, event_attendances.size
|
130
130
|
end
|
131
|
-
|
131
|
+
|
132
132
|
def test_can_query_for_events
|
133
|
-
expect_http_posts_with_responses(example_events_get_xml)
|
133
|
+
expect_http_posts_with_responses(example_events_get_xml)
|
134
134
|
events = @session.events
|
135
135
|
assert_equal 'Technology Tasting', events.first.name
|
136
136
|
end
|
137
|
-
|
137
|
+
|
138
138
|
def test_can_query_for_groups
|
139
|
-
expect_http_posts_with_responses(example_groups_get_xml)
|
139
|
+
expect_http_posts_with_responses(example_groups_get_xml)
|
140
140
|
groups = @session.user.groups
|
141
141
|
assert_equal 'Donald Knuth Is My Homeboy', groups.first.name
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
def test_can_query_for_group_memberships
|
145
145
|
expect_http_posts_with_responses(example_group_members_xml)
|
146
146
|
example_group = Facebooker::Group.new({:gid => 123, :session => @session})
|
@@ -149,18 +149,18 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
149
149
|
assert_equal(123, group_memberships.last.gid)
|
150
150
|
assert_equal(1240078, example_group.members.last.id)
|
151
151
|
end
|
152
|
-
|
152
|
+
|
153
153
|
def test_can_fql_query_for_users_and_pictures
|
154
154
|
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
155
155
|
mock_http = establish_session
|
156
|
-
mock_http.should_receive(:post_form).and_return(example_fql_for_multiple_users_and_pics).once.ordered(:posts)
|
156
|
+
mock_http.should_receive(:post_form).and_return(example_fql_for_multiple_users_and_pics).once.ordered(:posts)
|
157
157
|
response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')
|
158
158
|
assert_kind_of Array, response
|
159
159
|
assert_kind_of Facebooker::User, response.first
|
160
160
|
assert_equal "Ari Steinberg", response.first.name
|
161
161
|
end
|
162
|
-
|
163
|
-
|
162
|
+
|
163
|
+
|
164
164
|
def test_can_send_notification_with_object
|
165
165
|
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
166
166
|
@session.expects(:post).with('facebook.notifications.send',{:to_ids=>"1",:notification=>"a",:type=>"user_to_user"},true)
|
@@ -175,19 +175,19 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
175
175
|
@session.expects(:post).with('facebook.notifications.send',{:to_ids=>"1",:notification=>"a", :type=>"user_to_user"},true)
|
176
176
|
@session.send_notification(["1"],"a")
|
177
177
|
end
|
178
|
-
|
178
|
+
|
179
179
|
def test_can_send_announcement_notification
|
180
180
|
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
181
181
|
@session.expects(:post).with('facebook.notifications.send',{:to_ids=>"1",:notification=>"a", :type=>"app_to_user"},false)
|
182
182
|
@session.send_notification(["1"],"a")
|
183
183
|
end
|
184
|
-
|
184
|
+
|
185
185
|
def test_can_register_template_bundle
|
186
186
|
expect_http_posts_with_responses(example_register_template_bundle_return_xml)
|
187
187
|
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
188
188
|
assert_equal 17876842716, @session.register_template_bundle("{*actor*} did something")
|
189
189
|
end
|
190
|
-
|
190
|
+
|
191
191
|
def test_can_register_template_bundle_with_action_links
|
192
192
|
expect_http_posts_with_responses(example_register_template_bundle_return_xml)
|
193
193
|
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
@@ -198,7 +198,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
198
198
|
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
199
199
|
assert @session.publish_user_action(17876842716,{})
|
200
200
|
end
|
201
|
-
|
201
|
+
|
202
202
|
def test_logs_api_calls
|
203
203
|
call_name = 'sample.api.call'
|
204
204
|
params = { :param1 => true, :param2 => 'value' }
|
@@ -207,7 +207,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
207
207
|
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
208
208
|
@session.post(call_name, params)
|
209
209
|
end
|
210
|
-
|
210
|
+
|
211
211
|
def test_requests_inside_batch_are_added_to_batch
|
212
212
|
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
213
213
|
@session.send(:service).expects(:post).once
|
@@ -215,14 +215,14 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
215
215
|
@session.send_notification(["1"],"a")
|
216
216
|
@session.send_notification(["1"],"a")
|
217
217
|
end
|
218
|
-
|
218
|
+
|
219
219
|
end
|
220
220
|
|
221
221
|
def test_parses_batch_response
|
222
222
|
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
223
223
|
expect_http_posts_with_responses(example_batch_run_xml)
|
224
224
|
@session.batch do
|
225
|
-
@fql_response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')
|
225
|
+
@fql_response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')
|
226
226
|
end
|
227
227
|
assert_kind_of(Facebooker::Event::Attendance, @fql_response.first)
|
228
228
|
assert_equal('attending', @fql_response.first.rsvp_status)
|
@@ -231,9 +231,9 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
231
231
|
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
232
232
|
expect_http_posts_with_responses(example_batch_run_xml)
|
233
233
|
Facebooker::FqlQuery.expects(:process).raises(NoMethodError.new)
|
234
|
-
|
234
|
+
|
235
235
|
@session.batch do
|
236
|
-
@fql_response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')
|
236
|
+
@fql_response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')
|
237
237
|
end
|
238
238
|
assert_raises(NoMethodError) {
|
239
239
|
@fql_response.first
|
@@ -244,7 +244,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
244
244
|
Facebooker::BatchRun.current_batch=4
|
245
245
|
assert_equal 4,Facebooker::BatchRun.current_batch
|
246
246
|
end
|
247
|
-
|
247
|
+
|
248
248
|
def test_can_get_stanard_info
|
249
249
|
expect_http_posts_with_responses(standard_info_xml)
|
250
250
|
result = @session.users_standard([4])
|
@@ -267,21 +267,21 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
267
267
|
assert_equal "4846711747", page.page_id
|
268
268
|
assert_equal "Kronos Quartet", page.name
|
269
269
|
assert_equal "http://www.kronosquartet.org", page.website
|
270
|
-
|
270
|
+
|
271
271
|
# TODO we really need a way to differentiate between hash/list and text attributes
|
272
272
|
# assert_equal({}, page.company_overview)
|
273
|
-
|
273
|
+
|
274
274
|
# sakkaoui : as a fix to the parser, I replace empty text node by "" instead of {}
|
275
275
|
# we have child.attributes['list'] == 'true' that let us know that we have a hash/list.
|
276
276
|
assert_equal("", page.company_overview)
|
277
|
-
|
277
|
+
|
278
278
|
genre = page.genre
|
279
279
|
assert_equal false, genre.dance
|
280
280
|
assert_equal true, genre.party
|
281
281
|
end
|
282
|
-
|
282
|
+
|
283
283
|
private
|
284
|
-
|
284
|
+
|
285
285
|
def example_groups_get_xml
|
286
286
|
<<-XML
|
287
287
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -312,10 +312,10 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
312
312
|
<country>United States</country>
|
313
313
|
</venue>
|
314
314
|
</group>
|
315
|
-
</groups_get_response>
|
315
|
+
</groups_get_response>
|
316
316
|
XML
|
317
317
|
end
|
318
|
-
|
318
|
+
|
319
319
|
def example_events_get_xml
|
320
320
|
<<-XML
|
321
321
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -343,10 +343,10 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
343
343
|
<country>United States</country>
|
344
344
|
</venue>
|
345
345
|
</event>
|
346
|
-
</events_get_response>
|
346
|
+
</events_get_response>
|
347
347
|
XML
|
348
348
|
end
|
349
|
-
|
349
|
+
|
350
350
|
def example_fql_query_event_members_xml
|
351
351
|
<<-XML
|
352
352
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -378,10 +378,10 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
378
378
|
<uid2>1240079</uid2>
|
379
379
|
<are_friends>0</are_friends>
|
380
380
|
</friend_info>
|
381
|
-
</friends_areFriends_response>
|
381
|
+
</friends_areFriends_response>
|
382
382
|
XML
|
383
383
|
end
|
384
|
-
|
384
|
+
|
385
385
|
def example_check_friendship_with_unknown_result
|
386
386
|
<<-XML
|
387
387
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -391,10 +391,10 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
391
391
|
<uid2>1240079</uid2>
|
392
392
|
<are_friends xsi:nil="true"/>
|
393
393
|
</friend_info>
|
394
|
-
</friends_areFriends_response>
|
394
|
+
</friends_areFriends_response>
|
395
395
|
XML
|
396
396
|
end
|
397
|
-
|
397
|
+
|
398
398
|
def example_fql_for_multiple_users_and_pics
|
399
399
|
<<-XML
|
400
400
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -410,7 +410,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
410
410
|
</fql_query_response>
|
411
411
|
XML
|
412
412
|
end
|
413
|
-
|
413
|
+
|
414
414
|
def example_fql_for_multiple_photos_xml
|
415
415
|
<<-XML
|
416
416
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -433,7 +433,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
433
433
|
</fql_query_response>
|
434
434
|
XML
|
435
435
|
end
|
436
|
-
|
436
|
+
|
437
437
|
def example_fql_for_multiple_photos_with_anon_xml
|
438
438
|
<<-XML
|
439
439
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -462,16 +462,16 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
462
462
|
</fql_query_response>
|
463
463
|
XML
|
464
464
|
end
|
465
|
-
|
465
|
+
|
466
466
|
def no_results_fql
|
467
467
|
<<-XML
|
468
468
|
<?xml version="1.0" encoding="UTF-8"?>
|
469
469
|
<fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true">
|
470
470
|
</fql_query_response>
|
471
471
|
XML
|
472
|
-
|
472
|
+
|
473
473
|
end
|
474
|
-
|
474
|
+
|
475
475
|
def example_group_members_xml
|
476
476
|
<<-XML
|
477
477
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -490,21 +490,21 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
490
490
|
<uid>1240078</uid>
|
491
491
|
</officers>
|
492
492
|
<not_replied list="true"/>
|
493
|
-
</groups_getMembers_response>
|
493
|
+
</groups_getMembers_response>
|
494
494
|
XML
|
495
495
|
end
|
496
|
-
|
496
|
+
|
497
497
|
def example_batch_run_xml
|
498
498
|
<<-XML
|
499
499
|
<?xml version="1.0" encoding="UTF-8"?>
|
500
500
|
<batch_run_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">
|
501
|
-
<batch_run_response_elt>
|
501
|
+
<batch_run_response_elt>
|
502
502
|
#{CGI.escapeHTML(example_fql_query_event_members_xml)}
|
503
503
|
</batch_run_response_elt>
|
504
504
|
</batch_run_response>
|
505
505
|
XML
|
506
506
|
end
|
507
|
-
|
507
|
+
|
508
508
|
def example_event_members_xml
|
509
509
|
<<-XML
|
510
510
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -524,7 +524,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
524
524
|
</events_getMembers_response>
|
525
525
|
XML
|
526
526
|
end
|
527
|
-
|
527
|
+
|
528
528
|
def example_register_template_bundle_return_xml
|
529
529
|
<<-XML
|
530
530
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -551,7 +551,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
551
551
|
</pages_getInfo_response>
|
552
552
|
XML
|
553
553
|
end
|
554
|
-
|
554
|
+
|
555
555
|
def publish_user_action_return_xml
|
556
556
|
<<-XML
|
557
557
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -560,7 +560,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
560
560
|
</feed_publishUserAction_response>
|
561
561
|
XML
|
562
562
|
end
|
563
|
-
|
563
|
+
|
564
564
|
def standard_info_xml
|
565
565
|
<<-XML
|
566
566
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -577,7 +577,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
577
577
|
end
|
578
578
|
|
579
579
|
class PostMethodTest < Test::Unit::TestCase
|
580
|
-
|
580
|
+
|
581
581
|
def setup
|
582
582
|
Facebooker.use_curl = true
|
583
583
|
Facebooker::Parser.stubs(:parse)
|
@@ -585,28 +585,28 @@ class PostMethodTest < Test::Unit::TestCase
|
|
585
585
|
@service = Facebooker::Service.new("a","b","c")
|
586
586
|
@service.stubs("url").returns(@uri)
|
587
587
|
end
|
588
|
-
|
588
|
+
|
589
589
|
def teardown
|
590
590
|
Facebooker.use_curl = false
|
591
591
|
end
|
592
|
-
|
592
|
+
|
593
593
|
def test_use_curl_makes_post_with_curl
|
594
594
|
@service.expects(:post_form_with_curl).with(@uri,{:method=>"a"})
|
595
595
|
@service.post(:method=>"a")
|
596
596
|
end
|
597
|
-
|
597
|
+
|
598
598
|
def test_use_curl_makes_post_file_use_curl_with_multipart
|
599
599
|
@service.expects(:post_form_with_curl).with(@uri,{:method=>"a"},true)
|
600
|
-
@service.post_file(:method=>"a")
|
600
|
+
@service.post_file(:method=>"a")
|
601
601
|
end
|
602
602
|
end
|
603
603
|
|
604
604
|
class CanvasSessionTest < Test::Unit::TestCase
|
605
605
|
def setup
|
606
606
|
ENV['FACEBOOK_API_KEY'] = '1234567'
|
607
|
-
ENV['FACEBOOK_SECRET_KEY'] = '7654321'
|
607
|
+
ENV['FACEBOOK_SECRET_KEY'] = '7654321'
|
608
608
|
end
|
609
|
-
|
609
|
+
|
610
610
|
def test_login_url_will_display_callback_url_in_canvas
|
611
611
|
session = Facebooker::CanvasSession.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
612
612
|
assert_equal("http://www.facebook.com/login.php?api_key=1234567&v=1.0&canvas=true", session.login_url)
|
data/test/facebooker_test.rb
CHANGED
@@ -485,7 +485,7 @@ class TestFacebooker < Test::Unit::TestCase
|
|
485
485
|
def example_notifications_send_xml
|
486
486
|
<<-XML
|
487
487
|
<?xml version="1.0" encoding="UTF-8"?>
|
488
|
-
<notifications_send_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">http://www.facebook.com/send_email.php?from=211031&id=52</notifications_send_response>
|
488
|
+
<notifications_send_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">http://www.facebook.com/send_email.php?from=211031&id=52</notifications_send_response>
|
489
489
|
XML
|
490
490
|
end
|
491
491
|
|
data/test/test_helper.rb
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'rubygems'
|
3
3
|
|
4
|
+
begin
|
5
|
+
require 'nokogiri'
|
6
|
+
rescue LoadError
|
7
|
+
# Should work without nokogiri
|
8
|
+
end
|
9
|
+
|
4
10
|
begin
|
5
11
|
require 'multi_rails_init'
|
6
12
|
rescue LoadError
|
7
13
|
# multi rails not installed, test against newest supported version of Rails
|
8
14
|
gem 'rails', '2.2.2'
|
9
15
|
end
|
16
|
+
require 'activesupport'
|
10
17
|
require 'flexmock/test_unit'
|
11
18
|
require 'mocha'
|
12
19
|
|
@@ -38,10 +45,10 @@ class Test::Unit::TestCase
|
|
38
45
|
def establish_session(session = @session)
|
39
46
|
mock = flexmock(Net::HTTP).should_receive(:post_form).and_return(example_auth_token_xml).once.ordered(:posts)
|
40
47
|
mock.should_receive(:post_form).and_return(example_get_session_xml).once.ordered(:posts)
|
41
|
-
session.secure!
|
48
|
+
session.secure!
|
42
49
|
mock
|
43
50
|
end
|
44
|
-
|
51
|
+
|
45
52
|
def example_auth_token_xml
|
46
53
|
<<-XML
|
47
54
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -52,7 +59,7 @@ class Test::Unit::TestCase
|
|
52
59
|
</auth_createToken_response>
|
53
60
|
XML
|
54
61
|
end
|
55
|
-
|
62
|
+
|
56
63
|
def example_get_session_xml
|
57
64
|
<<-XML
|
58
65
|
<?xml version="1.0" encoding="UTF-8"?>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mmangino-facebooker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.32
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Fowler
|
@@ -13,7 +13,7 @@ autorequire:
|
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
15
|
|
16
|
-
date: 2009-
|
16
|
+
date: 2009-05-12 00:00:00 -07:00
|
17
17
|
default_executable:
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ">="
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.
|
37
|
+
version: 1.11.0
|
38
38
|
version:
|
39
39
|
description: "Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]. Its goals are: * Idiomatic Ruby * No dependencies outside of the Ruby standard library (This is true with Rails 2.1. Previous Rails versions require the JSON gem) * Concrete classes and methods modeling the Facebook data, so it's easy for a Rubyist to understand what's available * Well tested"
|
40
40
|
email: mmangino@elevatedrails.com
|
@@ -203,9 +203,10 @@ requirements: []
|
|
203
203
|
rubyforge_project: facebooker
|
204
204
|
rubygems_version: 1.2.0
|
205
205
|
signing_key:
|
206
|
-
specification_version:
|
206
|
+
specification_version: 2
|
207
207
|
summary: Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]
|
208
208
|
test_files:
|
209
|
+
- test/facebooker_test.rb
|
209
210
|
- test/facebooker/adapters_test.rb
|
210
211
|
- test/facebooker/admin_test.rb
|
211
212
|
- test/facebooker/batch_request_test.rb
|
@@ -213,12 +214,11 @@ test_files:
|
|
213
214
|
- test/facebooker/logging_test.rb
|
214
215
|
- test/facebooker/mobile_test.rb
|
215
216
|
- test/facebooker/model_test.rb
|
216
|
-
- test/facebooker/models/event_test.rb
|
217
|
-
- test/facebooker/models/user_test.rb
|
218
|
-
- test/facebooker/rails/publisher_test.rb
|
219
217
|
- test/facebooker/rails_integration_test.rb
|
220
218
|
- test/facebooker/server_cache_test.rb
|
221
219
|
- test/facebooker/session_test.rb
|
222
|
-
- test/
|
220
|
+
- test/facebooker/models/event_test.rb
|
221
|
+
- test/facebooker/models/user_test.rb
|
222
|
+
- test/facebooker/rails/publisher_test.rb
|
223
223
|
- test/net/http_multipart_post_test.rb
|
224
224
|
- test/rack/facebook_test.rb
|