1
1
require File . expand_path ( File . dirname ( __FILE__ ) + '/../rails_test_helper' )
2
2
3
- ActionController ::Routing ::Routes . draw do |map |
4
- map . connect '' , :controller => "facebook" , :conditions => { :canvas => true }
5
- map . connect '' , :controller => "plain_old_rails"
6
- map . resources :comments , :controller => "plain_old_rails"
7
- map . connect 'require_auth/:action' , :controller => "controller_which_requires_facebook_authentication"
8
- map . connect 'require_install/:action' , :controller => "controller_which_requires_application_installation"
9
- map . connect ':controller/:action/:id' , :controller => "plain_old_rails"
10
- end
11
-
12
3
module FBConnectTestHelpers
13
4
def setup_fb_connect_cookies ( params = cookie_hash_for_auth )
14
- params . each { |k , v | @request . cookies [ ENV [ 'FACEBOOK_API_KEY' ] +k ] = CGI ::Cookie . new ( ENV [ 'FACEBOOK_API_KEY' ] +k , v ) }
5
+ params . each { |k , v | @request . cookies [ ENV [ 'FACEBOOK_API_KEY' ] +k ] = CGI ::Cookie . new ( ENV [ 'FACEBOOK_API_KEY' ] +k , v ) }
15
6
end
16
7
17
8
def expired_cookie_hash_for_auth
@@ -193,7 +184,7 @@ def setup
193
184
194
185
def test_url_for_links_to_callback_if_canvas_is_false_and_in_canvas
195
186
get :link_test
196
- assert_match /test.host/ , @response . body
187
+ assert_match ( /test.host/ , @response . body )
197
188
end
198
189
199
190
def test_named_route_doesnt_include_canvas_path_when_not_in_canvas
@@ -444,33 +435,33 @@ def test_redirect_to_renders_javascript_redirect_if_request_is_for_a_facebook_if
444
435
assert_match "http-equiv" , @response . body
445
436
assert_match "http://www.facebook.com/login.php?api_key=1234567&v=1.0" . to_json , @response . body
446
437
assert_match "http://www.facebook.com/login.php?api_key=1234567&v=1.0" , @response . body
447
- end
448
-
438
+ end
439
+
449
440
def test_url_for_links_to_canvas_if_canvas_is_true_and_not_in_canvas
450
441
get :link_test , facebook_params ( :fb_sig_in_canvas => 0 , :canvas => true )
451
- assert_match /apps.facebook.com/ , @response . body
442
+ assert_match ( /apps.facebook.com/ , @response . body )
452
443
end
453
-
444
+
454
445
def test_includes_relative_url_root_when_linked_to_canvas
455
446
get :link_test , facebook_params ( :fb_sig_in_canvas => 0 , :canvas => true )
456
- assert_match /root/ , @response . body
447
+ assert_match ( /root/ , @response . body )
457
448
end
458
449
459
450
def test_url_for_links_to_callback_if_canvas_is_false_and_in_canvas
460
451
get :link_test , facebook_params ( :fb_sig_in_canvas => 0 , :canvas => false )
461
- assert_match /test.host/ , @response . body
452
+ assert_match ( /test.host/ , @response . body )
462
453
end
463
454
464
455
def test_url_for_doesnt_include_url_root_when_not_linked_to_canvas
465
456
get :link_test , facebook_params ( :fb_sig_in_canvas => 0 , :canvas => false )
466
457
assert !@response . body . match ( /root/ )
467
458
end
468
-
459
+
469
460
def test_url_for_links_to_canvas_if_canvas_is_not_set
470
461
get :link_test , facebook_params
471
- assert_match /apps.facebook.com/ , @response . body
462
+ assert_match ( /apps.facebook.com/ , @response . body )
472
463
end
473
-
464
+
474
465
def test_image_tag
475
466
get :image_test , facebook_params
476
467
assert_equal "<img alt=\" Image\" src=\" http://root.example.com/images/image.png\" />" , @response . body
@@ -660,35 +651,35 @@ def test_fb_add_info_section
660
651
assert_equal "<fb:add-section-button section=\" info\" />" , @h . fb_add_info_section
661
652
end
662
653
663
- def test_fb_name_with_invalid_key
654
+ def test_fb_name_with_invalid_key_sizee
664
655
assert_raises ( ArgumentError ) { @h . fb_name ( 1234 , :sizee => false ) }
665
656
end
666
657
667
658
def test_fb_name
668
659
assert_equal "<fb:name uid=\" 1234\" ></fb:name>" , @h . fb_name ( "1234" )
669
660
end
670
-
661
+
671
662
def test_fb_name_with_transformed_key
672
663
assert_equal "<fb:name uid=\" 1234\" useyou=\" true\" ></fb:name>" , @h . fb_name ( 1234 , :use_you => true )
673
664
end
674
-
665
+
675
666
def test_fb_name_with_user_responding_to_facebook_id
676
667
user = flexmock ( "user" , :facebook_id => "5678" )
677
668
assert_equal "<fb:name uid=\" 5678\" ></fb:name>" , @h . fb_name ( user )
678
669
end
679
-
680
- def test_fb_name_with_invalid_key
670
+
671
+ def test_fb_name_with_invalid_key_linkd
681
672
assert_raises ( ArgumentError ) { @h . fb_name ( 1234 , :linkd => false ) }
682
673
end
683
-
674
+
684
675
def test_fb_tabs
685
676
assert_equal "<fb:tabs></fb:tabs>" , @h . fb_tabs { }
686
677
end
687
-
678
+
688
679
def test_fb_tab_item
689
680
assert_equal "<fb:tab-item href=\" http://www.google.com\" title=\" Google\" />" , @h . fb_tab_item ( "Google" , "http://www.google.com" )
690
681
end
691
-
682
+
692
683
def test_fb_tab_item_raises_exception_for_invalid_option
693
684
assert_raises ( ArgumentError ) { @h . fb_tab_item ( "Google" , "http://www.google.com" , :alignn => :right ) }
694
685
end
@@ -708,10 +699,6 @@ def test_fb_multi_friend_selector_with_options
708
699
assert_equal "<fb:multi-friend-selector actiontext=\" This is a message\" exclude_ids=\" 1,2\" max=\" 20\" showborder=\" false\" />" , @h . fb_multi_friend_selector ( "This is a message" , :exclude_ids => "1,2" )
709
700
end
710
701
711
- def test_fb_comments
712
- assert_equal "<fb:comments candelete=\" false\" canpost=\" true\" numposts=\" 7\" showform=\" true\" xid=\" a:1\" />" , @h . fb_comments ( "a:1" , true , false , 7 , :showform => true )
713
- end
714
-
715
702
def test_fb_title
716
703
assert_equal "<fb:title>This is the canvas page window title</fb:title>" , @h . fb_title ( "This is the canvas page window title" )
717
704
end
@@ -919,9 +906,15 @@ def test_fb_help
919
906
def test_fb_create_button
920
907
assert_equal "<fb:create-button href=\" /growingpets/invite\" >Invite Friends</fb:create-button>" , @h . fb_create_button ( 'Invite Friends' , '/growingpets/invite' )
921
908
end
922
- def test_fb_comments
923
- assert_equal "<fb:comments candelete=\" false\" canpost=\" true\" numposts=\" 4\" optional=\" false\" xid=\" xxx\" ></fb:comments>" , @h . fb_comments ( "xxx" , true , false , 4 , :optional => false )
909
+
910
+ def test_fb_comments_a_1
911
+ assert_equal "<fb:comments candelete=\" false\" canpost=\" true\" numposts=\" 7\" showform=\" true\" xid=\" a:1\" ></fb:comments>" , @h . fb_comments ( "a:1" , true , false , 7 , :showform => true )
924
912
end
913
+
914
+ def test_fb_comments_xxx
915
+ assert_equal "<fb:comments candelete=\" false\" canpost=\" true\" numposts=\" 4\" optional=\" false\" xid=\" xxx\" ></fb:comments>" , @h . fb_comments ( "xxx" , true , false , 4 , :optional => false )
916
+ end
917
+
925
918
def test_fb_comments_with_title
926
919
assert_equal "<fb:comments candelete=\" false\" canpost=\" true\" numposts=\" 4\" optional=\" false\" xid=\" xxx\" ><fb:title>TITLE</fb:title></fb:comments>" , @h . fb_comments ( "xxx" , true , false , 4 , :optional => false , :title => "TITLE" )
927
920
end
@@ -1003,13 +996,15 @@ def test_fb_user_action
1003
996
action = Facebooker ::Rails ::Publisher ::UserAction . new
1004
997
assert_equal @h . fb_user_action ( action , "message" , "prompt" ) , "FB.Connect.showFeedDialog(null, null, null, null, null, FB.RequireConnect.promptConnect, null, \" prompt\" , \" message\" );"
1005
998
end
1006
-
1007
-
999
+
1000
+
1008
1001
def test_fb_connect_javascript_tag
1009
- assert_equal "<script src=\" http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php\" type=\" text/javascript\" ></script>" ,
1010
- @h . fb_connect_javascript_tag
1002
+ silence_warnings do
1003
+ assert_equal "<script src=\" http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php\" type=\" text/javascript\" ></script>" ,
1004
+ @h . fb_connect_javascript_tag
1005
+ end
1011
1006
end
1012
-
1007
+
1013
1008
def test_fb_container
1014
1009
@h . expects ( :capture ) . returns ( "Inner Stuff" )
1015
1010
@h . fb_container ( :condition => "somejs" ) do
@@ -1157,19 +1152,23 @@ def test_pretty_errors_disabled_success
1157
1152
post :pass , facebook_params
1158
1153
assert_response 200
1159
1154
end
1160
-
1155
+
1161
1156
def test_pretty_errors_disabled_error
1162
1157
Facebooker . apply_configuration ( 'api_key' => "1234" , 'secret_key' => "34278" , 'canvas_page_name' => 'mike' , 'pretty_errors' => false )
1163
- post :fail , facebook_params
1158
+ silence_warnings do
1159
+ post :fail , facebook_params
1160
+ end
1164
1161
assert_response :error
1165
1162
end
1166
-
1163
+
1167
1164
def test_pretty_errors_enabled_success
1168
1165
post :pass , facebook_params
1169
1166
assert_response 200
1170
1167
end
1171
1168
def test_pretty_errors_enabled_error
1172
- post :fail , facebook_params
1169
+ silence_warnings do
1170
+ post :fail , facebook_params
1171
+ end
1173
1172
assert_response 200
1174
1173
end
1175
1174
end
0 commit comments