Method: Devise::Test::ControllerHelpers#sign_in

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

#sign_in(resource, deprecated = nil, scope: nil) ⇒ Object

sign_in a given resource by storing its keys in the session. This method bypass any warden authentication callback.

  • resource - The resource that should be authenticated

  • scope - An optional Symbol with the scope where the resource

    should be signed in with.
    

Examples:

sign_in users(:alice) sign_in users(:alice), scope: :admin



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/devise/test/controller_helpers.rb', line 67

def (resource, deprecated = nil, scope: nil)
  if deprecated.present?
    scope = resource
    resource = deprecated

    Devise.deprecator.warn "      [Devise] sign_in(:\#{scope}, resource) on controller tests is deprecated and will be removed from Devise.\n      Please use sign_in(resource, scope: :\#{scope}) instead.\n    DEPRECATION\n  end\n\n  scope ||= Devise::Mapping.find_scope!(resource)\n\n  warden.instance_variable_get(:@users).delete(scope)\n  warden.session_serializer.store(resource, scope)\nend\n".strip_heredoc