djanowski-facebooker 1.0.4 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Manifest.txt CHANGED
@@ -37,6 +37,8 @@ generators/facebook_scaffold/templates/view_new.fbml.erb
37
37
  generators/facebook_scaffold/templates/view_new.html.erb
38
38
  generators/facebook_scaffold/templates/view_show.fbml.erb
39
39
  generators/facebook_scaffold/templates/view_show.html.erb
40
+ generators/xd_receiver/xd_receiver_generator.rb
41
+ generators/xd_receiver/templates/xd_receiver.html
40
42
  init.rb
41
43
  install.rb
42
44
  lib/facebooker.rb
@@ -75,6 +77,7 @@ lib/facebooker/rails/facebook_request_fix.rb
75
77
  lib/facebooker/rails/facebook_session_handling.rb
76
78
  lib/facebooker/rails/facebook_url_rewriting.rb
77
79
  lib/facebooker/rails/helpers.rb
80
+ lib/facebooker/rails/helpers/fb_connect.rb
78
81
  lib/facebooker/rails/profile_publisher_extensions.rb
79
82
  lib/facebooker/rails/publisher.rb
80
83
  lib/facebooker/rails/routing.rb
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" >
4
+ <head>
5
+ <title>Cross-Domain Receiver Page</title>
6
+ </head>
7
+ <body>
8
+ <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.debug.js" type="text/javascript"></script>
9
+ </body>
10
+ </html>
@@ -0,0 +1,9 @@
1
+ class XdReceiverGenerator < Rails::Generator::Base
2
+ def manifest
3
+ record do |m|
4
+ m.template "xd_receiver.html", "public/xd_receiver.html"
5
+ end
6
+ end
7
+
8
+
9
+ end
@@ -10,7 +10,7 @@ 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]
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
14
  STANDARD_FIELDS = [:uid, :first_name, :last_name, :name, :timezone, :birthday, :sex, :affiliations, :locale, :profile_url]
15
15
  attr_accessor :id, :session
16
16
  populating_attr_accessor *FIELDS
@@ -23,8 +23,7 @@ module Facebooker
23
23
 
24
24
 
25
25
  def set_facebook_session
26
-
27
- returning session_set = session_already_secured? || secure_with_facebook_params! ||secure_with_token! do
26
+ returning session_set = session_already_secured? || secure_with_facebook_params! || secure_with_cookies! || secure_with_token! do
28
27
  if session_set
29
28
  capture_facebook_friends_if_available!
30
29
  Session.current = facebook_session
@@ -72,7 +71,35 @@ module Facebooker
72
71
  !session[:facebook_session].blank? && (params[:fb_sig_session_key].blank? || session[:facebook_session].session_key == facebook_params[:session_key])
73
72
  end
74
73
  end
75
-
74
+
75
+ def clear_fb_cookies!
76
+ fb_cookie_names.each {|name| cookies[name] = nil }
77
+ end
78
+
79
+ def fb_cookie_prefix
80
+ Facebooker.api_key+"_"
81
+ end
82
+
83
+ def fb_cookie_names
84
+ fb_cookie_names = cookies.keys.select{|k| k.starts_with?(fb_cookie_prefix)}
85
+ end
86
+
87
+ def secure_with_cookies!
88
+ parsed = {}
89
+
90
+ fb_cookie_names.each { |key| parsed[key[fb_cookie_prefix.size,key.size]] = cookies[key] }
91
+
92
+ #returning gracefully if the cookies aren't set or have expired
93
+ return unless parsed['session_key'] && parsed['user'] && parsed['expires'] && parsed['ss']
94
+ return unless Time.at(parsed['expires'].to_f) > Time.now
95
+
96
+ #if we have the unexpired cookies, we'll throw an exception if the sig doesn't verify
97
+ verify_signature(parsed,cookies[Facebooker.api_key])
98
+
99
+ @facebook_session = new_facebook_session
100
+ @facebook_session.secure_with!(parsed['session_key'],parsed['user'],parsed['expires'],parsed['ss'])
101
+ end
102
+
76
103
  def secure_with_token!
77
104
  if params['auth_token']
78
105
  @facebook_session = new_facebook_session
