test/facebooker/session_test.rb in taweili-facebooker-1.0.47 vs test/facebooker/session_test.rb in taweili-facebooker-1.0.50

- old
+ new

@@ -20,9 +20,36 @@ 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