require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
require 'active_support'
class Facebooker::SessionTest < Test::Unit::TestCase
def setup
ENV['FACEBOOK_API_KEY'] = '1234567'
ENV['FACEBOOK_SECRET_KEY'] = '7654321'
Facebooker.current_adapter = nil
@session = Facebooker::Session.create('whatever', 'doesnotmatterintest')
Facebooker.use_curl=false
end
def teardown
Facebooker::Session.configuration_file_path = nil
super
end
def test_install_url_escapes_optional_next_parameter
session = Facebooker::CanvasSession.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
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"))
end
def test_permission_url_returns_correct_url_and_parameters
fb_url = "http://www.facebook.com/connect/prompt_permissions.php?api_key=#{ENV['FACEBOOK_API_KEY']}&v=1.0&next=next_url&ext_perm=publish_stream,email"
url = Facebooker::Session.new(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY']).connect_permission_url('publish_stream,email', {:next => 'next_url'})
assert_equal url, fb_url
end
def test_login_url_skips_all_parameters_when_not_passed_or_false
session = Facebooker::Session.new(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
url = session.login_url({:fbconnect => false})
expected_url = Facebooker.login_url_base
assert_equal url, expected_url
end
def test_login_url_adds_all_parameters_when_passed
login_options = {:skipcookie => true,
:hide_checkbox => true,
:canvas => true,
:fbconnect => true,
:req_perms => 'publish_stream',
:next => 'http://example.com'}
session = Facebooker::Session.new(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
url = session.login_url(login_options)
expected_url = "#{Facebooker.login_url_base}&next=#{CGI.escape(login_options[:next])}&hide_checkbox=true&canvas=true&fbconnect=true&req_perms=publish_stream"
assert_equal url, expected_url
end
def test_can_get_api_and_secret_key_from_environment
assert_equal('1234567', Facebooker::Session.api_key)
assert_equal('7654321', Facebooker::Session.secret_key)
end
def test_if_keys_are_not_available_via_environment_then_they_are_gotten_from_a_file
ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'] = nil
Facebooker.instance_variable_set('@facebooker_configuration', nil)
flexmock(File).should_receive(:read).with(File.expand_path("~/.facebookerrc")).once.and_return('{:api => "foo"}')
assert_equal('foo', Facebooker::Session.api_key)
end
def test_if_environment_and_file_fail_to_match_then_an_exception_is_raised
ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'] = nil
Facebooker.instance_variable_set('@facebooker_configuration', nil)
flexmock(File).should_receive(:read).with(File.expand_path("~/.facebookerrc")).once.and_return {raise Errno::ENOENT, "No such file"}
assert_raises(Facebooker::Session::ConfigurationMissing) {
Facebooker::Session.api_key
}
end
def test_marshal_stores_api_key
data = Marshal.dump(@session)
loaded_session = Marshal.load(data)
assert_equal 'whatever', loaded_session.instance_variable_get("@api_key")
end
def test_marshal_stores_secret_key
data = Marshal.dump(@session)
loaded_session = Marshal.load(data)
assert_equal 'doesnotmatterintest', loaded_session.instance_variable_get("@secret_key")
end
def test_configuration_file_path_can_be_set_explicitly
Facebooker::Session.configuration_file_path = '/tmp/foo'
assert_equal('/tmp/foo', Facebooker::Session.configuration_file_path)
end
def test_session_can_be_secured_with_existing_values
session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
session.secure_with!("a session key", "123456", Time.now.to_i + 60)
assert(session.secured?)
assert_equal 'a session key', session.session_key
assert_equal 123456, session.user.to_i
end
def test_session_can_be_secured_with_existing_values_and_a_nil_uid
flexmock(session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY']))
session.should_receive(:post).with('facebook.users.getLoggedInUser', :session_key => 'a session key').returns(321)
session.secure_with!("a session key", nil, Time.now.to_i + 60)
assert(session.secured?)
assert_equal 'a session key', session.session_key
assert_equal 321, session.user.to_i
end
# The Facebook API for this is hideous. Oh well.
def test_can_ask_session_to_check_friendship_between_pairs_of_users
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
mock_http = establish_session
mock_http.should_receive(:post_form).and_return(example_check_friendship_xml).once.ordered(:posts)
assert_equal({[222332, 222333] => true, [1240077, 1240079] => false}, @session.check_friendship([[222332, 222333], [1240077, 1240079]]))
end
def test_facebook_can_claim_ignorance_as_to_friend_relationships
mock_http = establish_session
mock_http.should_receive(:post_form).and_return(example_check_friendship_with_unknown_result).once.ordered(:posts)
assert_equal({[1240077, 1240079] => nil}, @session.check_friendship([[1240077, 1240079]]))
end
def test_can_query_with_fql
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
expect_http_posts_with_responses(example_fql_for_multiple_photos_xml)
response = @session.fql_query('Lets be frank. We are not testing the query here')
assert_kind_of(Facebooker::Photo, response.first)
end
def test_anonymous_fql_results_get_put_in_a_positioned_array_on_the_model
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
expect_http_posts_with_responses(example_fql_for_multiple_photos_with_anon_xml)
response = @session.fql_query('Lets be frank. We are not testing the query here')
assert_kind_of(Facebooker::Photo, response.first)
response.each do |photo|
assert_equal(['first', 'second'], photo.anonymous_fields)
end
end
def test_no_results_returns_empty_array
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
expect_http_posts_with_responses(no_results_fql)
response = @session.fql_query('Lets be frank. We are not testing the query here')
assert_equal [],response
end
def test_can_fql_query_for_event_members
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
expect_http_posts_with_responses(example_fql_query_event_members_xml)
response = @session.fql_query("DOES NOT REALLY MATTER FOR TEST")
assert_kind_of(Facebooker::Event::Attendance, response.first)
assert_equal('attending', response.first.rsvp_status)
end
def test_can_fql_query_for_events
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
expect_http_posts_with_responses(example_fql_query_events_xml)
response = @session.fql_query("DOES NOT REALLY MATTER FOR TEST")
assert_kind_of(Facebooker::Event, response.first)
assert_equal('Technology Tasting', response.first.name)
end
def test_can_fql_query_for_albums
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
expect_http_posts_with_responses(example_fql_query_albums_xml)
response = @session.fql_query("DOES NOT REALLY MATTER FOR TEST")
assert_kind_of(Facebooker::Album, response.first)
assert_equal('Films you will never see', response.first.name)
end
def test_can_query_for_event_members
expect_http_posts_with_responses(example_event_members_xml)
event_attendances = @session.event_members(69)
assert_equal Facebooker::Event::Attendance, event_attendances.first.class
assert_equal 'attending', event_attendances.first.rsvp_status
assert_equal(["1240077", "222332", "222333", "222335", "222336"], event_attendances.map{|ea| ea.uid}.sort)
assert_equal 5, event_attendances.size
end
def test_query_for_event_members_caching_honors_params
@session.expects(:post).returns(["1"])
assert_equal ["1"], @session.event_members(100)
@session.expects(:post).returns(["2"])
assert_equal ["2"],@session.event_members(200)
@session.expects(:post).never
assert_equal ["1"],@session.event_members(100)
end
def test_can_create_events
mock_http = establish_session
mock_http.should_receive(:post_multipart_form).and_return(example_event_create_xml).once
event_id = @session.create_event(:name => 'foo', :category => 'bar')
assert_equal '34444349712', event_id
end
def test_can_create_events_with_time_zones
mock_http = establish_session
mock_session = flexmock(@session)
# Start time is Jan 1, 2012 at 12:30pm EST
# This should be sent to Facebook as 12:30pm PST, or 1325449800 in Epoch time
start_time = ActiveSupport::TimeZone["Eastern Time (US & Canada)"].parse("2012-01-01 12:30:00")
# End time is July 4, 2012 at 3:00pm CDT
# Should be sent to Facebook as 3:00pm PDT, or 1341439200 in Epoch time
end_time = ActiveSupport::TimeZone["Central Time (US & Canada)"].parse("2012-07-04 15:00:00")
expected_info = {
'name' => 'foo',
'category' => 'bar',
'start_time' => 1325449800,
'end_time' => 1341439200
}.to_json
mock_session.should_receive(:post_file).once.with('facebook.events.create', {:event_info => expected_info, nil => nil}).and_return(example_event_create_xml).once
mock_session.create_event('name' => 'foo', 'category' => 'bar', :start_time => start_time, :end_time => end_time)
end
def test_can_cancel_events
expect_http_posts_with_responses(example_event_cancel_xml)
assert @session.cancel_event("12345", :cancel_message => "It's raining")
end
def test_can_query_for_events
expect_http_posts_with_responses(example_events_get_xml)
events = @session.events
assert_equal 'Technology Tasting', events.first.name
end
def test_query_for_events_caching_honors_params
@session.expects(:post).returns([{:eid=>1}])
assert_equal 1, @session.events.first[:eid]
@session.expects(:post).returns([{:eid=>2}])
assert_equal 2,@session.events(:start_time=>1.day.ago).first[:eid]
@session.expects(:post).never
assert_equal 1,@session.events.first[:eid]
end
def test_can_query_for_groups
expect_http_posts_with_responses(example_groups_get_xml)
groups = @session.user.groups
assert_equal 'Donald Knuth Is My Homeboy', groups.first.name
end
def test_can_query_for_group_memberships
expect_http_posts_with_responses(example_group_members_xml)
example_group = Facebooker::Group.new({:gid => 123, :session => @session})
group_memberships = example_group.memberships
assert_equal('officers', group_memberships.last.position)
assert_equal(123, group_memberships.last.gid)
assert_equal(1240078, example_group.members.last.id)
end
def test_can_fql_query_for_users_and_pictures
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
mock_http = establish_session
mock_http.should_receive(:post_form).and_return(example_fql_for_multiple_users_and_pics).once.ordered(:posts)
response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')
assert_kind_of Array, response
assert_kind_of Facebooker::User, response.first
assert_equal "Ari Steinberg", response.first.name
end
def test_can_fql_multiquery_for_users_and_pictures
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
mock_http = establish_session
mock_http.should_receive(:post_form).and_return(example_fql_multiquery_xml).once.ordered(:posts)
response = @session.fql_multiquery({:query => 'SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660'})
assert_kind_of Array, response["query1"]
assert_kind_of Facebooker::User, response["query1"].first
assert_equal "Ari Steinberg", response["query1"].first.name
end
def test_can_send_notification_with_object
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
@session.expects(:post).with('facebook.notifications.send',{:to_ids=>"1",:notification=>"a",:type=>"user_to_user"},true)
@session.send(:instance_variable_set,"@uid",3)
user=flexmock("user")
user.should_receive(:facebook_id).and_return("1").once
@session.send_notification([user],"a")
end
def test_can_send_notification_with_string
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
@session.send(:instance_variable_set,"@uid",3)
@session.expects(:post).with('facebook.notifications.send',{:to_ids=>"1",:notification=>"a", :type=>"user_to_user"},true)
@session.send_notification(["1"],"a")
end
def test_can_send_announcement_notification
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
@session.expects(:post).with('facebook.notifications.send',{:to_ids=>"1",:notification=>"a", :type=>"app_to_user"},false)
@session.send_notification(["1"],"a")
end
def test_can_register_template_bundle
expect_http_posts_with_responses(example_register_template_bundle_return_xml)
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
assert_equal 17876842716, @session.register_template_bundle("{*actor*} did something")
end
def test_can_register_template_bundle_with_action_links
expect_http_posts_with_responses(example_register_template_bundle_return_xml)
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
assert_equal 17876842716, @session.register_template_bundle("{*actor*} did something",nil,nil,[{:text=>"text",:href=>"href"}])
end
def test_can_register_template_bundle_with_short_story
one_line = "{*actor*} did something"
short_story = { :title => 'title', :body => 'body' }
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
@session.expects(:post).with(
'facebook.feed.registerTemplateBundle',
{:one_line_story_templates => [one_line].to_json, :short_story_templates => [short_story].to_json},
false
)
@session.register_template_bundle(one_line, short_story)
end
def test_can_register_template_bundle_with_short_story_for_several_templates
one_line = ["{*actor*} did something", "{*actor*} did something again"]
short_story = [{ :title => 'title', :body => 'body' }, { :title => 'title2', :body => 'body2' }]
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
@session.expects(:post).with(
'facebook.feed.registerTemplateBundle',
{:one_line_story_templates => one_line.to_json, :short_story_templates => short_story.to_json},
false
)
@session.register_template_bundle(one_line, short_story)
end
def test_can_register_template_bundle_with_full_story_for_several_templates
one_line = ["{*actor*} did something", "{*actor*} did something again"]
short_story = [{ :title => 'title', :body => 'body' }, { :title => 'title2', :body => 'body2' }]
full_story = { :title => 'title', :body => 'body' }
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
@session.expects(:post).with(
'facebook.feed.registerTemplateBundle',
{:one_line_story_templates => one_line.to_json, :short_story_templates => short_story.to_json, :full_story_template => full_story.to_json},
false
)
@session.register_template_bundle(one_line, short_story, full_story)
end
def test_can_deactivate_template_bundle_by_id
@session = Facebooker::Session.create(ENV['FACBEOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
@session.expects(:post).with(
'facebook.feed.deactivateTemplateBundleByID',
{:template_bundle_id => '999'},
false
)
@session.deactivate_template_bundle_by_id(999)
end
def test_can_publish_user_action
expect_http_posts_with_responses(publish_user_action_return_xml)
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
assert @session.publish_user_action(17876842716,{})
end
def test_logs_api_calls
call_name = 'sample.api.call'
params = { :param1 => true, :param2 => 'value' }
flexmock(Facebooker::Logging, :Logging).should_receive(:log_fb_api).once.with(
call_name, params, Proc)
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
@session.post(call_name, params)
end
def test_requests_inside_batch_are_added_to_batch
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
@session.send(:service).expects(:post).once
@session.batch do
@session.send_notification(["1"],"a")
@session.send_notification(["1"],"a")
end
end
def test_parses_batch_response
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
expect_http_posts_with_responses(example_batch_run_xml)
@session.batch do
@fql_response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')
end
assert_kind_of(Facebooker::Event::Attendance, @fql_response.first)
assert_equal('attending', @fql_response.first.rsvp_status)
end
def test_parses_batch_response_with_escaped_chars
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
expect_http_posts_with_responses(example_batch_run_with_escaped_chars_xml)
@session.batch do
@response = @session.events(:start_time => Time.now.to_i)
end
assert_kind_of(Facebooker::Event, @response.first)
assert_equal('Wolf & Crow', @response.first.name)
end
def test_parses_batch_response_sets_exception
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
expect_http_posts_with_responses(example_batch_run_xml)
Facebooker::FqlQuery.expects(:process).raises(NoMethodError.new)
@session.batch do
@fql_response = @session.fql_query('SELECT name, pic FROM user WHERE uid=211031 OR uid=4801660')
end
assert_raises(NoMethodError) {
@fql_response.first
}
end
def test_can_set_and_get_current_batch
Facebooker::BatchRun.current_batch=4
assert_equal 4,Facebooker::BatchRun.current_batch
end
def test_can_get_stanard_info
expect_http_posts_with_responses(standard_info_xml)
result = @session.users_standard([4])
assert_equal "Mike Mangino",result.first.name
end
def test_can_query_for_pages
expect_http_posts_with_responses(example_pages_xml)
example_page = Facebooker::Page.new(
:page_id => 4846711747,
:name => "Kronos Quartet",
:website => "http://www.kronosquartet.org",
:company_overview => "",
:session => @session)
pages = @session.pages(:fields => %w[ page_id name website company_overview ])
assert_equal 1, pages.size
page = pages.first
assert_equal "4846711747", page.page_id
assert_equal "Kronos Quartet", page.name
assert_equal "http://www.kronosquartet.org", page.website
# TODO we really need a way to differentiate between hash/list and text attributes
# assert_equal({}, page.company_overview)
# sakkaoui : as a fix to the parser, I replace empty text node by "" instead of {}
# we have child.attributes['list'] == 'true' that let us know that we have a hash/list.
assert_equal("", page.company_overview)
genre = page.genre
assert_equal false, genre.dance
assert_equal true, genre.party
end
private
def example_fql_multiquery_xml
<<-XML
query1Ari Steinberg46903192query2Lisa Petrovskaia
XML
end
def example_groups_get_xml
<<-XML
2206609142Donald Knuth Is My Homeboy0Donald Ervin Knuth (born January 10, 1938) is a renowned computer scientist and professor emeritus at Stanford University.
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.
That's how he ROLLS, y0.Just for FunFan Clubshttp://photos-142.facebook.com/ip006/object/543/95/s2206609142_32530.jpghttp://photos-142.facebook.com/ip006/object/543/95/n2206609142_32530.jpghttp://photos-142.facebook.com/ip006/object/543/95/t2206609142_32530.jpg12400771156543965CAUnited States
XML
end
def example_event_create_xml
<<-XML
34444349712
XML
end
def example_event_cancel_xml
<<-XML
1
XML
end
def example_events_get_xml
<<-XML
1037629024Technology TastingWho said Engineering can't be delicious?12409987http://photos-628.facebook.com/ip006/object/1345/48/s1037629024_30775.jpghttp://photos-628.facebook.com/ip006/object/1345/48/n1037629024_30775.jpghttp://photos-628.facebook.com/ip006/object/1345/48/t1037629024_30775.jpgFacebookFacebook 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.PartyCocktail Party1172107800117211500010781170096157Facebook's New OfficePalo AltoCAUnited States
XML
end
def example_fql_query_event_members_xml
<<-XML
5179618782454827764attending7449611102454827764declined
XML
end
def example_fql_query_events_xml
<<-XML
1037629024Technology TastingWho said Engineering can't be delicious?12409987http://photos-628.facebook.com/ip006/object/1345/48/s1037629024_30775.jpghttp://photos-628.facebook.com/ip006/object/1345/48/n1037629024_30775.jpghttp://photos-628.facebook.com/ip006/object/1345/48/t1037629024_30775.jpgFacebookFacebook 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.PartyCocktail Party1172107800117211500010781170096157Facebook's New Office156 University Ave.Palo AltoCAUnited States
XML
end
def example_fql_query_albums_xml
<<-XML
34595963571485345959916128128055Films you will never see11325531091132553363No I will not make out with youYork, PA
http://www.facebook.com/album.php?aid=2002205&id=8055
30friends1241834423
XML
end
def example_check_friendship_xml
<<-XML
2223322223331124007712400790
XML
end
def example_check_friendship_with_unknown_result
<<-XML
12400771240079
XML
end
def example_fql_for_multiple_users_and_pics
<<-XML
Ari Steinberghttp://profile.ak.facebook.com/profile2/1805/47/s211031_26434.jpgRuchi Sanghvihttp://profile.ak.facebook.com/v52/870/125/s4801660_2498.jpg
XML
end
def example_fql_for_multiple_photos_xml
<<-XML
http://photos-c.ak.facebook.com/photos-ak-sf2p/v108/212/118/22700225/s22700225_30345986_2713.jpg
An epic shot of Patrick getting ready for a run to second.
An epic shot of Patrick getting ready for a run to second.
XML
end
def example_fql_for_multiple_photos_with_anon_xml
<<-XML
http://photos-c.ak.facebook.com/photos-ak-sf2p/v108/212/118/22700225/s22700225_30345986_2713.jpg
An epic shot of Patrick getting ready for a run to second.
An epic shot of Patrick getting ready for a run to second.
firstsecond
XML
end
def no_results_fql
<<-XML
XML
end
def example_group_members_xml
<<-XML
1240077124007822233222233312400772223331240078
XML
end
def example_batch_run_xml
<<-XML
#{CGI.escapeHTML(example_fql_query_event_members_xml)}
XML
end
def example_batch_run_with_escaped_chars_xml
<<-XML
#{CGI.escapeHTML(event_with_amp_in_xml)}
XML
end
def event_with_amp_in_xml
<<-XML
1Wolf & Crow
XML
end
def example_event_members_xml
<<-XML
2223322223331240077222335222336
XML
end
def example_register_template_bundle_return_xml
<<-XML
17876842716
XML
end
def example_pages_xml
<<-XML
4846711747Kronos Quartethttp://www.kronosquartet.org01
XML
end
def publish_user_action_return_xml
<<-XML
1
XML
end
def standard_info_xml
<<-XML
12451752Mike Mangino
XML
end
end
class CanvasSessionTest < Test::Unit::TestCase
def setup
ENV['FACEBOOK_API_KEY'] = '1234567'
ENV['FACEBOOK_SECRET_KEY'] = '7654321'
end
def test_login_url_will_display_callback_url_in_canvas
session = Facebooker::CanvasSession.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
assert_equal("http://www.facebook.com/login.php?api_key=1234567&v=1.0&canvas=true", session.login_url)
end
end