@@ -142,7 +169,7 @@ module Facebooker
142
169
  raw_string = facebook_sig_params.map{ |*args| args.join('=') }.sort.join
143
170
  actual_sig = Digest::MD5.hexdigest([raw_string, Facebooker::Session.secret_key].join)
144
171
  raise Facebooker::Session::IncorrectSignature if actual_sig != expected_signature
145
- raise Facebooker::Session::SignatureTooOld if Time.at(facebook_sig_params['time'].to_f) < earliest_valid_session
172
+ raise Facebooker::Session::SignatureTooOld if facebook_sig_params['time'] && Time.at(facebook_sig_params['time'].to_f) < earliest_valid_session
146
173
  true
147
174
  end
148
175
 
@@ -8,6 +8,7 @@ module Facebooker
8
8
  #
9
9
  module Helpers
10
10
 
11
+ include Facebooker::Rails::Helpers::FbConnect
11
12
 
12
13
  # Create an fb:dialog
13
14
  # id must be a unique name e.g. "my_dialog"
@@ -111,7 +112,7 @@ module Facebooker
111
112
  # <em> Note: </em> I don't think the block is used here.
112
113
  def fb_multi_friend_selector(message,options={},&block)
113
114
  options = options.dup
114
- tag("fb:multi-friend-selector",stringify_vals(options.merge(:showborder=>false,:actiontext=>message,:max=>20)))
115
+ tag("fb:multi-friend-selector",stringify_vals({:showborder=>false,:actiontext=>message,:max=>20}.merge(options)))
115
116
  end
116
117
 
117
118
  # Render a condensed <fb:multi-friend-selector> with the passed in welcome message
@@ -196,7 +197,7 @@ module Facebooker
196
197
  options.transform_keys!(FB_NAME_OPTION_KEYS_TO_TRANSFORM)
197
198
  options.assert_valid_keys(FB_NAME_VALID_OPTION_KEYS)
198
199
  options.merge!(:uid => cast_to_facebook_id(user))
199
- tag("fb:name", stringify_vals(options))
200
+ content_tag("fb:name",nil, stringify_vals(options))
200
201
  end
201
202
 
202
203
  FB_NAME_OPTION_KEYS_TO_TRANSFORM = {:first_name_only => :firstnameonly,
@@ -217,7 +218,7 @@ module Facebooker
217
218
  options.transform_keys!(FB_PRONOUN_OPTION_KEYS_TO_TRANSFORM)
218
219
  options.assert_valid_keys(FB_PRONOUN_VALID_OPTION_KEYS)
219
220
  options.merge!(:uid => cast_to_facebook_id(user))
220
- tag("fb:pronoun", stringify_vals(options))
221
+ content_tag("fb:pronoun",nil, stringify_vals(options))
221
222
  end
222
223
 
223
224
  FB_PRONOUN_OPTION_KEYS_TO_TRANSFORM = {:use_you => :useyou, :use_they => :usethey}
@@ -259,7 +260,7 @@ module Facebooker
259
260
  options = options.dup
260
261
  validate_fb_profile_pic_size(options)
261
262
  options.merge!(:uid => cast_to_facebook_id(user))
262
- tag("fb:profile-pic", stringify_vals(options))
263
+ content_tag("fb:profile-pic", nil,stringify_vals(options))
263
264
  end
264
265
 
265
266
  # Render an fb:photo tag.
@@ -271,7 +272,7 @@ module Facebooker
271
272
  options.merge!(:pid => cast_to_photo_id(photo))
272
273
  validate_fb_photo_size(options)
273
274
  validate_fb_photo_align_value(options)
274
- tag("fb:photo", stringify_vals(options))
275
+ content_tag("fb:photo",nil, stringify_vals(options))
275
276
  end
276
277
 
277
278
  FB_PHOTO_VALID_OPTION_KEYS = [:uid, :size, :align]
@@ -544,6 +545,32 @@ module Facebooker
544
545
  content_tag("fb:prompt-permission",message,args)
545
546
  end
546
547
 
548
+ def fb_eventlink(eid)
549
+ content_tag "fb:eventlink",nil,:eid=>eid
550
+ end
551
+
552
+ def fb_grouplink(gid)
553
+ content_tag "fb:grouplink",nil,:gid=>gid
554
+ end
555
+
556
+ def fb_user_status(user,linked=true)
557
+ content_tag "fb:user-status",nil,stringify_vals(:uid=>cast_to_facebook_id(user), :linked=>linked)
558
+ end
559
+
560
+ def fb_share_button(url)
561
+ content_tag "fb:share-button",nil,:class=>"url",:href=>url
562
+ end
563
+
564
+ def fb_serverfbml(options={},&proc)
565
+ inner = capture(&proc)
566
+ concat(content_tag("fb:serverfbml",inner,options),&proc.binding)
567
+ end
568
+
569
+ def fb_container(options={},&proc)
570
+ inner = capture(&proc)
571
+ concat(content_tag("fb:container",inner,options),&proc.binding)
572
+ end
573
+
547
574
  protected
548
575
 
549
576
  def cast_to_facebook_id(object)
@@ -0,0 +1,34 @@
1
+ module Facebooker
2
+ module Rails
3
+ module Helpers
4
+ module FbConnect
5
+
6
+ def fb_connect_javascript_tag
7
+ javascript_include_tag "http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php"
8
+ end
9
+
10
+ def init_fb_connect(*required_features)
11
+ init_string = "FB.Facebook.init('#{Facebooker.api_key}','/xd_receiver.html');"
12
+ unless required_features.blank?
13
+ init_string = <<-FBML
14
+ Element.observe(window,'load', function() {
15
+ FB_RequireFeatures(#{required_features.to_json}, function() {
16
+ #{init_string}
17
+ });
18
+ });
19
+ FBML
20
+ end
21
+ javascript_tag init_string
22
+ end
23
+
24
+ def fb_login_button(callback=nil)
25
+ content_tag("fb:login-button",nil,(callback.nil? ? {} : {:onlogin=>callback}))
26
+ end
27
+
28
+ def fb_unconnected_friends_count
29
+ content_tag "fb:unconnected-friends-count",nil
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -34,6 +34,7 @@ module Facebooker
34
34
  # def publish_action(f)
