Skip to content

Issues with Manual Login and Logout in Specs #214

@albertski

Description

@albertski

I have a question regarding the login_as helper. I'm using Rails 6 application with Devise (which uses Warden). I have a spec where I want to test the login page as a real user, so I have a method like this:

  def log_in(user)
    visit '/users/login'
    fill_in 'Email', with: user.email
    fill_in 'Password', with: user.password
    click_button 'Login'
  end

The problem is after I logout and then try to go login again. I get an error that I am already signed in. If I use login_as(user, scope: :user) the issue goes away.

Do we have to use the login_as method for proper sign-in/sign-out functionality in specs, or am I missing something in my manual login approach? (Sorry, if this is a Devise question and not a Warden question)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions