ref: refs/heads/master
commit b8461742b5f58e9fb236351278f84c2e70c49107
Author: Josef Reidinger
Date: Tue Nov 3 17:18:19 2009 +0100
add tests for rescue_from in application controller
---
.../test/functional/raising_controller_test.rb | 57 ++++++++++++++++++++
1 files changed, 57 insertions(+), 0 deletions(-)
diff --git a/webservice/test/functional/raising_controller_test.rb b/webservice/test/functional/raising_controller_test.rb
new file mode 100644
index 0000000..8a4f653
--- /dev/null
+++ b/webservice/test/functional/raising_controller_test.rb
@@ -0,0 +1,57 @@
+require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
+
+class RaisingControllerTest < ActionController::TestCase
+
+ class RaisingController < ApplicationController
+ def raiseNotFound
+ raise YaST::ConfigFile::NotFoundError.new("/dev/null") #frozen hell
+ end
+
+ def raiseInvalidParameters
+ raise InvalidParameters.new( :heaven => "MISSING" )
+ end
+
+ def raiseBackendException
+ raise BackendException
+ end
+
+ def raiseException
+ raise "WTF?"
+ end
+ end
+
+ def setup
+ @controller = RaisingController.new
+ @routes = ActionController::Routing::Routes.routes.dup
+ # add a catch-all route for the tests only.
+ ActionController::Routing::Routes.draw {
+ |map| map.connect ':controller/:action'
+ }
+ end
+
+ def teardown
+ #restore original routes to not affect other tests
+ ActionController::Routing::Routes.routes = @routes
+ end
+
+ def test_catch_not_found
+ get :raiseNotFound
+ assert_response 503
+ end
+
+ def test_catch_invalid
+ get :raiseInvalidParameters
+ assert_response 422
+ end
+
+ def test_catch_backend_exception
+ get :raiseBackendException
+ assert_response 503
+ end
+
+ def test_catch_exception
+ get :raiseException
+ assert_response 500
+ end
+
+end
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org