From 8d500a2c277bc4a009eb31dc0e1d7e9e5e16d9c8 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 29 Mar 2023 16:16:44 +1100 Subject: [PATCH] Remove superflouous login test helper It was often used with a `visit` statement after which resulted in unnecessary page loads. There was only one case where a `visit` was expected but it wasn't needed either. --- spec/support/request/authentication_helper.rb | 5 ----- spec/system/admin/bulk_product_update_spec.rb | 2 +- spec/system/admin/order_cycles/simple_spec.rb | 6 +++--- spec/system/admin/orders_spec.rb | 2 +- spec/system/admin/reports/orders_and_fulfillment_spec.rb | 6 +++--- spec/system/admin/reports_spec.rb | 4 ++-- 6 files changed, 10 insertions(+), 15 deletions(-) diff --git a/spec/support/request/authentication_helper.rb b/spec/support/request/authentication_helper.rb index ee1aaa4ebe..ff4905286c 100644 --- a/spec/support/request/authentication_helper.rb +++ b/spec/support/request/authentication_helper.rb @@ -16,11 +16,6 @@ module AuthenticationHelper login_as_admin_and_visit(spree.admin_dashboard_path) end - def login_to_admin_as(user) - login_as user - 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 diff --git a/spec/system/admin/bulk_product_update_spec.rb b/spec/system/admin/bulk_product_update_spec.rb index 3649842832..8417ca27bf 100644 --- a/spec/system/admin/bulk_product_update_spec.rb +++ b/spec/system/admin/bulk_product_update_spec.rb @@ -785,7 +785,7 @@ describe ' @enterprise_user.enterprise_roles.build(enterprise: supplier_managed2).save @enterprise_user.enterprise_roles.build(enterprise: distributor_managed).save - login_to_admin_as @enterprise_user + login_as @enterprise_user end it "shows only products that I supply" do diff --git a/spec/system/admin/order_cycles/simple_spec.rb b/spec/system/admin/order_cycles/simple_spec.rb index 3f3541de41..dfb1b03e14 100644 --- a/spec/system/admin/order_cycles/simple_spec.rb +++ b/spec/system/admin/order_cycles/simple_spec.rb @@ -384,7 +384,7 @@ describe ' before do new_user.enterprise_roles.build(enterprise: supplier_managed).save - login_to_admin_as new_user + login_as new_user end it "editing an order cycle" do @@ -467,7 +467,7 @@ describe ' permissions_list: [:add_to_order_cycle]) new_user.enterprise_roles.build(enterprise: my_distributor).save - login_to_admin_as new_user + login_as new_user end it "editing an order cycle" do @@ -555,7 +555,7 @@ describe ' before do user.enterprise_roles.create! enterprise: enterprise - login_to_admin_as user + login_as user end it "shows me an index of order cycles without enterprise columns" do diff --git a/spec/system/admin/orders_spec.rb b/spec/system/admin/orders_spec.rb index 307248e926..79a4874792 100644 --- a/spec/system/admin/orders_spec.rb +++ b/spec/system/admin/orders_spec.rb @@ -539,7 +539,7 @@ distributors: [distributor4, distributor5]) } context "for a hub manager" do before do - login_to_admin_as owner2 + login_as owner2 visit spree.admin_orders_path end diff --git a/spec/system/admin/reports/orders_and_fulfillment_spec.rb b/spec/system/admin/reports/orders_and_fulfillment_spec.rb index 8874424913..72a425c35d 100644 --- a/spec/system/admin/reports/orders_and_fulfillment_spec.rb +++ b/spec/system/admin/reports/orders_and_fulfillment_spec.rb @@ -10,7 +10,7 @@ describe "Orders And Fulfillment" do let(:current_user) { create(:admin_user) } before do - login_to_admin_as(current_user) + login_as(current_user) visit admin_reports_path end @@ -553,7 +553,7 @@ describe "Orders And Fulfillment" do click_button 'Go' logout - login_to_admin_as(current_user) + login_as(current_user) visit admin_reports_path click_link report_title @@ -573,7 +573,7 @@ describe "Orders And Fulfillment" do click_button 'Go' logout - login_to_admin_as(current_user) + login_as(current_user) visit admin_reports_path click_link "Report" diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index 0e255bbdb1..5b117c9064 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -16,8 +16,8 @@ describe ' end it "does not show super admin only report" do - login_to_admin_as user - click_link "Reports" + login_as user + visit admin_reports_path expect(page).not_to have_content "Users & Enterprises" end end