mmangino-facebooker 1.0.13 → 1.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +1 -1
- data/lib/facebooker/admin.rb +14 -0
- data/lib/facebooker/model.rb +2 -2
- data/lib/facebooker/models/user.rb +2 -2
- data/lib/facebooker/parser.rb +22 -1
- data/lib/facebooker/rails/controller.rb +19 -9
- data/lib/facebooker/rails/helpers/fb_connect.rb +31 -2
- data/lib/facebooker/session.rb +5 -0
- data/lib/facebooker/version.rb +3 -3
- data/lib/facebooker.rb +1 -0
- data/test/facebook_admin_test.rb +26 -0
- data/test/facebooker_test.rb +24 -0
- data/test/model_test.rb +34 -0
- data/test/rails_integration_test.rb +66 -4
- metadata +2 -1
data/History.txt
CHANGED
data/lib/facebooker/admin.rb
CHANGED
@@ -18,6 +18,20 @@ module Facebooker
|
|
18
18
|
hash = JSON.parse(CGI.unescapeHTML(json))
|
19
19
|
@properties = ApplicationProperties.from_hash(hash)
|
20
20
|
end
|
21
|
+
|
22
|
+
# ** BETA ***
|
23
|
+
# +restrictions+: Hash of restrictions you want to set.
|
24
|
+
def set_restriction_info(restrictions)
|
25
|
+
restrictions = restrictions.respond_to?(:to_json) ? restrictions.to_json : restrictions
|
26
|
+
(@session.post 'facebook.admin.setRestrictionInfo', :restriction_str => restrictions) == '1'
|
27
|
+
end
|
28
|
+
|
29
|
+
# ** BETA ***
|
30
|
+
def get_restriction_info(*restrictions)
|
31
|
+
json = @session.post('facebook.admin.getRestrictionInfo')
|
32
|
+
hash = JSON.parse(CGI.unescapeHTML(json))
|
33
|
+
@restrictions = ApplicationRestrictions.from_hash(hash)
|
34
|
+
end
|
21
35
|
|
22
36
|
# Integration points include..
|
23
37
|
# :notifications_per_day, :requests_per_day, :emails_per_day, :email_disable_message_location
|
data/lib/facebooker/model.rb
CHANGED
@@ -119,10 +119,10 @@ module Facebooker
|
|
119
119
|
##
|
120
120
|
# Set model's attributes via Hash. Keys should map directly to the model's attribute names.
|
121
121
|
def populate_from_hash!(hash)
|
122
|
-
unless hash.empty?
|
122
|
+
unless hash.nil? || hash.empty?
|
123
123
|
hash.each do |key, value|
|
124
124
|
set_attr_method = "#{key}="
|
125
|
-
if respond_to?(set_attr_method)
|
125
|
+
if !value.nil? and respond_to?(set_attr_method)
|
126
126
|
self.__send__(set_attr_method, value)
|
127
127
|
else
|
128
128
|
Facebooker::Logging.log_info("**Warning**, Attempt to set non-attribute: #{key}",hash)
|
@@ -10,8 +10,8 @@ module Facebooker
|
|
10
10
|
include Model
|
11
11
|
attr_accessor :message, :time, :status_id
|
12
12
|
end
|
13
|
-
FIELDS = [:status, :political, :pic_small, :name, :quotes, :is_app_user, :tv, :profile_update_time, :meeting_sex, :hs_info, :timezone, :relationship_status, :hometown_location, :about_me, :wall_count, :significant_other_id, :pic_big, :music, :uid, :work_history, :sex, :religion, :notes_count, :activities, :pic_square, :movies, :has_added_app, :education_history, :birthday, :first_name, :meeting_for, :last_name, :interests, :current_location, :pic, :books, :affiliations, :locale, :profile_url, :proxied_email
|
14
|
-
STANDARD_FIELDS = [:uid, :first_name, :last_name, :name, :timezone, :birthday, :sex, :affiliations, :locale, :profile_url]
|
13
|
+
FIELDS = [:status, :political, :pic_small, :name, :quotes, :is_app_user, :tv, :profile_update_time, :meeting_sex, :hs_info, :timezone, :relationship_status, :hometown_location, :about_me, :wall_count, :significant_other_id, :pic_big, :music, :uid, :work_history, :sex, :religion, :notes_count, :activities, :pic_square, :movies, :has_added_app, :education_history, :birthday, :first_name, :meeting_for, :last_name, :interests, :current_location, :pic, :books, :affiliations, :locale, :profile_url, :proxied_email, :email_hashes, :allowed_restrictions]
|
14
|
+
STANDARD_FIELDS = [:uid, :first_name, :last_name, :name, :timezone, :birthday, :sex, :affiliations, :locale, :profile_url, :pic_square]
|
15
15
|
populating_attr_accessor *FIELDS
|
16
16
|
attr_reader :affiliations
|
17
17
|
populating_hash_settable_accessor :current_location, Location
|
data/lib/facebooker/parser.rb
CHANGED
@@ -144,6 +144,12 @@ module Facebooker
|
|
144
144
|
array_of_hashes(element('pages_getInfo_response', data), 'page')
|
145
145
|
end
|
146
146
|
end
|
147
|
+
|
148
|
+
class PagesIsFan < Parser#:nodoc:
|
149
|
+
def self.process(data)
|
150
|
+
element('pages_isFan_response', data).text_value == '1'
|
151
|
+
end
|
152
|
+
end
|
147
153
|
|
148
154
|
class PublishStoryToUser < Parser#:nodoc:
|
149
155
|
def self.process(data)
|
@@ -199,6 +205,18 @@ module Facebooker
|
|
199
205
|
end
|
200
206
|
end
|
201
207
|
|
208
|
+
class SetRestrictionInfo < Parser#:nodoc:
|
209
|
+
def self.process(data)
|
210
|
+
element('admin_setRestrictionInfo_response', data).text_value
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
class GetRestrictionInfo < Parser#:nodoc:
|
215
|
+
def self.process(data)
|
216
|
+
element('admin_getRestrictionInfo_response', data).text_value
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
202
220
|
class GetAllocation < Parser#:nodoc:
|
203
221
|
def self.process(data)
|
204
222
|
element('admin_getAllocation_response', data).text_value
|
@@ -484,7 +502,7 @@ module Facebooker
|
|
484
502
|
if response_element
|
485
503
|
hash = hashinate(response_element)
|
486
504
|
exception = EXCEPTIONS[Integer(hash['error_code'])] || StandardError
|
487
|
-
raise exception
|
505
|
+
raise exception, hash['error_msg']
|
488
506
|
end
|
489
507
|
end
|
490
508
|
end
|
@@ -501,6 +519,7 @@ module Facebooker
|
|
501
519
|
'facebook.users.hasAppPermission' => UserHasPermission,
|
502
520
|
'facebook.pages.isAdmin' => PagesIsAdmin,
|
503
521
|
'facebook.pages.getInfo' => PagesGetInfo,
|
522
|
+
'facebook.pages.isFan' => PagesIsFan,
|
504
523
|
'facebook.friends.get' => GetFriends,
|
505
524
|
'facebook.friends.getLists' => FriendListsGet,
|
506
525
|
'facebook.friends.areFriends' => AreFriends,
|
@@ -526,6 +545,8 @@ module Facebooker
|
|
526
545
|
'facebook.data.getCookies' => GetCookies,
|
527
546
|
'facebook.admin.setAppProperties' => SetAppProperties,
|
528
547
|
'facebook.admin.getAppProperties' => GetAppProperties,
|
548
|
+
'facebook.admin.setRestrictionInfo' => SetRestrictionInfo,
|
549
|
+
'facebook.admin.getRestrictionInfo' => GetRestrictionInfo,
|
529
550
|
'facebook.admin.getAllocation' => GetAllocation,
|
530
551
|
'facebook.batch.run' => BatchRun,
|
531
552
|
'facebook.fql.query' => FqlQuery,
|
@@ -6,7 +6,7 @@ module Facebooker
|
|
6
6
|
include Facebooker::Rails::ProfilePublisherExtensions
|
7
7
|
def self.included(controller)
|
8
8
|
controller.extend(ClassMethods)
|
9
|
-
controller.before_filter :set_adapter
|
9
|
+
#controller.before_filter :set_adapter <-- security hole noted by vchu
|
10
10
|
controller.before_filter :set_fbml_format
|
11
11
|
controller.helper_attr :facebook_session_parameters
|
12
12
|
controller.helper_method :request_comes_from_facebook?
|
@@ -21,16 +21,26 @@ module Facebooker
|
|
21
21
|
{:fb_sig_session_key=>params[:fb_sig_session_key]}
|
22
22
|
end
|
23
23
|
|
24
|
+
def create_facebook_session
|
25
|
+
secure_with_facebook_params! || secure_with_cookies! || secure_with_token!
|
26
|
+
end
|
24
27
|
|
25
28
|
def set_facebook_session
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
# first, see if we already have a session
|
30
|
+
session_set = session_already_secured?
|
31
|
+
# if not, see if we can load it from the environment
|
32
|
+
unless session_set
|
33
|
+
session_set = create_facebook_session
|
34
|
+
session[:facebook_session] = @facebook_session if session_set
|
31
35
|
end
|
36
|
+
if session_set
|
37
|
+
capture_facebook_friends_if_available!
|
38
|
+
Session.current = facebook_session
|
39
|
+
end
|
40
|
+
return session_set
|
32
41
|
end
|
33
42
|
|
43
|
+
|
34
44
|
def facebook_params
|
35
45
|
@facebook_params ||= verified_facebook_params
|
36
46
|
end
|
@@ -101,7 +111,7 @@ module Facebooker
|
|
101
111
|
|
102
112
|
@facebook_session = new_facebook_session
|
103
113
|
@facebook_session.secure_with!(parsed['session_key'],parsed['user'],parsed['expires'],parsed['ss'])
|
104
|
-
|
114
|
+
@facebook_session
|
105
115
|
end
|
106
116
|
|
107
117
|
def secure_with_token!
|
@@ -109,7 +119,7 @@ module Facebooker
|
|
109
119
|
@facebook_session = new_facebook_session
|
110
120
|
@facebook_session.auth_token = params['auth_token']
|
111
121
|
@facebook_session.secure!
|
112
|
-
|
122
|
+
@facebook_session
|
113
123
|
end
|
114
124
|
end
|
115
125
|
|
@@ -119,7 +129,7 @@ module Facebooker
|
|
119
129
|
if ['user', 'session_key'].all? {|element| facebook_params[element]}
|
120
130
|
@facebook_session = new_facebook_session
|
121
131
|
@facebook_session.secure_with!(facebook_params['session_key'], facebook_params['user'], facebook_params['expires'])
|
122
|
-
|
132
|
+
@facebook_session
|
123
133
|
end
|
124
134
|
end
|
125
135
|
|
@@ -11,27 +11,56 @@ module Facebooker
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
def init_fb_connect(*required_features)
|
14
|
+
def init_fb_connect(*required_features,&proc)
|
15
|
+
additions = ""
|
16
|
+
if block_given?
|
17
|
+
additions = capture(&proc)
|
18
|
+
end
|
15
19
|
init_string = "FB.Facebook.init('#{Facebooker.api_key}','/xd_receiver.html');"
|
16
20
|
unless required_features.blank?
|
17
21
|
init_string = <<-FBML
|
18
22
|
Element.observe(window,'load', function() {
|
19
23
|
FB_RequireFeatures(#{required_features.to_json}, function() {
|
20
24
|
#{init_string}
|
25
|
+
#{additions}
|
21
26
|
});
|
22
27
|
});
|
23
28
|
FBML
|
24
29
|
end
|
25
|
-
|
30
|
+
if block_given?
|
31
|
+
concat javascript_tag(init_string)
|
32
|
+
else
|
33
|
+
javascript_tag init_string
|
34
|
+
end
|
26
35
|
end
|
27
36
|
|
28
37
|
def fb_login_button(callback=nil)
|
29
38
|
content_tag("fb:login-button",nil,(callback.nil? ? {} : {:onlogin=>callback}))
|
30
39
|
end
|
40
|
+
def fb_login_and_redirect(url)
|
41
|
+
js = update_page do |page|
|
42
|
+
page.call "FB.Connect.logoutAndRedirect",url
|
43
|
+
end
|
44
|
+
content_tag("fb:login-button",nil,:onlogin=>js)
|
45
|
+
end
|
31
46
|
|
32
47
|
def fb_unconnected_friends_count
|
33
48
|
content_tag "fb:unconnected-friends-count",nil
|
34
49
|
end
|
50
|
+
|
51
|
+
def fb_logout_link(text,url)
|
52
|
+
js = update_page do |page|
|
53
|
+
page.call "FB.Connect.logoutAndRedirect",url
|
54
|
+
end
|
55
|
+
link_to_function text, js
|
56
|
+
end
|
57
|
+
|
58
|
+
def fb_user_action(action)
|
59
|
+
update_page do |page|
|
60
|
+
page.call "FB.Connect.showFeedDialog",action.template_id,action.data,action.target_ids,action.body_general,nil,"FB.RequireConnect.promptConnect"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
35
64
|
end
|
36
65
|
end
|
37
66
|
end
|
data/lib/facebooker/session.rb
CHANGED
@@ -234,6 +234,11 @@ module Facebooker
|
|
234
234
|
end
|
235
235
|
end
|
236
236
|
|
237
|
+
# Takes page_id and uid, returns true if uid is a fan of the page_id
|
238
|
+
def is_fan(page_id, uid)
|
239
|
+
post('facebook.pages.isFan', :page_id=>page_id, :uid=>uid)
|
240
|
+
end
|
241
|
+
|
237
242
|
#
|
238
243
|
# Returns a proxy object for handling calls to Facebook cached items
|
239
244
|
# such as images and FBML ref handles
|
data/lib/facebooker/version.rb
CHANGED
data/lib/facebooker.rb
CHANGED
@@ -161,6 +161,7 @@ require 'facebooker/models/page'
|
|
161
161
|
require 'facebooker/models/photo'
|
162
162
|
require 'facebooker/models/cookie'
|
163
163
|
require 'facebooker/models/applicationproperties'
|
164
|
+
require 'facebooker/models/applicationrestrictions'
|
164
165
|
require 'facebooker/models/tag'
|
165
166
|
require 'facebooker/models/user'
|
166
167
|
require 'facebooker/models/info_item'
|
data/test/facebook_admin_test.rb
CHANGED
@@ -32,6 +32,20 @@ class FacebookAdminTest < Test::Unit::TestCase
|
|
32
32
|
assert_equal 0, p.dev_mode
|
33
33
|
assert_equal 'my_canvas', p.canvas_name
|
34
34
|
end
|
35
|
+
|
36
|
+
def test_can_set_restriction_info
|
37
|
+
restrictions = {:age => '21', :type => 'alcohol'}
|
38
|
+
flexmock(@session).should_receive(:post).with('facebook.admin.setRestrictionInfo', :restriction_str => restrictions.to_json).and_return('1').once
|
39
|
+
assert(@session.admin.set_restriction_info(restrictions))
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_can_get_restriction_info
|
43
|
+
mock_http = establish_session
|
44
|
+
mock_http.should_receive(:post_form).and_return(example_get_restriction_info_xml).once.ordered(:posts)
|
45
|
+
r = @session.admin.get_restriction_info
|
46
|
+
assert_equal 'alcohol', r.type
|
47
|
+
assert_equal '21', r.age
|
48
|
+
end
|
35
49
|
|
36
50
|
def test_can_get_allocation
|
37
51
|
mock_http = establish_session
|
@@ -61,6 +75,18 @@ class FacebookAdminTest < Test::Unit::TestCase
|
|
61
75
|
XML
|
62
76
|
end
|
63
77
|
|
78
|
+
def example_get_restriction_info_xml
|
79
|
+
<<-XML
|
80
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
81
|
+
<admin_getRestrictionInfo_response
|
82
|
+
xmlns="http://api.facebook.com/1.0/"
|
83
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
84
|
+
xsi:schemaLocation="http://api.facebook.com/1.0/http://api.facebook.com/1.0/facebook.xsd">
|
85
|
+
{"age":"21","location":"","age_distribution":"","type":"alcohol"}
|
86
|
+
</admin_getRestrictionInfo_response>
|
87
|
+
XML
|
88
|
+
end
|
89
|
+
|
64
90
|
def example_get_allocation_xml
|
65
91
|
<<-XML
|
66
92
|
<?xml version="1.0" encoding="UTF-8"?>
|
data/test/facebooker_test.rb
CHANGED
@@ -321,6 +321,16 @@ class TestFacebooker < Test::Unit::TestCase
|
|
321
321
|
assert_equal false, @session.post('facebook.pages.isAdmin', :page_id => 123)
|
322
322
|
end
|
323
323
|
|
324
|
+
def test_pages_is_fan_true
|
325
|
+
expect_http_posts_with_responses(example_pages_is_fan_true_xml)
|
326
|
+
assert_equal true, @session.post('facebook.pages.isFan', :page_id => 123)
|
327
|
+
end
|
328
|
+
|
329
|
+
def test_pages_is_fan_false
|
330
|
+
expect_http_posts_with_responses(example_pages_is_fan_false_xml)
|
331
|
+
assert_equal false, @session.post('facebook.pages.isFan', :page_id => 123)
|
332
|
+
end
|
333
|
+
|
324
334
|
def test_users_set_status_true
|
325
335
|
expect_http_posts_with_responses(example_users_set_status_true_xml)
|
326
336
|
assert_equal true, @session.post('facebook.users.setStatus', :uid => 123, :status => 'message')
|
@@ -401,6 +411,20 @@ class TestFacebooker < Test::Unit::TestCase
|
|
401
411
|
XML
|
402
412
|
end
|
403
413
|
|
414
|
+
def example_pages_is_fan_true_xml
|
415
|
+
<<-XML
|
416
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
417
|
+
<pages_isFan_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">1</pages_isFan_response>
|
418
|
+
XML
|
419
|
+
end
|
420
|
+
|
421
|
+
def example_pages_is_fan_false_xml
|
422
|
+
<<-XML
|
423
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
424
|
+
<pages_isFan_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">0</pages_isFan_response>
|
425
|
+
XML
|
426
|
+
end
|
427
|
+
|
404
428
|
def example_users_set_status_true_xml
|
405
429
|
<<-XML
|
406
430
|
<?xml version="1.0" encoding="UTF-8"?>
|
data/test/model_test.rb
CHANGED
@@ -87,5 +87,39 @@ class TestFacebooker < Test::Unit::TestCase
|
|
87
87
|
t.first_name
|
88
88
|
}
|
89
89
|
end
|
90
|
+
|
91
|
+
def test_populate_from_hash_e_should_call_a_setter_for_a_key
|
92
|
+
t = PopulatingThing.new
|
93
|
+
flexmock(t).should_receive('mykey=').with('a value')
|
94
|
+
t.populate_from_hash!({ :mykey => 'a value' })
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_populate_from_hash_e_should_call_a_setter_for_a_key_if_the_value_is_false
|
98
|
+
t = PopulatingThing.new
|
99
|
+
flexmock(t).should_receive('mykey=').with(false)
|
100
|
+
t.populate_from_hash!({ :mykey => false })
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_populate_from_hash_e_should_call_not_a_setter_for_a_key_if_the_value_is_nil
|
104
|
+
t = PopulatingThing.new
|
105
|
+
flexmock(t).should_receive('mykey=').never
|
106
|
+
t.populate_from_hash!({ :mykey => nil })
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_populate_from_hash_should_check_for_an_empty_hash
|
110
|
+
t = PopulatingThing.new
|
111
|
+
hash = {}
|
112
|
+
flexmock(hash).should_receive('empty?')
|
113
|
+
t.populate_from_hash!(hash)
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_populate_from_hash_should_check_for_a_nil_param
|
117
|
+
t = PopulatingThing.new
|
118
|
+
hash = nil
|
119
|
+
assert_nothing_raised do
|
120
|
+
t.populate_from_hash!(hash)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
90
124
|
end
|
91
125
|
|
@@ -18,10 +18,25 @@ begin
|
|
18
18
|
map.connect ':controller/:action/:id', :controller => "plain_old_rails"
|
19
19
|
end
|
20
20
|
|
21
|
+
module FBConnectTestHelpers
|
22
|
+
def setup_fb_connect_cookies(params=cookie_hash_for_auth)
|
23
|
+
params.each {|k,v| @request.cookies[ENV['FACEBOOK_API_KEY']+k] = CGI::Cookie.new(ENV['FACEBOOK_API_KEY']+k,v)}
|
24
|
+
end
|
25
|
+
|
26
|
+
def expired_cookie_hash_for_auth
|
27
|
+
{"_ss" => "not_used", "_session_key"=> "whatever", "_user"=>"77777", "_expires"=>"#{1.day.ago.to_i}"}
|
28
|
+
end
|
29
|
+
|
30
|
+
def cookie_hash_for_auth
|
31
|
+
{"_ss" => "not_used", "_session_key"=> "whatever", "_user"=>"77777", "_expires"=>"#{1.day.from_now.to_i}"}
|
32
|
+
end
|
33
|
+
end
|
21
34
|
class NoisyController < ActionController::Base
|
22
35
|
include Facebooker::Rails::Controller
|
23
36
|
def rescue_action(e) raise e end
|
24
37
|
end
|
38
|
+
|
39
|
+
|
25
40
|
class ControllerWhichRequiresExtendedPermissions< NoisyController
|
26
41
|
ensure_authenticated_to_facebook
|
27
42
|
before_filter :ensure_has_status_update
|
@@ -32,6 +47,13 @@ begin
|
|
32
47
|
end
|
33
48
|
end
|
34
49
|
|
50
|
+
class FBConnectController < NoisyController
|
51
|
+
before_filter :create_facebook_session
|
52
|
+
def index
|
53
|
+
render :text => 'score!'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
35
57
|
class ControllerWhichRequiresFacebookAuthentication < NoisyController
|
36
58
|
ensure_authenticated_to_facebook
|
37
59
|
def index
|
@@ -139,6 +161,29 @@ begin
|
|
139
161
|
end
|
140
162
|
end
|
141
163
|
|
164
|
+
class RailsIntegrationTestForFBConnect < Test::Unit::TestCase
|
165
|
+
include FBConnectTestHelpers
|
166
|
+
|
167
|
+
def setup
|
168
|
+
ENV['FACEBOOK_CANVAS_PATH'] ='facebook_app_name'
|
169
|
+
ENV['FACEBOOK_API_KEY'] = '1234567'
|
170
|
+
ENV['FACEBOOK_SECRET_KEY'] = '7654321'
|
171
|
+
@controller = FBConnectController.new
|
172
|
+
@request = ActionController::TestRequest.new
|
173
|
+
@response = ActionController::TestResponse.new
|
174
|
+
@controller.stubs(:verify_signature).returns(true)
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_doesnt_set_cookie_but_facebook_session_is_available
|
179
|
+
setup_fb_connect_cookies
|
180
|
+
get :index
|
181
|
+
assert_not_nil @controller.facebook_session
|
182
|
+
assert_nil @response.cookies[:facebook_session]
|
183
|
+
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
142
187
|
class RailsIntegrationTestForNonFacebookControllers < Test::Unit::TestCase
|
143
188
|
def setup
|
144
189
|
ENV['FACEBOOK_CANVAS_PATH'] ='facebook_app_name'
|
@@ -256,6 +301,7 @@ class RailsIntegrationTestForApplicationInstallation < Test::Unit::TestCase
|
|
256
301
|
end
|
257
302
|
|
258
303
|
class RailsIntegrationTest < Test::Unit::TestCase
|
304
|
+
include FBConnectTestHelpers
|
259
305
|
def setup
|
260
306
|
ENV['FACEBOOK_CANVAS_PATH'] ='root'
|
261
307
|
ENV['FACEBOOK_API_KEY'] = '1234567'
|
@@ -373,19 +419,19 @@ class RailsIntegrationTest < Test::Unit::TestCase
|
|
373
419
|
session_params = { 'session_key' => '123', 'uid' => '321' }
|
374
420
|
session_mock.should_receive(:post).with('facebook.auth.getSession', :auth_token => auth_token).once.and_return(session_params).ordered
|
375
421
|
flexmock(@controller).should_receive(:new_facebook_session).once.and_return(session).ordered
|
376
|
-
expired_cookie_hash_for_auth
|
422
|
+
setup_fb_connect_cookies(expired_cookie_hash_for_auth)
|
377
423
|
get :index, modified_params
|
378
424
|
assert_equal(321, @controller.facebook_session.user.id)
|
379
425
|
end
|
380
426
|
|
381
427
|
def test_session_can_be_secured_with_cookies
|
382
|
-
|
428
|
+
setup_fb_connect_cookies
|
383
429
|
get :index, example_rails_params_for_fb_connect
|
384
430
|
assert_equal(77777, @controller.facebook_session.user.id)
|
385
431
|
end
|
386
432
|
|
387
433
|
def test_session_does_NOT_secure_with_expired_cookies
|
388
|
-
expired_cookie_hash_for_auth
|
434
|
+
setup_fb_connect_cookies(expired_cookie_hash_for_auth)
|
389
435
|
get :index, example_rails_params_for_fb_connect
|
390
436
|
assert_nil(@controller.facebook_session)
|
391
437
|
end
|
@@ -462,7 +508,6 @@ class RailsIntegrationTest < Test::Unit::TestCase
|
|
462
508
|
|
463
509
|
end
|
464
510
|
|
465
|
-
private
|
466
511
|
def example_rails_params_for_fb_connect
|
467
512
|
{"action"=>"index", "controller"=>"controller_which_requires_facebook_authentication"}
|
468
513
|
end
|
@@ -939,6 +984,23 @@ class RailsHelperTest < Test::Unit::TestCase
|
|
939
984
|
assert @h.init_fb_connect("XFBML").match(/XFBML/)
|
940
985
|
end
|
941
986
|
|
987
|
+
def test_init_fb_connect_with_features_and_body
|
988
|
+
@h.expects(:capture).returns("Body Content")
|
989
|
+
|
990
|
+
@h.init_fb_connect("XFBML") do
|
991
|
+
end
|
992
|
+
assert @h.output_buffer =~ /Body Content/
|
993
|
+
end
|
994
|
+
|
995
|
+
def test_fb_login_and_redirect
|
996
|
+
assert_equal @h.fb_login_and_redirect("/path"),"<fb:login-button onlogin=\"FB.Connect.logoutAndRedirect("/path");\"></fb:login-button>"
|
997
|
+
end
|
998
|
+
|
999
|
+
def test_fb_logout_link
|
1000
|
+
assert_equal @h.fb_logout_link("Logout","My URL"),"<a href=\"#\" onclick=\"FB.Connect.logoutAndRedirect("My URL");; return false;\">Logout</a>"
|
1001
|
+
end
|
1002
|
+
|
1003
|
+
|
942
1004
|
def test_fb_connect_javascript_tag
|
943
1005
|
assert_equal "<script src=\"http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php\" type=\"text/javascript\"></script>",
|
944
1006
|
@h.fb_connect_javascript_tag
|
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.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Fowler
|
@@ -17,6 +17,7 @@ default_executable:
|
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: hoe
|
20
|
+
type: :development
|
20
21
|
version_requirement:
|
21
22
|
version_requirements: !ruby/object:Gem::Requirement
|
22
23
|
requirements:
|