35
35
  # send_as :user_action
36
36
  # from f
37
+ # story_size SHORT # or ONE_LINE or FULL
37
38
  # data :friend=>"Mike"
38
39
  # end
39
40
  #
@@ -87,6 +88,12 @@ module Facebooker
87
88
  #
88
89
  # Publisher makes many helpers available, including the linking and asset helpers
89
90
  class Publisher
91
+
92
+ #story sizes from the Facebooker API
93
+ ONE_LINE=1
94
+ SHORT=2
95
+ FULL=4
96
+
90
97
  def initialize
91
98
  @controller = PublisherController.new
92
99
  end
@@ -213,11 +220,14 @@ module Facebooker
213
220
  attr_accessor :body_general
214
221
  attr_accessor :template_id
215
222
  attr_accessor :template_name
216
-
223
+ attr_accessor :story_size
217
224
  def target_ids=(val)
218
225
  @target_ids = val.is_a?(Array) ? val.join(",") : val
219
226
  end
220
-
227
+ def data_hash
228
+ default_data = story_size.nil? ? {} : {:story_size=>story_size}
229
+ default_data.merge(data||{})
230
+ end
221
231
  end
222
232
 
223
233
  cattr_accessor :ignore_errors
@@ -351,7 +361,7 @@ module Facebooker
351
361
  when Ref
352
362
  Facebooker::Session.create.server_cache.set_ref_handle(_body.handle,_body.fbml)
353
363
  when UserAction
354
- @from.session.publish_user_action(_body.template_id,_body.data||{},_body.target_ids,_body.body_general)
364
+ @from.session.publish_user_action(_body.template_id,_body.data_hash,_body.target_ids,_body.body_general)
355
365
  else
356
366
  raise UnspecifiedBodyType.new("You must specify a valid send_as")
357
367
  end
@@ -6,6 +6,7 @@ require 'action_controller/test_process'
6
6
  require 'active_record'
7
7
  require File.dirname(__FILE__)+'/../init'
8
8
  require 'facebooker/rails/controller'
9
+ require 'facebooker/rails/helpers/fb_connect'
9
10
  require 'facebooker/rails/helpers'
10
11
  require 'facebooker/rails/publisher'
11
12
 
