Method: Devise::Test::ControllerHelpers#_catch_warden

Defined in:
lib/devise/test/controller_helpers.rb

#_catch_warden(&block) ⇒ Object (protected)

Catch warden continuations and handle like the middleware would. Returns nil when interrupted, otherwise the normal result of the block.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/devise/test/controller_helpers.rb', line 103

def _catch_warden(&block)
  result = catch(:warden, &block)

  env = @controller.request.env

  result ||= {}

  # Set the response. In production, the rack result is returned
  # from Warden::Manager#call, which the following is modelled on.
  case result
  when Array
    if result.first == 401 && intercept_401?(env) # does this happen during testing?
      _process_unauthenticated(env)
    else
      result
    end
  when Hash
    _process_unauthenticated(env, result)
  else
    result
  end
end