facebooker 1.0.31 → 1.0.41

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/CHANGELOG.rdoc +7 -0
  2. data/Manifest.txt +5 -0
  3. data/README.rdoc +9 -0
  4. data/facebooker.gemspec +8 -9
  5. data/generators/facebook/templates/public/javascripts/facebooker.js +10 -16
  6. data/init.rb +4 -1
  7. data/install.rb +1 -1
  8. data/lib/facebooker.rb +75 -20
  9. data/lib/facebooker/adapters/bebo_adapter.rb +9 -9
  10. data/lib/facebooker/data.rb +14 -14
  11. data/lib/facebooker/models/page.rb +16 -0
  12. data/lib/facebooker/models/photo.rb +7 -0
  13. data/lib/facebooker/models/user.rb +75 -28
  14. data/lib/facebooker/parser.rb +187 -127
  15. data/lib/facebooker/rails/backwards_compatible_param_checks.rb +31 -0
  16. data/lib/facebooker/rails/controller.rb +30 -7
  17. data/lib/facebooker/rails/extensions/rack_setup.rb +5 -1
  18. data/lib/facebooker/rails/facebook_request_fix.rb +5 -5
  19. data/lib/facebooker/rails/facebook_request_fix_2-3.rb +31 -0
  20. data/lib/facebooker/rails/facebook_url_rewriting.rb +7 -2
  21. data/lib/facebooker/rails/helpers.rb +29 -5
  22. data/lib/facebooker/rails/helpers/fb_connect.rb +14 -5
  23. data/lib/facebooker/rails/publisher.rb +26 -12
  24. data/lib/facebooker/service.rb +64 -56
  25. data/lib/facebooker/session.rb +56 -22
  26. data/lib/facebooker/version.rb +1 -1
  27. data/lib/rack/facebook.rb +26 -14
  28. data/lib/tasks/tunnel.rake +1 -1
  29. data/test/facebooker/adapters_test.rb +78 -0
  30. data/test/facebooker/data_test.rb +14 -14
  31. data/test/facebooker/models/page_test.rb +46 -0
  32. data/test/facebooker/models/photo_test.rb +16 -0
  33. data/test/facebooker/models/user_test.rb +83 -48
  34. data/test/facebooker/rails/facebook_request_fix_2-3_test.rb +25 -0
  35. data/test/facebooker/rails/facebook_url_rewriting_test.rb +39 -0
  36. data/test/facebooker/rails/publisher_test.rb +5 -1
  37. data/test/facebooker/rails_integration_test.rb +52 -8
  38. data/test/facebooker/service_test.rb +58 -0
  39. data/test/facebooker/session_test.rb +106 -92
  40. data/test/facebooker_test.rb +2 -2
  41. data/test/rack/facebook_test.rb +4 -4
  42. data/test/test_helper.rb +10 -3
  43. metadata +14 -4
@@ -0,0 +1,58 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
+ require 'active_support'
3
+ # make sure the class exists
4
+ class ::Facebooker::Service::CurlService < Facebooker::Service::BaseService
5
+ end
6
+
7
+ class ::Facebooker::Service::TyphoeusMultiService
8
+ def process
9
+ end
10
+ end
11
+
12
+ class Facebooker::ServiceTest < Test::Unit::TestCase
13
+
14
+ def test_should_use_the_curl_service
15
+ Facebooker.use_curl = true
16
+ Facebooker::Service.active_service= nil
17
+ assert(Facebooker::Service::CurlService === Facebooker::Service.active_service)
18
+ ensure
19
+ Facebooker::Service.active_service= nil
20
+ end
21
+
22
+ def test_should_allow_changing_the_service_in_a_block
23
+ Facebooker::Service.with_service("MyService") do
24
+ assert_equal(Facebooker::Service.active_service,"MyService")
25
+ end
26
+
27
+ end
28
+
29
+ def test_should_restore_the_original_service_even_with_an_exception
30
+ original_service = Facebooker::Service.active_service
31
+ begin
32
+ Facebooker::Service.with_service("MyService") do
33
+ raise "This is a test"
34
+ end
35
+ fail("Should have raised")
36
+ rescue
37
+ end
38
+ assert_equal(original_service,Facebooker::Service.active_service)
39
+ end
40
+
41
+ def test_should_allow_using_the_async_service
42
+ Facebooker::Service.with_async do
43
+ assert(Facebooker::Service::TyphoeusMultiService === Facebooker::Service.active_service)
44
+ @called = true
45
+ end
46
+ assert @called
47
+ end
48
+
49
+ def test_should_call_process_at_the_end_of_the_block
50
+ Facebooker::Service.with_async do
51
+ Facebooker::Service.active_service.expects(:process)
52
+ @called = true
53
+ end
54
+ assert @called
55
+
56
+ end
57
+
58
+ end
@@ -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
 
