1 require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2 require 'active_support'
4 class Facebooker::SessionTest < Test::Unit::TestCase
8 ENV['FACEBOOK_API_KEY'] = '1234567'
9 ENV['FACEBOOK_SECRET_KEY'] = '7654321'
10 Facebooker.current_adapter = nil
11 @session = Facebooker::Session.create('whatever', 'doesnotmatterintest')
12 Facebooker.use_curl=false
16 Facebooker::Session.configuration_file_path = nil
20 def test_install_url_escapes_optional_next_parameter
21 session = Facebooker::CanvasSession.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
22 assert_equal("http://www.facebook.com/install.php?api_key=1234567&v=1.0&next=next_url%3Fa%3D1%26b%3D2", session.install_url(:next => "next_url?a=1&b=2"))
25 def test_can_get_api_and_secret_key_from_environment
26 assert_equal('1234567', Facebooker::Session.api_key)
27 assert_equal('7654321', Facebooker::Session.secret_key)
30 def test_if_keys_are_not_available_via_environment_then_they_are_gotten_from_a_file
31 ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'] = nil
32 Facebooker.instance_variable_set('@facebooker_configuration', nil)
33 flexmock(File).should_receive(:read).with(File.expand_path("~/.facebookerrc")).once.and_return('{:api => "foo"}')
34 assert_equal('foo', Facebooker::Session.api_key)
37 def test_if_environment_and_file_fail_to_match_then_an_exception_is_raised
38 ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'] = nil
39 Facebooker.instance_variable_set('@facebooker_configuration', nil)
40 flexmock(File).should_receive(:read).with(File.expand_path("~/.facebookerrc")).once.and_return {raise Errno::ENOENT, "No such file"}
41 assert_raises(Facebooker::Session::ConfigurationMissing) {
42 Facebooker::Session.api_key
46 def test_marshal_stores_api_key
47 data = Marshal.dump(@session)
48 loaded_session = Marshal.load(data)
49 assert_equal 'whatever', loaded_session.instance_variable_get("@api_key")
52 def test_marshal_stores_secret_key
53 data = Marshal.dump(@session)
54 loaded_session = Marshal.load(data)
55 assert_equal 'doesnotmatterintest', loaded_session.instance_variable_get("@secret_key")
58 def test_configuration_file_path_can_be_set_explicitly
59 Facebooker::Session.configuration_file_path = '/tmp/foo'
60 assert_equal('/tmp/foo', Facebooker::Session.configuration_file_path)
63 def test_session_can_be_secured_with_existing_values
64 session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
65 session.secure_with!("a session key", "123456", Time.now.to_i + 60)
66 assert(session.secured?)
67 assert_equal 'a session key', session.session_key
68 assert_equal 123456, session.user.to_i
71 def test_session_can_be_secured_with_existing_values_and_a_nil_uid
72 flexmock(session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY']))
73 session.should_receive(:post).with('facebook.users.getLoggedInUser', :session_key => 'a session key').returns(321)
74 session.secure_with!("a session key", nil, Time.now.to_i + 60)
75 assert(session.secured?)
76 assert_equal 'a session key', session.session_key
77 assert_equal 321, session.user.to_i
80 # The Facebook API for this is hideous. Oh well.
81 def test_can_ask_session_to_check_friendship_between_pairs_of_users
82 @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
83 mock_http = establish_session
84 mock_http.should_receive(:post_form).and_return(example_check_friendship_xml).once.ordered(:posts)
85 assert_equal({[222332, 222333] => true, [1240077, 1240079] => false}, @session.check_friendship([[222332, 222333], [1240077, 1240079]]))
88 def test_facebook_can_claim_ignorance_as_to_friend_relationships
89 mock_http = establish_session
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]]))
94 def test_can_query_with_fql
95 @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
96 expect_http_posts_with_responses(example_fql_for_multiple_photos_xml)
97 response = @session.fql_query('Lets be frank. We are not testing the query here')
98 assert_kind_of(Facebooker::Photo, response.first)
101 def test_anonymous_fql_results_get_put_in_a_positioned_array_on_the_model
102 @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
103 expect_http_posts_with_responses(example_fql_for_multiple_photos_with_anon_xml)
104 response = @session.fql_query('Lets be frank. We are not testing the query here')
105 assert_kind_of(Facebooker::Photo, response.first)
106 response.each do |photo|
107 assert_equal(['first', 'second'], photo.anonymous_fields)
110 def test_no_results_returns_empty_array
111 @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
112 expect_http_posts_with_responses(no_results_fql)
113 response = @session.fql_query('Lets be frank. We are not testing the query here')
114 assert_equal [],response
117 def test_can_fql_query_for_event_members
118 @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
119 expect_http_posts_with_responses(example_fql_query_event_members_xml)
120 response = @session.fql_query("DOES NOT REALLY MATTER FOR TEST")
121 assert_kind_of(Facebooker::Event::Attendance, response.first)
122 assert_equal('attending', response.first.rsvp_status)
125 def test_can_query_for_event_members
126 expect_http_posts_with_responses(example_event_members_xml)
127 event_attendances = @session.event_members(69)
128 assert_equal Facebooker::Event::Attendance, event_attendances.first.class
129 assert_equal 'attending', event_attendances.first.rsvp_status
130 assert_equal(["1240077", "222332", "222333", "222335", "222336"], event_attendances.map{|ea| ea.uid}.sort)
131 assert_equal 5, event_attendances.size
134 def test_can_query_for_events
135 expect_http_posts_with_responses(example_events_get_xml)
136 events = @session.events
137 assert_equal 'Technology Tasting', events.first.name
140 def test_can_query_for_groups
141 expect_http_posts_with_responses(example_groups_get_xml)
142 groups = @session.user.groups
143 assert_equal 'Donald Knuth Is My Homeboy', groups.first.name
146 def test_can_query_for_group_memberships
147 expect_http_posts_with_responses(example_group_members_xml)
148 example_group = Facebooker::Group.new({:gid => 123, :session => @session})
149 group_memberships = example_group.memberships
150 assert_equal('officers', group_memberships.last.position)
151 assert_equal(123, group_memberships.last.gid)
152 assert_equal(1240078, example_group.members.last.id)
155 def test_can_fql_query_for_users_and_pictures
156 @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
157 mock_http = establish_session
158 mock_http.should_receive(:post_form).and_return(example_fql_for_multiple_users_and_pics).once.ordered(:posts)
159 response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')
160 assert_kind_of Array, response
161 assert_kind_of Facebooker::User, response.first
162 assert_equal "Ari Steinberg", response.first.name
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
175 def test_can_send_notification_with_object
176 @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
177 @session.expects(:post).with('facebook.notifications.send',{:to_ids=>"1",:notification=>"a",:type=>"user_to_user"},true)
178 @session.send(:instance_variable_set,"@uid",3)
179 user=flexmock("user")
180 user.should_receive(:facebook_id).and_return("1").once
181 @session.send_notification([user],"a")
183 def test_can_send_notification_with_string
184 @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
185 @session.send(:instance_variable_set,"@uid",3)
186 @session.expects(:post).with('facebook.notifications.send',{:to_ids=>"1",:notification=>"a", :type=>"user_to_user"},true)
187 @session.send_notification(["1"],"a")
190 def test_can_send_announcement_notification
191 @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
192 @session.expects(:post).with('facebook.notifications.send',{:to_ids=>"1",:notification=>"a", :type=>"app_to_user"},false)
193 @session.send_notification(["1"],"a")
196 def test_can_register_template_bundle
197 expect_http_posts_with_responses(example_register_template_bundle_return_xml)
198 @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
199 assert_equal 17876842716, @session.register_template_bundle("{*actor*} did something")
202 def test_can_register_template_bundle_with_action_links
203 expect_http_posts_with_responses(example_register_template_bundle_return_xml)
204 @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
205 assert_equal 17876842716, @session.register_template_bundle("{*actor*} did something",nil,nil,[{:text=>"text",:href=>"href"}])
207 def test_can_publish_user_action
208 expect_http_posts_with_responses(publish_user_action_return_xml)
209 @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
210 assert @session.publish_user_action(17876842716,{})
213 def test_logs_api_calls
214 call_name = 'sample.api.call'
215 params = { :param1 => true, :param2 => 'value' }
216 flexmock(Facebooker::Logging, :Logging).should_receive(:log_fb_api).once.with(
217 call_name, params, Proc)
218 @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
219 @session.post(call_name, params)
222 def test_requests_inside_batch_are_added_to_batch
223 @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
224 @session.send(:service).expects(:post).once
226 @session.send_notification(["1"],"a")
227 @session.send_notification(["1"],"a")
232 def test_parses_batch_response
233 @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
234 expect_http_posts_with_responses(example_batch_run_xml)
236 @fql_response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')
238 assert_kind_of(Facebooker::Event::Attendance, @fql_response.first)
239 assert_equal('attending', @fql_response.first.rsvp_status)
241 def test_parses_batch_response_sets_exception
242 @session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
243 expect_http_posts_with_responses(example_batch_run_xml)
244 Facebooker::FqlQuery.expects(:process).raises(NoMethodError.new)
247 @fql_response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')
249 assert_raises(NoMethodError) {
254 def test_can_set_and_get_current_batch
255 Facebooker::BatchRun.current_batch=4
256 assert_equal 4,Facebooker::BatchRun.current_batch
259 def test_can_get_stanard_info
260 expect_http_posts_with_responses(standard_info_xml)
261 result = @session.users_standard([4])
262 assert_equal "Mike Mangino",result.first.name
265 def test_can_query_for_pages
266 expect_http_posts_with_responses(example_pages_xml)
267 example_page = Facebooker::Page.new(
268 :page_id => 4846711747,
269 :name => "Kronos Quartet",
270 :website => "http://www.kronosquartet.org",
271 :company_overview => "",
272 :session => @session)
273 pages = @session.pages(:fields => %w[ page_id name website company_overview ])
275 assert_equal 1, pages.size
278 assert_equal "4846711747", page.page_id
279 assert_equal "Kronos Quartet", page.name
280 assert_equal "http://www.kronosquartet.org", page.website
282 # TODO we really need a way to differentiate between hash/list and text attributes
283 # assert_equal({}, page.company_overview)
285 # sakkaoui : as a fix to the parser, I replace empty text node by "" instead of {}
286 # we have child.attributes['list'] == 'true' that let us know that we have a hash/list.
287 assert_equal("", page.company_overview)
290 assert_equal false, genre.dance
291 assert_equal true, genre.party
296 def example_fql_multiquery_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">
302 <results list="true">
304 <name>Ari Steinberg</name>
306 <rsvp_status xsi:nil="true"/>
312 <results list="true">
314 <name>Lisa Petrovskaia</name>
315 <pic xsi:nil="true"/>
319 </fql_multiquery_response>
323 def example_groups_get_xml
325 <?xml version="1.0" encoding="UTF-8"?>
326 <groups_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">
328 <gid>2206609142</gid>
329 <name>Donald Knuth Is My Homeboy</name>
331 <description>Donald Ervin Knuth (born January 10, 1938) is a renowned computer scientist and professor emeritus at Stanford University.
333 Knuth is best known as the author of the multi-volume The Art of Computer Programming, one of the most highly respected references in the computer science field. He practically created the field of rigorous analysis of algorithms, and made many seminal contributions to several branches of theoretical computer science. He is also the creator of the TeX typesetting system and of the METAFONT font design system, and pioneered the concept of literate programming.
335 That's how he ROLLS, y0.</description>
336 <group_type>Just for Fun</group_type>
337 <group_subtype>Fan Clubs</group_subtype>
339 <pic>http://photos-142.facebook.com/ip006/object/543/95/s2206609142_32530.jpg</pic>
340 <pic_big>http://photos-142.facebook.com/ip006/object/543/95/n2206609142_32530.jpg</pic_big>
341 <pic_small>http://photos-142.facebook.com/ip006/object/543/95/t2206609142_32530.jpg</pic_small>
342 <creator>1240077</creator>
343 <update_time>1156543965</update_time>
350 <country>United States</country>
353 </groups_get_response>
357 def example_events_get_xml
359 <?xml version="1.0" encoding="UTF-8"?>
360 <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">
362 <eid>1037629024</eid>
363 <name>Technology Tasting</name>
364 <tagline>Who said Engineering can't be delicious?</tagline>
366 <pic>http://photos-628.facebook.com/ip006/object/1345/48/s1037629024_30775.jpg</pic>
367 <pic_big>http://photos-628.facebook.com/ip006/object/1345/48/n1037629024_30775.jpg</pic_big>
368 <pic_small>http://photos-628.facebook.com/ip006/object/1345/48/t1037629024_30775.jpg</pic_small>
369 <host>Facebook</host>
370 <description>Facebook will be hosting technology thought leaders and avid software engineers for a social evening of technology tasting. We invite you to connect with some of our newest technologies and innovative people over hors d'oeuvres and wine. Come share ideas, ask questions, and challenge existing technology paradigms in the spirit of the open source community.</description>
371 <event_type>Party</event_type>
372 <event_subtype>Cocktail Party</event_subtype>
373 <start_time>1172107800</start_time>
374 <end_time>1172115000</end_time>
375 <creator>1078</creator>
376 <update_time>1170096157</update_time>
377 <location>Facebook's New Office</location>
379 <city>Palo Alto</city>
381 <country>United States</country>
384 </events_get_response>
388 def example_fql_query_event_members_xml
390 <?xml version="1.0" encoding="UTF-8"?>
391 <fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true">
394 <eid>2454827764</eid>
395 <rsvp_status>attending</rsvp_status>
399 <eid>2454827764</eid>
400 <rsvp_status>declined</rsvp_status>
402 </fql_query_response>
405 def example_check_friendship_xml
407 <?xml version="1.0" encoding="UTF-8"?>
408 <friends_areFriends_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">
412 <are_friends>1</are_friends>
417 <are_friends>0</are_friends>
419 </friends_areFriends_response>
423 def example_check_friendship_with_unknown_result
425 <?xml version="1.0" encoding="UTF-8"?>
426 <friends_areFriends_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">
430 <are_friends xsi:nil="true"/>
432 </friends_areFriends_response>
436 def example_fql_for_multiple_users_and_pics
438 <?xml version="1.0" encoding="UTF-8"?>
439 <fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true">
441 <name>Ari Steinberg</name>
442 <pic>http://profile.ak.facebook.com/profile2/1805/47/s211031_26434.jpg</pic>
445 <name>Ruchi Sanghvi</name>
446 <pic>http://profile.ak.facebook.com/v52/870/125/s4801660_2498.jpg</pic>
448 </fql_query_response>
452 def example_fql_for_multiple_photos_xml
454 <?xml version="1.0" encoding="UTF-8"?>
455 <fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true">
457 <src>http://photos-c.ak.facebook.com/photos-ak-sf2p/v108/212/118/22700225/s22700225_30345986_2713.jpg</src>
458 <caption>Nottttt. get ready for some museumz</caption>
459 <caption>Nottttt. get ready for some museumz</caption>
462 <src>http://photos-c.ak.facebook.com/photos-ak-sf2p/v77/74/112/22701786/s22701786_30324934_7816.jpg</src>
463 <caption>Rooftop barbecues make me act funny</caption>
464 <caption>Rooftop barbecues make me act funny</caption>
467 <src>http://photos-c.ak.facebook.com/photos-ak-sctm/v96/154/56/22700188/s22700188_30321538_17.jpg</src>
468 <caption>An epic shot of Patrick getting ready for a run to second.</caption>
469 <caption>An epic shot of Patrick getting ready for a run to second.</caption>
471 </fql_query_response>
475 def example_fql_for_multiple_photos_with_anon_xml
477 <?xml version="1.0" encoding="UTF-8"?>
478 <fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true">
480 <src>http://photos-c.ak.facebook.com/photos-ak-sf2p/v108/212/118/22700225/s22700225_30345986_2713.jpg</src>
481 <caption>Nottttt. get ready for some museumz</caption>
482 <caption>Nottttt. get ready for some museumz</caption>
487 <src>http://photos-c.ak.facebook.com/photos-ak-sf2p/v77/74/112/22701786/s22701786_30324934_7816.jpg</src>
488 <caption>Rooftop barbecues make me act funny</caption>
489 <caption>Rooftop barbecues make me act funny</caption>
494 <src>http://photos-c.ak.facebook.com/photos-ak-sctm/v96/154/56/22700188/s22700188_30321538_17.jpg</src>
495 <caption>An epic shot of Patrick getting ready for a run to second.</caption>
496 <caption>An epic shot of Patrick getting ready for a run to second.</caption>
500 </fql_query_response>
506 <?xml version="1.0" encoding="UTF-8"?>
507 <fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true">
508 </fql_query_response>
513 def example_group_members_xml
515 <?xml version="1.0" encoding="UTF-8"?>
516 <groups_getMembers_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">
517 <members list="true">
527 <officers list="true">
530 <not_replied list="true"/>
531 </groups_getMembers_response>
535 def example_batch_run_xml
537 <?xml version="1.0" encoding="UTF-8"?>
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">
539 <batch_run_response_elt>
540 #{CGI.escapeHTML(example_fql_query_event_members_xml)}
541 </batch_run_response_elt>
542 </batch_run_response>
546 def example_event_members_xml
548 <?xml version="1.0" encoding="UTF-8"?>
549 <events_getMembers_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">
550 <attending list="true">
557 <declined list="true"/>
558 <not_replied list="true">
562 </events_getMembers_response>
566 def example_register_template_bundle_return_xml
568 <?xml version="1.0" encoding="UTF-8"?>
569 <feed_registerTemplateBundle_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/">
571 </feed_registerTemplateBundle_response>
575 def example_pages_xml
577 <?xml version="1.0" encoding="UTF-8"?>
578 <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">
580 <page_id>4846711747</page_id>
581 <name>Kronos Quartet</name>
582 <website>http://www.kronosquartet.org</website>
589 </pages_getInfo_response>
593 def publish_user_action_return_xml
595 <?xml version="1.0" encoding="UTF-8"?>
596 <feed_publishUserAction_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">
597 <feed_publishUserAction_response_elt>1</feed_publishUserAction_response_elt>
598 </feed_publishUserAction_response>
602 def standard_info_xml
604 <?xml version="1.0" encoding="UTF-8"?>
605 <?xml version="1.0" encoding="UTF-8"?>
607 <users_getStandardInfo_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">
610 <name>Mike Mangino</name>
611 </standard_user_info>
612 </users_getStandardInfo_response>
617 class PostMethodTest < Test::Unit::TestCase
620 Facebooker.use_curl = true
621 Facebooker::Parser.stubs(:parse)
622 @uri = URI.parse("http://api.facebook.com/api")
623 @service = Facebooker::Service.new("a","b","c")
624 @service.stubs("url").returns(@uri)
628 Facebooker.use_curl = false
631 def test_use_curl_makes_post_with_curl
632 @service.expects(:post_form_with_curl).with(@uri,{:method=>"a"})
633 @service.post(:method=>"a")
636 def test_use_curl_makes_post_file_use_curl_with_multipart
637 @service.expects(:post_form_with_curl).with(@uri,{:method=>"a"},true)
638 @service.post_file(:method=>"a")
642 class CanvasSessionTest < Test::Unit::TestCase
644 ENV['FACEBOOK_API_KEY'] = '1234567'
645 ENV['FACEBOOK_SECRET_KEY'] = '7654321'
648 def test_login_url_will_display_callback_url_in_canvas
649 session = Facebooker::CanvasSession.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
650 assert_equal("http://www.facebook.com/login.php?api_key=1234567&v=1.0&canvas=true", session.login_url)