public
Description: The facebooker Rails plugin
Homepage: http://facebooker.rubyforge.org
Clone URL: git://github.com/mmangino/facebooker.git
Added knob for enabling pretty errors (200s instead of 500s) in 
configuration.
costan (author)
Wed Oct 01 00:24:56 -0700 2008
mmangino (committer)
Wed Oct 01 07:13:40 -0700 2008
commit  8393d3732b5512229cd1cca1a4b095acef3e97e0
tree    54c68c725317456b915e4cec697006d41c63de5f
parent  7a5cfc931c31e6088a93909681a43a1ee2acc6b1
...
11
12
13
 
14
15
16
...
11
12
13
14
15
16
17
0
@@ -11,6 +11,7 @@ development:
0
   secret_key:
0
   canvas_page_name:
0
   callback_url:
0
+ pretty_errors: true
0
   tunnel:
0
     public_host_username:
0
     public_host:
...
1
 
2
3
4
...
 
1
2
3
4
0
@@ -1,4 +1,4 @@
0
-if RAILS_ENV=="development"
0
+if Facebooker.facebooker_config['pretty_errors'] || (Facebooker.facebooker_config['pretty_errors'].nil? && RAILS_ENV=="development")
0
   class ActionController::Base
0
     def rescues_path_with_facebooker(template_name)
0
       t="#{RAILS_ROOT}/vendor/plugins/facebooker/templates/#{template_name}.erb"
...
112
113
114
 
 
 
 
 
 
 
 
 
115
116
117
...
949
950
951
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
952
953
954
...
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
...
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
0
@@ -112,6 +112,15 @@ begin
0
     end
0
   end
0
   
0
+ class ControllerWhichFails < ActionController::Base
0
+ def pass
0
+ render :text=>''
0
+ end
0
+ def fail
0
+ raise "I'm failing"
0
+ end
0
+ end
0
+
0
   # you can't use asset_recognize, because it can't pass parameters in to the requests
0
   class UrlRecognitionTests < Test::Unit::TestCase
0
     def test_detects_in_canvas
0
@@ -949,6 +958,36 @@ class RailsFacebookFormbuilderTest < Test::Unit::TestCase
0
     assert_equal "<fb:editor-custom label=\"Friends\"></fb:editor-custom>",@form_builder.multi_friend_input
0
   end
0
 end
0
+
0
+class RailsPrettyErrorsTest < Test::Unit::TestCase
0
+ def setup
0
+ ENV['FACEBOOK_API_KEY'] = '1234567'
0
+ ENV['FACEBOOK_SECRET_KEY'] = '7654321'
0
+ @controller = ControllerWhichFails.new
0
+ @request = ActionController::TestRequest.new
0
+ @response = ActionController::TestResponse.new
0
+ @controller.stubs(:verify_signature).returns(true)
0
+ end
0
+
0
+ def test_pretty_errors
0
+ Facebooker.facebooker_config.stubs(:pretty_errors).returns(false)
0
+ post :pass, example_rails_params_including_fb
0
+ assert_response :success
0
+ post :fail, example_rails_params_including_fb
0
+ assert_response :error
0
+ Facebooker.facebooker_config.stubs(:pretty_errors).returns(true)
0
+ post :pass, example_rails_params_including_fb
0
+ assert_response :success
0
+ post :fail, example_rails_params_including_fb
0
+ assert_response :error
0
+ end
0
+ private
0
+ def example_rails_params_including_fb
0
+ {"fb_sig_time"=>"1186588275.5988", "fb_sig"=>"7371a6400329b229f800a5ecafe03b0a", "action"=>"index", "fb_sig_in_canvas"=>"1", "fb_sig_session_key"=>"c452b5d5d60cbd0a0da82021-744961110", "controller"=>"controller_which_requires_facebook_authentication", "fb_sig_expires"=>"0", "fb_sig_friends"=>"417358,702720,1001170,1530839,3300204,3501584,6217936,9627766,9700907,22701786,33902768,38914148,67400422,135301144,157200364,500103523,500104930,500870819,502149612,502664898,502694695,502852293,502985816,503254091,504510130,504611551,505421674,509229747,511075237,512548373,512830487,517893818,517961878,518890403,523589362,523826914,525812984,531555098,535310228,539339781,541137089,549405288,552706617,564393355,564481279,567640762,568091401,570201702,571469972,573863097,574415114,575543081,578129427,578520568,582262836,582561201,586550659,591631962,592318318,596269347,596663221,597405464,599764847,602995438,606661367,609761260,610544224,620049417,626087078,628803637,632686250,641422291,646763898,649678032,649925863,653288975,654395451,659079771,661794253,665861872,668960554,672481514,675399151,678427115,685772348,686821151,687686894,688506532,689275123,695551670,710631572,710766439,712406081,715741469,718976395,719246649,722747311,725327717,725683968,725831016,727580320,734151780,734595181,737944528,748881410,752244947,763868412,768578853,776596978,789728437,873695441", "fb_sig_added"=>"0", "fb_sig_api_key"=>"b6c9c857ac543ca806f4d3187cd05e09", "fb_sig_user"=>"744961110", "fb_sig_profile_update_time"=>"1180712453"}
0
+ end
0
+
0
+end
0
+
0
 # rescue LoadError
0
 # $stderr.puts "Couldn't find action controller. That's OK. We'll skip it."
0
 end

Comments

    No one has commented yet.