mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
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.
27 lines
601 B
Ruby
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
|