@@ -29,35 +29,37 @@ class Facebooker::SessionTest < Test::Unit::TestCase
29
29
 
30
30
  def test_if_keys_are_not_available_via_environment_then_they_are_gotten_from_a_file
31
31
  ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'] = nil
32
+ Facebooker.instance_variable_set('@facebooker_configuration', nil)
32
33
  flexmock(File).should_receive(:read).with(File.expand_path("~/.facebookerrc")).once.and_return('{:api => "foo"}')
33
34
  assert_equal('foo', Facebooker::Session.api_key)
34
35
  end
35
-
36
+
36
37
  def test_if_environment_and_file_fail_to_match_then_an_exception_is_raised
37
38
  ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'] = nil
39
+ Facebooker.instance_variable_set('@facebooker_configuration', nil)
38
40
  flexmock(File).should_receive(:read).with(File.expand_path("~/.facebookerrc")).once.and_return {raise Errno::ENOENT, "No such file"}
39
41
  assert_raises(Facebooker::Session::ConfigurationMissing) {
40
42
  Facebooker::Session.api_key
41
43
  }
42
44
  end
43
-
45
+
44
46
  def test_marshal_stores_api_key
45
47
  data = Marshal.dump(@session)
46
48
  loaded_session = Marshal.load(data)
47
49
  assert_equal 'whatever', loaded_session.instance_variable_get("@api_key")
48
50
  end
49
-
51
+
50
52
  def test_marshal_stores_secret_key
51
53
  data = Marshal.dump(@session)
52
54
  loaded_session = Marshal.load(data)
53
- assert_equal 'doesnotmatterintest', loaded_session.instance_variable_get("@secret_key")
55
+ assert_equal 'doesnotmatterintest', loaded_session.instance_variable_get("@secret_key")
54
56
  end
55
-
57
+
56
58
  def test_configuration_file_path_can_be_set_explicitly
57
59
  Facebooker::Session.configuration_file_path = '/tmp/foo'
58
60
  assert_equal('/tmp/foo', Facebooker::Session.configuration_file_path)
59
61
  end
60
-
62
+
61
63
  def test_session_can_be_secured_with_existing_values
62
64
  session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
63
65
  session.secure_with!("a session key", "123456", Time.now.to_i + 60)
@@ -74,31 +76,31 @@ class Facebooker::SessionTest < Test::Unit::TestCase
74
76
  assert_equal 'a session key', session.session_key
75
77
  assert_equal 321, session.user.to_i
76
78
  end
77
-
79
+
78
80
  # The Facebook API for this is hideous. Oh well.
79
81
  def test_can_ask_session_to_check_friendship_between_pairs_of_users
80
82
  @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
81
83
  mock_http = establish_session
82
84
  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]]))
85
+ assert_equal({[222332, 222333] => true, [1240077, 1240079] => false}, @session.check_friendship([[222332, 222333], [1240077, 1240079]]))
84
86
  end
85
-
87
+
86
88
  def test_facebook_can_claim_ignorance_as_to_friend_relationships
87
89
  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]]))
90
+ mock_http.should_receive(:post_form).and_return(example_check_friendship_with_unknown_result).once.ordered(:posts)
91
+ assert_equal({[1240077, 1240079] => nil}, @session.check_friendship([[1240077, 1240079]]))
90
92
  end
91
-
93
+
92
94
  def test_can_query_with_fql
