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)
52 53 54 |
# File 'lib/devise/test/integration_helpers.rb', line 52 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.
35 36 37 38 39 |
# File 'lib/devise/test/integration_helpers.rb', line 35 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.
44 45 46 47 48 |
# File 'lib/devise/test/integration_helpers.rb', line 44 def sign_out(resource_or_scope) scope = Devise::Mapping.find_scope!(resource_or_scope) logout scope end |
#teardown_integration_for_devise ⇒ Object (protected)
56 57 58 |
# File 'lib/devise/test/integration_helpers.rb', line 56 def teardown_integration_for_devise Warden.test_reset! end |