From 82a5be93c6d37f23ce8f574a253c82d4234f6244 Mon Sep 17 00:00:00 2001 From: Dave Iverson Date: Tue, 2 Aug 2022 16:38:59 -0500 Subject: [PATCH] Explain how to use the testing backdoor outside of Rails routes Some projects may want to use the backdoor, but may not be using Rails routes in their system tests. One example is an app that hosts a React frontend, but still uses Clearance cookies for auth. A system test with Capybara may visit a React route like this: `visit "/payment_method"`. The existing documentation didn't show how to use the backdoor with this kind of route. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 0d41136f..a80d3997 100644 --- a/README.md +++ b/README.md @@ -393,6 +393,12 @@ Usage: visit root_path(as: user) ``` +You can even use the backdoor outside of Rails route helpers: + +```ruby +visit "/dashboard?as=#{user.id}" +``` + Additionally, if `User#to_param` is overridden, you can pass a block in order to override the default behavior: