Module: MiniAuth::TestsAuth

Extended by:
ActiveSupport::Concern
Defined in:
lib/mini_auth/tests_auth.rb

Instance Method Summary collapse

Instance Method Details

#act_as(user, guard = nil) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/mini_auth/tests_auth.rb', line 12

def act_as(user, guard = nil)
  manager = auth_manager
  manager.instance_eval do |s|
    @definitions.unshift({ name: guard || @default_guard, builder: -> (_, _, _) { MiniAuth::TestGuard.new } })
  end

  manager.fetch_guard(ActionDispatch::Request.new({}), guard).login!(user)
end

#actor(guard = nil) ⇒ Object



21
22
23
# File 'lib/mini_auth/tests_auth.rb', line 21

def actor(guard = nil)
  auth_manager.fetch_guard(nil, guard).user
end

#after_teardownObject



7
8
9
10
# File 'lib/mini_auth/tests_auth.rb', line 7

def after_teardown
  MiniAuth::AuthManager.reset!
  super
end