@@ -118,6 +119,14 @@ class TestPublisher < Facebooker::Rails::Publisher
118
119
  from user
119
120
  data :friend=>"Mike"
120
121
  end
122
+ def user_action_with_story_size(user)
123
+ send_as :user_action
124
+ from user
125
+ story_size ONE_LINE
126
+ story_size FULL
127
+ story_size SHORT
128
+ data :friend=>"Mike"
129
+ end
121
130
  def user_action_no_data(user)
122
131
  send_as :user_action
123
132
  from user
@@ -353,6 +362,19 @@ class PublisherTest < Test::Unit::TestCase
353
362
  TestPublisher.deliver_user_action(@from_user)
354
363
  end
355
364
 
365
+ def test_publish_user_action_with_story_size
366
+ @from_user = Facebooker::User.new
367
+ @session = Facebooker::Session.new("","")
368
+ @from_user.stubs(:session).returns(@session)
369
+ @session.expects(:publish_user_action).with(20309041537,{:friend=>"Mike", :story_size=>2},nil,nil)
370
+
371
+ Facebooker::Rails::Publisher::FacebookTemplate.expects(:bundle_id_for_class_and_method).
372
+ with(TestPublisher, 'user_action_with_story_size').
373
+ returns(20309041537)
374
+ TestPublisher.deliver_user_action_with_story_size(@from_user)
375
+
376
+ end
377
+
356
378
  def test_publishing_user_data_no_action_gives_nil_hash
357
379
  @from_user = Facebooker::User.new
358
380
  @session = Facebooker::Session.new("","")
@@ -3,6 +3,7 @@ begin
3
3
  require 'action_controller'
4
4
  require 'action_controller/test_process'
5
5
  require 'facebooker/rails/controller'
6
+ require 'facebooker/rails/helpers/fb_connect'
6
7
  require 'facebooker/rails/helpers'
7
8
  require 'facebooker/rails/facebook_form_builder'
8
9
  require File.dirname(__FILE__)+'/../init'
@@ -363,6 +364,32 @@ class RailsIntegrationTest < Test::Unit::TestCase
363
364
  get :index, modified_params
364
365
  end
365
366
 
