Files
openfoodnetwork/spec/support/request/authentication_helper.rb
Maikel Linke 5c6d9a092e Simplify login spec helpers, avoid long lines
The `login_as_admin_and_visit` helper was used a lot but isn't really
shorter than:

    login_as_admin
    visit path_visit

Calling those methods separately reduces line length. It also removes
the potential impression that it may be more efficient to use the
helper. Now we have less indirection if one of the calls fails and see
the failing spec line straight away.
2023-04-17 11:08:32 +10:00

27 lines
601 B
Ruby

# frozen_string_literal: true
module AuthenticationHelper
include Warden::Test::Helpers
def login_as_admin
login_as create(:admin_user)
end
def login_to_admin_section
login_as_admin
visit spree.admin_dashboard_path
end
def fill_in_and_submit_login_form(user)
fill_in "Email", with: user.email
fill_in "Password", with: user.password
click_button "Login"
end
def expect_logged_in
# Ensure page has been reloaded after submitting login form
expect(page).to_not have_selector ".menu #login-link"
expect(page).to_not have_content "Login"
end
end