Module: Devise::Test::IntegrationHelpers
- Defined in:
- lib/devise/test/integration_helpers.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#sign_in(resource, scope: nil) ⇒ Object
Signs in a specific resource, mimicking a successful sign in operation through Devise::SessionsController#create.
-
#sign_out(resource_or_scope) ⇒ Object
Signs out a specific scope from the session.
Class Method Details
.included(base) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/devise/test/integration_helpers.rb', line 22 def self.included(base) base.class_eval do include Warden::Test::Helpers setup :setup_integration_for_devise teardown :teardown_integration_for_devise end end |
Instance Method Details
#sign_in(resource, scope: nil) ⇒ Object
Signs in a specific resource, mimicking a successful sign in operation through Devise::SessionsController#create.
-
resource
- The resource that should be authenticated -
scope
- An optionalSymbol
with the scope where the resourceshould be signed in with.
37 38 39 40 41 |
# File 'lib/devise/test/integration_helpers.rb', line 37 def sign_in(resource, scope: nil) scope ||= Devise::Mapping.find_scope!(resource) login_as(resource, scope: scope) end |
#sign_out(resource_or_scope) ⇒ Object
Signs out a specific scope from the session.
-
resource_or_scope
- The resource or scope that should be signed out.
46 47 48 49 50 |
# File 'lib/devise/test/integration_helpers.rb', line 46 def sign_out(resource_or_scope) scope = Devise::Mapping.find_scope!(resource_or_scope) logout scope end |