367
+ def test_session_secured_with_auth_token_if_cookies_expired
368
+ auth_token = 'ohaiauthtokenhere111'
369
+ modified_params = example_rails_params_including_fb
370
+ modified_params.delete('fb_sig_session_key')
371
+ modified_params['auth_token'] = auth_token
372
+ session_mock = flexmock(session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY']))
373
+ session_params = { 'session_key' => '123', 'uid' => '321' }
374
+ session_mock.should_receive(:post).with('facebook.auth.getSession', :auth_token => auth_token).once.and_return(session_params).ordered
375
+ flexmock(@controller).should_receive(:new_facebook_session).once.and_return(session).ordered
376
+ expired_cookie_hash_for_auth.each {|k,v| @request.cookies[ENV['FACEBOOK_API_KEY']+k] = CGI::Cookie.new(ENV['FACEBOOK_API_KEY']+k,v)}
377
+ get :index, modified_params
378
+ assert_equal(321, @controller.facebook_session.user.id)
379
+ end
380
+
381
+ def test_session_can_be_secured_with_cookies
382
+ cookie_hash_for_auth.each {|k,v| @request.cookies[ENV['FACEBOOK_API_KEY']+k] = CGI::Cookie.new(ENV['FACEBOOK_API_KEY']+k,v)}
383
+ get :index, example_rails_params_for_fb_connect
384
+ assert_equal(77777, @controller.facebook_session.user.id)
385
+ end
386
+
387
+ def test_session_does_NOT_secure_with_expired_cookies
388
+ expired_cookie_hash_for_auth.each {|k,v| @request.cookies[ENV['FACEBOOK_API_KEY']+k] = CGI::Cookie.new(ENV['FACEBOOK_API_KEY']+k,v)}
389
+ get :index, example_rails_params_for_fb_connect
390
+ assert_nil(@controller.facebook_session)
391
+ end
392
+
366
393
  def test_user_friends_can_be_populated_from_facebook_params_if_available
367
394
  get :index, example_rails_params_including_fb
368
395
  assert_not_nil(friends = @controller.facebook_session.user.friends)
@@ -436,6 +463,18 @@ class RailsIntegrationTest < Test::Unit::TestCase
436
463
  end
437
464
 
438
465
  private
466
+ def example_rails_params_for_fb_connect
467
+ {"action"=>"index", "controller"=>"controller_which_requires_facebook_authentication"}
468
+ end
469
+
470
+ def expired_cookie_hash_for_auth
471
+ {"_ss" => "not_used", "_session_key"=> "whatever", "_user"=>"77777", "_expires"=>"#{1.day.ago.to_i}"}
472
+ end
473
+
474
+ def cookie_hash_for_auth
475
+ {"_ss" => "not_used", "_session_key"=> "whatever", "_user"=>"77777", "_expires"=>"#{1.day.from_now.to_i}"}
476
+ end
477
+
439
478
  def example_rails_params_including_fb_for_user_not_logged_into_application
440
479
  {"fb_sig_time"=>"1186588275.5988", "fb_sig"=>"7371a6400329b229f800a5ecafe03b0a", "action"=>"index", "fb_sig_in_canvas"=>"1", "controller"=>"controller_which_requires_facebook_authentication", "fb_sig_added"=>"0", "fb_sig_api_key"=>"b6c9c857ac543ca806f4d3187cd05e09"}
441
480
  end
@@ -490,6 +529,7 @@ class RailsHelperTest < Test::Unit::TestCase
490
529
  include ActionView::Helpers::CaptureHelper
491
530
  include ActionView::Helpers::TagHelper
492
531
  include ActionView::Helpers::AssetTagHelper
532
+ include ActionView::Helpers::JavaScriptHelper
493
533
  include Facebooker::Rails::Helpers
494
534
  attr_accessor :flash, :output_buffer
495
535
  def initialize
@@ -524,11 +564,11 @@ class RailsHelperTest < Test::Unit::TestCase
524
564
  end
525
565
 
526
566
  def test_fb_profile_pic
527
- assert_equal "<fb:profile-pic uid=\"1234\" />", @h.fb_profile_pic("1234")
567
+ assert_equal "<fb:profile-pic uid=\"1234\"></fb:profile-pic>", @h.fb_profile_pic("1234")
528
568
  end
529
569
 
530
570
  def test_fb_profile_pic_with_valid_size
531
- assert_equal "<fb:profile-pic size=\"small\" uid=\"1234\" />", @h.fb_profile_pic("1234", :size => :small)
571
+ assert_equal "<fb:profile-pic size=\"small\" uid=\"1234\"></fb:profile-pic>", @h.fb_profile_pic("1234", :size => :small)
532
572
  end
533
573
 
534
574
  def test_fb_profile_pic_with_invalid_size
@@ -536,12 +576,12 @@ class RailsHelperTest < Test::Unit::TestCase
536
576
  end
537
577
 
538
578
  def test_fb_photo
539
- assert_equal "<fb:photo pid=\"1234\" />",@h.fb_photo("1234")
579
+ assert_equal "<fb:photo pid=\"1234\"></fb:photo>",@h.fb_photo("1234")
540
580
  end
541
581
 
542
582
  def test_fb_photo_with_object_responding_to_photo_id
543
583
  photo = flexmock("photo", :photo_id => "5678")
544
- assert_equal "<fb:photo pid=\"5678\" />", @h.fb_photo(photo)
584
+ assert_equal "<fb:photo pid=\"5678\"></fb:photo>", @h.fb_photo(photo)
545
585
  end
546
586
 
547
587
  def test_fb_photo_with_invalid_size
@@ -557,14 +597,14 @@ class RailsHelperTest < Test::Unit::TestCase
557
597
  end
558
598
 
559
599
  def test_fb_photo_with_valid_align_value
560
- assert_equal "<fb:photo align=\"right\" pid=\"1234\" />",@h.fb_photo("1234", :align => :right)
600
+ assert_equal "<fb:photo align=\"right\" pid=\"1234\"></fb:photo>",@h.fb_photo("1234", :align => :right)
561
601
  end
562
602
 
563
603
  def test_fb_photo_with_class
564
- assert_equal "<fb:photo class=\"picky\" pid=\"1234\" />",@h.fb_photo("1234", :class => :picky)
604
+ assert_equal "<fb:photo class=\"picky\" pid=\"1234\"></fb:photo>",@h.fb_photo("1234", :class => :picky)
565
605
  end
566
606
  def test_fb_photo_with_style
567
- assert_equal "<fb:photo pid=\"1234\" style=\"some=css;put=here;\" />",@h.fb_photo("1234", :style => "some=css;put=here;")
607
+ assert_equal "<fb:photo pid=\"1234\" style=\"some=css;put=here;\"></fb:photo>",@h.fb_photo("1234", :style => "some=css;put=here;")
568
608
  end
569
609
 
570
610
  def test_fb_prompt_permission_valid_no_callback
@@ -593,16 +633,16 @@ class RailsHelperTest < Test::Unit::TestCase
593
633
  end
594
634
 
595
635
  def test_fb_name
596
- assert_equal "<fb:name uid=\"1234\" />",@h.fb_name("1234")
636
+ assert_equal "<fb:name uid=\"1234\"></fb:name>",@h.fb_name("1234")
597
637
  end
598
638
 
599
639
  def test_fb_name_with_transformed_key
600
- assert_equal "<fb:name uid=\"1234\" useyou=\"true\" />", @h.fb_name(1234, :use_you => true)
640
+ assert_equal "<fb:name uid=\"1234\" useyou=\"true\"></fb:name>", @h.fb_name(1234, :use_you => true)
601
641
  end
602
642
 
603
643
  def test_fb_name_with_user_responding_to_facebook_id
604
644
  user = flexmock("user", :facebook_id => "5678")
605
- assert_equal "<fb:name uid=\"5678\" />", @h.fb_name(user)
645
+ assert_equal "<fb:name uid=\"5678\"></fb:name>", @h.fb_name(user)
606
646
  end
607
647
 
608
648
  def test_fb_name_with_invalid_key
@@ -698,16 +738,16 @@ class RailsHelperTest < Test::Unit::TestCase
698
738
  end
699
739
 
700
740
  def test_fb_pronoun
701
- assert_equal "<fb:pronoun uid=\"1234\" />", @h.fb_pronoun(1234)
741
+ assert_equal "<fb:pronoun uid=\"1234\"></fb:pronoun>", @h.fb_pronoun(1234)
702
742
  end
703
743
 
704
744
  def test_fb_pronoun_with_transformed_key
705
- assert_equal "<fb:pronoun uid=\"1234\" usethey=\"true\" />", @h.fb_pronoun(1234, :use_they => true)
745
+ assert_equal "<fb:pronoun uid=\"1234\" usethey=\"true\"></fb:pronoun>", @h.fb_pronoun(1234, :use_they => true)
706
746
  end
707
747
 
708
748
  def test_fb_pronoun_with_user_responding_to_facebook_id
709
749
  user = flexmock("user", :facebook_id => "5678")
710
- assert_equal "<fb:pronoun uid=\"5678\" />", @h.fb_pronoun(user)
750
+ assert_equal "<fb:pronoun uid=\"5678\"></fb:pronoun>", @h.fb_pronoun(user)
711
751
  end
712
752
 
713
753
  def test_fb_pronoun_with_invalid_key
@@ -880,6 +920,58 @@ class RailsHelperTest < Test::Unit::TestCase
880
920
  end
881
921
  assert_equal "<fb:narrow>narrow profile content</fb:narrow>", @h.output_buffer
882
922
  end
923
+
924
+ def test_fb_login_button
925
+ assert_equal "<fb:login-button onlogin=\"somejs\"></fb:login-button>",@h.fb_login_button("somejs")
926
+ end
927
+
928
+ def test_init_fb_connect_no_features
929
+ assert ! @h.init_fb_connect.match(/XFBML/)
930
+ end
931
+
932
+ def test_init_fb_connect_with_features
933
+ assert @h.init_fb_connect("XFBML").match(/XFBML/)
934
+ end
935
+
936
+ def test_fb_connect_javascript_tag
937
+ assert_equal "<script src=\"http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php\" type=\"text/javascript\"></script>",
938
+ @h.fb_connect_javascript_tag
939
+ end
940
+
941
+ def test_fb_container
942
+ @h.expects(:capture).returns("Inner Stuff")
943
+ @h.fb_container(:condition=>"somejs") do
944
+ end
945
+ assert_equal "<fb:container condition=\"somejs\">Inner Stuff</fb:container>",@h.output_buffer
946
+ end
947
+
948
+ def test_fb_eventlink
949
+ assert_equal '<fb:eventlink eid="21150032416"></fb:eventlink>',@h.fb_eventlink("21150032416")
950
+ end
951
+
952
+ def test_fb_grouplink
953
+ assert_equal '<fb:grouplink gid="2541896821"></fb:grouplink>',@h.fb_grouplink("2541896821")
954
+ end
955
+
956
+ def test_fb_serverfbml
957
+ @h.expects(:capture).returns("Inner Stuff")
958
+ @h.fb_serverfbml(:condition=>"somejs") do
959
+ end
960
+ assert_equal "<fb:serverfbml condition=\"somejs\">Inner Stuff</fb:serverfbml>",@h.output_buffer
961
+ end
962
+
963
+ def test_fb_share_button
964
+ assert_equal "<fb:share-button class=\"url\" href=\"http://www.elevatedrails.com\"></fb:share-button>",@h.fb_share_button("http://www.elevatedrails.com")
965
+ end
966
+
967
+ def test_fb_unconnected_friends_count_without_condition
968
+ assert_equal "<fb:unconnected-friends-count></fb:unconnected-friends-count>",@h.fb_unconnected_friends_count
969
+ end
970
+
971
+ def test_fb_user_status
972
+ user=flexmock("user", :facebook_id => "5678")
973
+ assert_equal '<fb:user-status linked="false" uid="5678"></fb:user-status>',@h.fb_user_status(user,false)
974
+ end
883
975
  end
884
976
  class TestModel
885
977
  attr_accessor :name,:facebook_id
@@ -958,6 +1050,8 @@ class RailsFacebookFormbuilderTest < Test::Unit::TestCase
958
1050
  def test_multi_friend_input
959
1051
  assert_equal "<fb:editor-custom label=\"Friends\"><fb:multi-friend-input></fb:multi-friend-input></fb:editor-custom>",@form_builder.multi_friend_input
960
1052
  end
1053
+
1054
+
961
1055
  end
962
1056
 
963
1057
  class RailsPrettyErrorsTest < Test::Unit::TestCase
@@ -1118,6 +1212,7 @@ class RailsUrlHelperExtensionsTest < Test::Unit::TestCase
1118
1212
  def test_link_to_if_with_false
1119
1213
  assert_equal @label, @u.link_to_if(false,@label,@url)
1120
1214
  end
1215
+
1121
1216
  end
1122
1217
 
1123
1218
 
data/test/user_test.rb CHANGED
@@ -169,6 +169,17 @@ class UserTest < Test::Unit::TestCase
169
169
  assert_equal({:email=>"mike@example.com",:account_id=>2},e.failed_users.first)
170
170
  end
171
171
 
172
+ def test_get_locale
173
+ @user = Facebooker::User.new(9507801, @session)
174
+ expect_http_posts_with_responses(example_users_get_info_xml)
175
+ assert_equal "en_US", @user.locale
176
+ end
177
+
178
+ def test_get_profile_url
179
+ @user = Facebooker::User.new(8055, @session)
180
+ expect_http_posts_with_responses(example_users_get_info_xml)
181
+ assert_equal "http://www.facebook.com/profile.php?id=8055", @user.profile_url
182
+ end
172
183
 
173
184
  private
174
185
  def example_profile_photos_get_xml
@@ -233,6 +244,12 @@ class UserTest < Test::Unit::TestCase
233
244
  </events_get_response>"
234
245
  end
235
246
 
247
+ def example_users_get_info_xml
248
+ <<-XML
249
+ <?xml version="1.0" encoding="UTF-8"?> <users_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"> <user> <uid>8055</uid> <about_me>This field perpetuates the glorification of the ego. Also, it has a character limit.</about_me> <activities>Here: facebook, etc. There: Glee Club, a capella, teaching.</activities> <affiliations list="true"> <affiliation> <nid>50453093</nid> <name>Facebook Developers</name> <type>work</type> <status/> <year/> </affiliation> </affiliations> <birthday>November 3</birthday> <books>The Brothers K, GEB, Ken Wilber, Zen and the Art, Fitzgerald, The Emporer's New Mind, The Wonderful Story of Henry Sugar</books> <current_location> <city>Palo Alto</city> <state>CA</state> <country>United States</country> <zip>94303</zip> </current_location> <education_history list="true"> <education_info> <name>Harvard</name> <year>2003</year> <concentrations list="true"> <concentration>Applied Mathematics</concentration> <concentration>Computer Science</concentration> </concentrations> </education_info> </education_history> <first_name>Dave</first_name> <hometown_location> <city>York</city> <state>PA</state> <country>United States</country> </hometown_location> <hs_info> <hs1_name>Central York High School</hs1_name> <hs2_name/> <grad_year>1999</grad_year> <hs1_id>21846</hs1_id> <hs2_id>0</hs2_id> </hs_info> <is_app_user>1</is_app_user> <has_added_app>1</has_added_app> <interests>coffee, computers, the funny, architecture, code breaking,snowboarding, philosophy, soccer, talking to strangers</interests> <last_name>Fetterman</last_name> <locale>en_US</locale> <meeting_for list="true"> <seeking>Friendship</seeking> </meeting_for> <meeting_sex list="true"> <sex>female</sex> </meeting_sex> <movies>Tommy Boy, Billy Madison, Fight Club, Dirty Work, Meet the Parents, My Blue Heaven, Office Space </movies> <music>New Found Glory, Daft Punk, Weezer, The Crystal Method, Rage, the KLF, Green Day, Live, Coldplay, Panic at the Disco, Family Force 5</music> <name>Dave Fetterman</name> <notes_count>0</notes_count> <pic>http://photos-055.facebook.com/ip007/profile3/1271/65/s8055_39735.jpg</pic> <pic_big>http://photos-055.facebook.com/ip007/profile3/1271/65/n8055_39735.jpg</pic_big> <pic_small>http://photos-055.facebook.com/ip007/profile3/1271/65/t8055_39735.jpg</pic_small> <pic_square>http://photos-055.facebook.com/ip007/profile3/1271/65/q8055_39735.jpg</pic_square> <political>Moderate</political> <profile_update_time>1170414620</profile_update_time> <profile_url>http://www.facebook.com/profile.php?id=8055</profile_url> <quotes/> <relationship_status>In a Relationship</relationship_status> <religion/> <sex>male</sex> <significant_other_id xsi:nil="true"/> <status> <message>Fast Company, November issue, page 84</message> <time>1193075616</time> </status> <timezone>-8</timezone> <tv>cf. Bob Trahan</tv> <wall_count>121</wall_count> <work_history list="true"> <work_info> <location> <city>Palo Alto</city> <state>CA</state> <country>United States</country> </location> <company_name>Facebook</company_name> <position>Software Engineer</position> <description>Tech Lead, Facebook Platform</description> <start_date>2006-01</start_date> <end_date/> </work_info> </work_history> </user> </users_getInfo_response>
250
+ XML
251
+ end
252
+
236
253
  def register_response_xml
237
254
  <<-XML
238
255
  <?xml version="1.0" encoding="UTF-8"?>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: djanowski-facebooker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Fowler
@@ -79,6 +79,8 @@ files:
79
79
  - generators/facebook_scaffold/templates/view_new.html.erb
80
80
  - generators/facebook_scaffold/templates/view_show.fbml.erb
81
81
  - generators/facebook_scaffold/templates/view_show.html.erb
82
+ - generators/xd_receiver/xd_receiver_generator.rb
83
+ - generators/xd_receiver/templates/xd_receiver.html
82
84
  - init.rb
83
85
  - install.rb
84
86
  - lib/facebooker.rb
@@ -117,6 +119,7 @@ files:
117
119
  - lib/facebooker/rails/facebook_session_handling.rb
118
120
  - lib/facebooker/rails/facebook_url_rewriting.rb
119
121
  - lib/facebooker/rails/helpers.rb
122
+ - lib/facebooker/rails/helpers/fb_connect.rb
120
123
  - lib/facebooker/rails/profile_publisher_extensions.rb
121
124
  - lib/facebooker/rails/publisher.rb
122
125
  - lib/facebooker/rails/routing.rb