From dbd79746b16e8435620b205e977afa5da8a33079 Mon Sep 17 00:00:00 2001 From: Samuel Cochran Date: Tue, 3 Jan 2012 09:09:49 +0800 Subject: [PATCH] Fix test behaviour for rspec subject requests --- lib/devise/test_helpers.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/devise/test_helpers.rb b/lib/devise/test_helpers.rb index 959a13d3..0c61acdb 100644 --- a/lib/devise/test_helpers.rb +++ b/lib/devise/test_helpers.rb @@ -15,9 +15,8 @@ module Devise # Override process to consider warden. def process(*) - result = nil - _catch_warden { result = super } - result + # Make sure we always return @response, a la ActionController::TestCase::Behaviour#process, even if warden interrupts + _catch_warden { super } || @response end # We need to setup the environment variables and the response in the controller. @@ -66,6 +65,8 @@ module Devise protected + # Catch warden continuations and handle like the middleware would. + # Returns nil when interrupted, otherwise the normal result of the block. def _catch_warden(&block) result = catch(:warden, &block)