search for: rescue_act

Displaying 20 results from an estimated 49 matches for "rescue_act".

2007 Oct 07
0
Is there a way to use the rescue_action defined in a controller in the controller''s specs?
Heyho, I start to discover RSpec but it seems that just on my second day I ran into some strange trouble with the rescue_action of my controllers. Just like in Rails 2.0 where there is a rescue_from Exception, :with => :foo_method thing to rescue exception thrown in actions in the production environment, I did a little helper that rescues my action exceptions with a defined class. For example if a login fails for so...
2007 May 23
8
Rails Rendering diagnostics.rhtml in Controller Spec
Forgive me if this isn''t the proper list. It''s specific to the rSpec Rails plugin. The problem is, some controller actions are rendering the "diagnostics.rhtml" template when I''m expecting it to render something else in a controller spec. I''m assuming this is the template that displays the error message and a stack trace when an error is raised in the
2006 Jun 30
1
Taking Control of Un-handled Exceptions
Greetings, I''m trying to catch all un-handled exceptions. I''m having problems handling the RoutingError and UnknownAction exceptions. I''ve added the following to my application controller as a protected method: def rescue_action(exception) render(:text => "error") end As far as I understand, this should catch all uncaught exceptions and override the rails default "rescue_action" method. However, anytime a RoutingError occurs, the "app_root/public/404.html" file gets displayed. Th...
2006 Feb 26
0
rescue_action with RoutingError not loading ApplicationController/ApplicationHelper
Why is it that when rescue_action is called with any exception except for RoutingError, "self" refers to a controller within my application, but when there''s a RoutingError, "self" refers to an object of ActionController::Base? This makes some sense because a "RoutingError" implies that no...
2006 Oct 26
0
rescue_action overridden
In rspec_on_rails, method setup_with_controller, exists the following line: @controller_class.send(:define_method, :rescue_action) { | e| raise e } I understand that this is a better way to handle errors than the default. However, it gets in the way when you''ve defined your own rescue_action and are trying to test it. No good solutions came to me while I pondered the problem. Anyhow, there it is. Micah...
2009 Jun 16
1
[PATCH server] Fix errors in controller tests.
...b/src/test/functional/host_controller_test.rb index caf198d..dc9891c 100644 --- a/src/test/functional/host_controller_test.rb +++ b/src/test/functional/host_controller_test.rb @@ -23,7 +23,7 @@ require 'host_controller' # Re-raise errors caught by the controller. class HostController; def rescue_action(e) raise e end; end -class HostControllerTest < Test::Unit::TestCase +class HostControllerTest < ActionController::TestCase fixtures :hosts, :pools, :privileges, :roles, :permissions def setup diff --git a/src/test/functional/nic_controller_test.rb b/src/test/functional/nic_contr...
2007 May 20
9
How to test for exceptions
...missed. Thanks in advance, Blake describe VenuesController, "on update" do before(:each) do @venue = mock("venue") @venue.stub!(:new_record?).and_return(false) @venue.stub!(:to_param).and_return(''1'') controller.class.send(:define_method, :rescue_action) { |e| raise e } end it "should raise an error if record is invalid" do stub_authorized_login Venue.should_receive(:find).and_return(@venue) @venue.should_receive(:update_attributes!).with("name" => "random text").and_return(false) lambda {po...
2007 Jan 11
0
writing tests for rescue_action_in_public
I''m having trouble with rescue_action_in_public, both in getting it to work right in my rails app, and in writing tests to make sure. What I ultimately want to do is test for what a normal user would see when an error is trapped. I override local_request? like so: application.rb -------------- def rescue_action_in_public(exc...
2007 Oct 11
0
Custom rescue_action_* methods not being called?
All, Rails 1.1.6 Ruby 1.8.6 Win XP It appears that none of my rescue_action_* methods, if defined in my application.rb file, are being called. I''ve placed debug statements inside of the ActionController Rescue module to verify that rescue_action is being called. Here are my overrides in application.rb, none of which are being called - they are all protected v...
2007 Nov 13
7
rails story runner returning a nil response code
Has anyone noticed any problems with the Rails story runner returning a response code of "0" when doing get/post/etc methods? I just grabbed the latest rails/rspec and just started noticing this problem, http://pastie.caboo.se/117497 Regular controller specs pass as expected. -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com
2005 Dec 11
7
Catching Exceptions in ActionController
I''d like to be able to catch ActionController::MissingTemplate exceptions from within ActionControlle, *but*, MissingTemplate isn''t defined within my controllers!!! How is that possible - after all, all controller subclass ActionController, so how are exceptions it defines not there!? More importantly, how can I do this? -- Posted via http://www.ruby-forum.com/.
2007 Apr 17
8
problem with rspec_on_rails and @controller.should_receive(:render) in trunk
Hey guys! I am using rspec trunk, and I am having a little problem with the latest version. (I am quite sure this worked with an older version about a week ago) heres the spec: it "should render the new user form without layout for a xhr request" do @controller.should_receive(:render).with(:layout=>false) xhr :get,:new end and the controller: def new render
2008 Apr 30
7
rescue_from issue with AWS - uninitialized constant
...AWS interfers with the inheritance chain I guess, but if I define: <b>rescue_from Object::ActionController::RoutingError, :with => :page_not_found</b> I get no errors, but then the rescue_from method isn''t invoked either. Anyone got any advice? I can get around this with rescue_action_in_public, but thats just not as nice. Cheers, --Kip --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF...
2009 Dec 25
18
rescue_from ActionController::RoutingError II
OK ... so I''m not supposed to use it but ... Why doesn''t rescue_from ActionController::RoutingError work witht he code from http://www.rubyplus.org/episodes/20-Extended-RESTful-Authentication-Rails-2-App.html class ApplicationController < ActionController::Base helper :all # include all helpers, all the time # See ActionController::RequestForgeryProtection for details
2006 Feb 01
3
Testing components
...functional tests for them fail. Trying to duplicate my normal controller tests I have: require File.dirname(__FILE__) + ''/../test_helper'' require File.dirname(__FILE__) + ''news_controller'' # Re-raise errors caught by the controller. class NewsController; def rescue_action(e) raise e end; end class NewsControllerTest < Test::Unit::TestCase def setup @controller = NewsController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end # Replace this with your real tests. def test_content g...
2006 Dec 04
2
begin, rescue, end for the whole darn app
Hello. Imagine how paranoid and ugly code would look if one put a ''begin,rescue, end'' in every action in the app... With server, mysql, etc errors, is there a way to rescue anything weird when (not if :( ) it were to ever happen? Thoughts? Dominic -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message
2006 Jan 10
4
Problem creating MockController
...I''m trying to create a mock controller to test the use of UrlHelper in ActionMailer. I''m trying this: require ''d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller'' # Re-raise errors caught by the controller. #class DiscussionsController; def rescue_action(e) raise e end; end class MockController < ActionController::Base def initialize @url = UrlRewriter.new(ActionController::TestRequest.new, nil) super end end because if I just do require ''action_controller'' I get a no such file error. Problem with this mock is that I get...
2007 Oct 16
5
RailsStory - lessons learned
After trying RailsStory for a few days, I have learned: 1. Rails testing support does not serve up static pages 2. RailsStory masks errors generated by the app under test 3. The masked errors are available in log/test 4. I should read log/test more often See http://pastie.caboo.se/107876 for an example for points 2 and 3 The welcome controller fails when the HTTP_USER_AGENT is missing.
2006 Oct 12
2
Test should fail !
...really executed by the test suite, I can see it in the screen output of rake Which mistery is this ? Thanks require File.dirname(__FILE__) + ''/../test_helper'' require ''alerts_controller'' # Re-raise errors caught by the controller. class AlertsController; def rescue_action(e) raise e end; end class AlertsControllerTest < Test::Unit::TestCase fixtures :clients def setup @controller = AlertsController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end def test_get_index get :index...
2005 Dec 21
2
Missing error page templates
...ib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/base.rb:195:in `multilingual_old_render_file'' /vendor/plugins/multilingual/lib/multilingual/rails/action_view.rb:15:in `render_file'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:73:in `rescue_action_locally'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:31:in `rescue_action'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:108:in `perform_action'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/...