Module: Devise::Test::IntegrationHelpers
- Defined in:
- lib/devise/test/integration_helpers.rb
Instance Method Summary collapse
- #setup_integration_for_devise ⇒ Object protected
-
#sign_in(resource, scope: nil) ⇒ Object
Signs in a specific resource, mimicking a successfull sign in operation through Devise::SessionsController#create.
-
#sign_out(resource_or_scope) ⇒ Object
Signs out a specific scope from the session.
- #teardown_integration_for_devise ⇒ Object protected
Instance Method Details
#setup_integration_for_devise ⇒ Object (protected)
54 55 56 |
# File 'lib/devise/test/integration_helpers.rb', line 54 def setup_integration_for_devise Warden.test_mode! end |
#sign_in(resource, scope: nil) ⇒ Object
Signs in a specific resource, mimicking a successfull 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 |
#teardown_integration_for_devise ⇒ Object (protected)
58 59 60 |
# File 'lib/devise/test/integration_helpers.rb', line 58 def teardown_integration_for_devise Warden.test_reset! end |