93
95
  @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
94
- expect_http_posts_with_responses(example_fql_for_multiple_photos_xml)
96
+ expect_http_posts_with_responses(example_fql_for_multiple_photos_xml)
95
97
  response = @session.fql_query('Lets be frank. We are not testing the query here')
96
- assert_kind_of(Facebooker::Photo, response.first)
98
+ assert_kind_of(Facebooker::Photo, response.first)
97
99
  end
98
-
100
+
99
101
  def test_anonymous_fql_results_get_put_in_a_positioned_array_on_the_model
100
102
  @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)
103
+ expect_http_posts_with_responses(example_fql_for_multiple_photos_with_anon_xml)
102
104
  response = @session.fql_query('Lets be frank. We are not testing the query here')
103
105
  assert_kind_of(Facebooker::Photo, response.first)
104
106
  response.each do |photo|
@@ -107,11 +109,11 @@ class Facebooker::SessionTest < Test::Unit::TestCase
107
109
  end
108
110
  def test_no_results_returns_empty_array
109
111
  @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
110
- expect_http_posts_with_responses(no_results_fql)
112
+ expect_http_posts_with_responses(no_results_fql)
111
113
  response = @session.fql_query('Lets be frank. We are not testing the query here')
112
114
  assert_equal [],response
113
115
  end
114
-
116
+
115
117
  def test_can_fql_query_for_event_members
116
118
  @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
117
119
  expect_http_posts_with_responses(example_fql_query_event_members_xml)
@@ -119,7 +121,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
119
121
  assert_kind_of(Facebooker::Event::Attendance, response.first)
120
122
  assert_equal('attending', response.first.rsvp_status)
121
123
  end
122
-
124
+
123
125
  def test_can_query_for_event_members
124
126
  expect_http_posts_with_responses(example_event_members_xml)
125
127
  event_attendances = @session.event_members(69)
@@ -128,19 +130,19 @@ class Facebooker::SessionTest < Test::Unit::TestCase
128
130
  assert_equal(["1240077", "222332", "222333", "222335", "222336"], event_attendances.map{|ea| ea.uid}.sort)
129
131
  assert_equal 5, event_attendances.size
130
132
  end
131
-
133
+
132
134
  def test_can_query_for_events
133
- expect_http_posts_with_responses(example_events_get_xml)
135
+ expect_http_posts_with_responses(example_events_get_xml)
134
136
  events = @session.events
135
137
  assert_equal 'Technology Tasting', events.first.name
136
138
  end
137
-
139
+
138
140
  def test_can_query_for_groups
139
- expect_http_posts_with_responses(example_groups_get_xml)
141
+ expect_http_posts_with_responses(example_groups_get_xml)
140
142
  groups = @session.user.groups
141
143
  assert_equal 'Donald Knuth Is My Homeboy', groups.first.name
142
144
  end
143
-
145
+
144
146
  def test_can_query_for_group_memberships
145
147
  expect_http_posts_with_responses(example_group_members_xml)
146
148
  example_group = Facebooker::Group.new({:gid => 123, :session => @session})
@@ -149,18 +151,27 @@ class Facebooker::SessionTest < Test::Unit::TestCase
149
151
  assert_equal(123, group_memberships.last.gid)
150
152
  assert_equal(1240078, example_group.members.last.id)
151
153
  end
152
-
154
+
153
155
  def test_can_fql_query_for_users_and_pictures
154
156
  @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
155
157
  mock_http = establish_session
156
- mock_http.should_receive(:post_form).and_return(example_fql_for_multiple_users_and_pics).once.ordered(:posts)
158
+ mock_http.should_receive(:post_form).and_return(example_fql_for_multiple_users_and_pics).once.ordered(:posts)
157
159
  response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')
158
160
  assert_kind_of Array, response
159
161
  assert_kind_of Facebooker::User, response.first
160
162
  assert_equal "Ari Steinberg", response.first.name
161
163
  end
