Class: Clearance::BackDoor
- Inherits:
-
Object
- Object
- Clearance::BackDoor
- Defined in:
- lib/clearance/back_door.rb
Overview
Middleware which allows signing in by passing as=USER_ID in a query parameter.
Designed to eliminate time in integration tests wasted by visiting and submitting the sign in form.
Configuration:
# config/environments/test.rb MyRailsApp::Application.configure do # ... config.middleware.use Clearance::BackDoor # ... end
Usage:
visit new_feedback_path(as: user)
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ BackDoor
constructor
A new instance of BackDoor.
Constructor Details
#initialize(app) ⇒ BackDoor
Returns a new instance of BackDoor.
21 22 23 |
# File 'lib/clearance/back_door.rb', line 21 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
25 26 27 28 |
# File 'lib/clearance/back_door.rb', line 25 def call(env) sign_in_through_the_back_door(env) @app.call(env) end |