clearance icon indicating copy to clipboard operation
clearance copied to clipboard

The backdoor for testing doesn't work with follow redirects

Open msayed98 opened this issue 3 years ago • 4 comments

When using the clearance backdoor for testing, and using as user, when following redirects by clicking on links, it doesn't continue with the same user, making this backdoor useless, and you can't use as in follow_redirect! or click_on for example here is a simple test that that is created by using the rails scaffold generator, and it fails because click on leads to a redirect

test "creating a Car" do
    visit cars_url(as: @user)
    click_on "New Car"

    fill_in "Make", with: @car.make
    fill_in "Model", with: @car.model
    fill_in "Year", with: @car.year
    click_on "Create Car"

    assert_text "Car was successfully created"
    click_on "Back"
  end

and here is a repository I created for reproducing this issue, it contains just a minimal created rails app with users and cars scaffold, you can just run the tests by ralis test:system and it would fail

msayed98 avatar Oct 16 '22 11:10 msayed98

I am facing the same issue upon upgrading to Rails7

coorasse avatar Feb 02 '23 08:02 coorasse

Just hit the same issue. Not clear how to make clearance work with system tests…

avk avatar May 15 '24 15:05 avk