162
-
163
-
164
+
165
+ def test_can_fql_multiquery_for_users_and_pictures
166
+ @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
167
+ mock_http = establish_session
168
+ mock_http.should_receive(:post_form).and_return(example_fql_multiquery_xml).once.ordered(:posts)
169
+ response = @session.fql_multiquery({:query => 'SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660'})
170
+ assert_kind_of Array, response["query1"]
171
+ assert_kind_of Facebooker::User, response["query1"].first
172
+ assert_equal "Ari Steinberg", response["query1"].first.name
173
+ end
174
+
164
175
  def test_can_send_notification_with_object
165
176
  @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
166
177
  @session.expects(:post).with('facebook.notifications.send',{:to_ids=>"1",:notification=>"a",:type=>"user_to_user"},true)
@@ -175,19 +186,19 @@ class Facebooker::SessionTest < Test::Unit::TestCase
175
186
  @session.expects(:post).with('facebook.notifications.send',{:to_ids=>"1",:notification=>"a", :type=>"user_to_user"},true)
176
187
  @session.send_notification(["1"],"a")
177
188
  end
178
-
189
+
179
190
  def test_can_send_announcement_notification
180
191
  @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
181
192
  @session.expects(:post).with('facebook.notifications.send',{:to_ids=>"1",:notification=>"a", :type=>"app_to_user"},false)
182
193
  @session.send_notification(["1"],"a")
183
194
  end
184
-
195
+
185
196
  def test_can_register_template_bundle
186
197
  expect_http_posts_with_responses(example_register_template_bundle_return_xml)
187
198
  @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
188
199
  assert_equal 17876842716, @session.register_template_bundle("{*actor*} did something")
189
200
  end
190
-
201
+
191
202
  def test_can_register_template_bundle_with_action_links
192
203
  expect_http_posts_with_responses(example_register_template_bundle_return_xml)
193
204
  @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
@@ -198,7 +209,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
198
209
  @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
199
210
  assert @session.publish_user_action(17876842716,{})
200
211
  end
201
-
212
+
202
213
  def test_logs_api_calls
203
214
  call_name = 'sample.api.call'
204
215
  params = { :param1 => true, :param2 => 'value' }
@@ -207,7 +218,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
207
218
  @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
208
219
  @session.post(call_name, params)
209
220
  end
210
-
221
+
211
222
  def test_requests_inside_batch_are_added_to_batch
212
223
  @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
213
224
  @session.send(:service).expects(:post).once
@@ -215,14 +226,14 @@ class Facebooker::SessionTest < Test::Unit::TestCase
215
226
  @session.send_notification(["1"],"a")
216
227
  @session.send_notification(["1"],"a")
217
228
  end
218
-
229
+
219
230
  end
220
231
 
221
232
  def test_parses_batch_response
222
233
  @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
223
234
  expect_http_posts_with_responses(example_batch_run_xml)
224
235
  @session.batch do
225
- @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')
226
237
  end
227
238
  assert_kind_of(Facebooker::Event::Attendance, @fql_response.first)
228
239
  assert_equal('attending', @fql_response.first.rsvp_status)
@@ -231,9 +242,9 @@ class Facebooker::SessionTest < Test::Unit::TestCase
231
242
  @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
232
243
  expect_http_posts_with_responses(example_batch_run_xml)
233
244
  Facebooker::FqlQuery.expects(:process).raises(NoMethodError.new)
234
-
245
+
235
246
  @session.batch do
236
- @fql_response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')
247
+ @fql_response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')
237
248
  end
238
249
  assert_raises(NoMethodError) {
239
250
  @fql_response.first
@@ -244,7 +255,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
244
255
  Facebooker::BatchRun.current_batch=4
245
256
  assert_equal 4,Facebooker::BatchRun.current_batch
246
257
  end
247
-
258
+
248
259
  def test_can_get_stanard_info
249
260
  expect_http_posts_with_responses(standard_info_xml)
250
261
  result = @session.users_standard([4])
@@ -267,21 +278,48 @@ class Facebooker::SessionTest < Test::Unit::TestCase
267
278
  assert_equal "4846711747", page.page_id
268
279
  assert_equal "Kronos Quartet", page.name
269
280
  assert_equal "http://www.kronosquartet.org", page.website
270
-
281
+
271
282
  # TODO we really need a way to differentiate between hash/list and text attributes
272
283
  # assert_equal({}, page.company_overview)
273
-
284
+
274
285
  # sakkaoui : as a fix to the parser, I replace empty text node by "" instead of {}
275
286
  # we have child.attributes['list'] == 'true' that let us know that we have a hash/list.
276
287
  assert_equal("", page.company_overview)
277
-
288
+
278
289
  genre = page.genre
279
290
  assert_equal false, genre.dance
280
291
  assert_equal true, genre.party
281
292
  end
282
-
293
+
283
294
  private
284
-
295
+
296
+ def example_fql_multiquery_xml
297
+ <<-XML
298
+ <?xml version="1.0" encoding="UTF-8"?>
299
+ <fql_multiquery_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">
300
+ <fql_result>
301
+ <name>query1</name>
302
+ <results list="true">
303
+ <user>
304
+ <name>Ari Steinberg</name>
305
+ <uid>46903192</uid>
306
+ <rsvp_status xsi:nil="true"/>
307
+ </user>
308
+ </results>
309
+ </fql_result>
310
+ <fql_result>
311
+ <name>query2</name>
312
+ <results list="true">
313
+ <user>
314
+ <name>Lisa Petrovskaia</name>
315
+ <pic xsi:nil="true"/>
316
+ </user>
317
+ </results>
318
+ </fql_result>
319
+ </fql_multiquery_response>
320
+ XML
321
+ end
322
+
285
323
  def example_groups_get_xml
286
324
  <<-XML
287
325
  <?xml version="1.0" encoding="UTF-8"?>
@@ -312,10 +350,10 @@ class Facebooker::SessionTest < Test::Unit::TestCase
312
350
  <country>United States</country>
313
351
  </venue>
314
352
  </group>
315
- </groups_get_response>
353
+ </groups_get_response>
316
354
  XML
317
355
  end
318
-
356
+
319
357
  def example_events_get_xml
320
358
  <<-XML
321
359
  <?xml version="1.0" encoding="UTF-8"?>
@@ -343,10 +381,10 @@ class Facebooker::SessionTest < Test::Unit::TestCase
343
381
  <country>United States</country>
344
382
  </venue>
345
383
  </event>
346
- </events_get_response>
384
+ </events_get_response>
347
385
  XML
348
386
  end
349
-
387
+
350
388
  def example_fql_query_event_members_xml
351
389
  <<-XML
352
390
  <?xml version="1.0" encoding="UTF-8"?>
@@ -378,10 +416,10 @@ class Facebooker::SessionTest < Test::Unit::TestCase
378
416
  <uid2>1240079</uid2>
379
417
  <are_friends>0</are_friends>
380
418
  </friend_info>
381
- </friends_areFriends_response>
419
+ </friends_areFriends_response>
382
420
  XML
383
421
  end
384
-
422
+
385
423
  def example_check_friendship_with_unknown_result
386
424
  <<-XML
387
425
  <?xml version="1.0" encoding="UTF-8"?>
@@ -391,10 +429,10 @@ class Facebooker::SessionTest < Test::Unit::TestCase
391
429
  <uid2>1240079</uid2>
392
430
  <are_friends xsi:nil="true"/>
393
431
  </friend_info>
394
- </friends_areFriends_response>
432
+ </friends_areFriends_response>
395
433
  XML
396
434
  end
397
-
435
+
398
436
  def example_fql_for_multiple_users_and_pics
399
437
  <<-XML
400
438
  <?xml version="1.0" encoding="UTF-8"?>
@@ -410,7 +448,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
410
448
  </fql_query_response>
411
449
  XML
412
450
  end
413
-
451
+
414
452
  def example_fql_for_multiple_photos_xml
415
453
  <<-XML
416
454
  <?xml version="1.0" encoding="UTF-8"?>
@@ -433,7 +471,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
433
471
  </fql_query_response>
434
472
  XML
435
473
  end
436
-
474
+
437
475
  def example_fql_for_multiple_photos_with_anon_xml
438
476
  <<-XML
439
477
  <?xml version="1.0" encoding="UTF-8"?>
@@ -462,16 +500,16 @@ class Facebooker::SessionTest < Test::Unit::TestCase
462
500
  </fql_query_response>
463
501
  XML
464
502
  end
465
-
503
+
466
504
  def no_results_fql
467
505
  <<-XML
468
506
  <?xml version="1.0" encoding="UTF-8"?>
469
507
  <fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true">
470
508
  </fql_query_response>
471
509
  XML
472
-
510
+
473
511
  end
474
-
512
+
475
513
  def example_group_members_xml
476
514
  <<-XML
477
515
  <?xml version="1.0" encoding="UTF-8"?>
@@ -490,21 +528,21 @@ class Facebooker::SessionTest < Test::Unit::TestCase
490
528
  <uid>1240078</uid>
491
529
  </officers>
492
530
  <not_replied list="true"/>
493
- </groups_getMembers_response>
531
+ </groups_getMembers_response>
494
532
  XML
495
533
  end
496
-
534
+
497
535
  def example_batch_run_xml
498
536
  <<-XML
499
537
  <?xml version="1.0" encoding="UTF-8"?>
500
538
  <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>
539
+ <batch_run_response_elt>
502
540
  #{CGI.escapeHTML(example_fql_query_event_members_xml)}
503
541
  </batch_run_response_elt>
504
542
  </batch_run_response>
505
543
  XML
506
544
  end
507
-
545
+
508
546
  def example_event_members_xml
509
547
  <<-XML
510
548
  <?xml version="1.0" encoding="UTF-8"?>
@@ -524,7 +562,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
524
562
  </events_getMembers_response>
525
563
  XML
526
564
  end
527
-
565
+
528
566
  def example_register_template_bundle_return_xml
529
567
  <<-XML
530
568
  <?xml version="1.0" encoding="UTF-8"?>
@@ -551,7 +589,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
551
589
  </pages_getInfo_response>
552
590
  XML
553
591
  end
554
-
592
+
555
593
  def publish_user_action_return_xml
556
594
  <<-XML
557
595
  <?xml version="1.0" encoding="UTF-8"?>
@@ -560,7 +598,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
560
598
  </feed_publishUserAction_response>
561
599
  XML
562
600
  end
563
-
601
+
564
602
  def standard_info_xml
565
603
  <<-XML
566
604
  <?xml version="1.0" encoding="UTF-8"?>
@@ -576,37 +614,13 @@ class Facebooker::SessionTest < Test::Unit::TestCase
576
614
  end
577
615
  end
578
616
 
579
- class PostMethodTest < Test::Unit::TestCase
580
-
581
- def setup
582
- Facebooker.use_curl = true
583
- Facebooker::Parser.stubs(:parse)
584
- @uri = URI.parse("http://api.facebook.com/api")
585
- @service = Facebooker::Service.new("a","b","c")
586
- @service.stubs("url").returns(@uri)
587
- end
588
-
589
- def teardown
590
- Facebooker.use_curl = false
591
- end
592
-
593
- def test_use_curl_makes_post_with_curl
594
- @service.expects(:post_form_with_curl).with(@uri,{:method=>"a"})
595
- @service.post(:method=>"a")
596
- end
597
-
598
- def test_use_curl_makes_post_file_use_curl_with_multipart
599
- @service.expects(:post_form_with_curl).with(@uri,{:method=>"a"},true)
600
- @service.post_file(:method=>"a")
601
- end
602
- end
603
617
 
604
618
  class CanvasSessionTest < Test::Unit::TestCase
605
619
  def setup
606
620
  ENV['FACEBOOK_API_KEY'] = '1234567'
607
- ENV['FACEBOOK_SECRET_KEY'] = '7654321'
621
+ ENV['FACEBOOK_SECRET_KEY'] = '7654321'
608
622
  end
609
-
623
+
610
624
  def test_login_url_will_display_callback_url_in_canvas
611
625
  session = Facebooker::CanvasSession.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
612
626
  assert_equal("http://www.facebook.com/login.php?api_key=1234567&v=1.0&canvas=true", session.login_url)