From ae600d4bd63c8b6e2ff9d3622355c2647f5e8058 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Mon, 10 Jun 2024 10:20:05 -0600 Subject: [PATCH] Removes test case on access rights to the products page Moves test on access rights to authentication_spec The test on accessing the products page as an anonymous does not seem specific to the products page (IMO); as we're testing access rights and the Devise gem (right?) we're probably better off having this test in a more suitable and general context, such as as a spec dealing with authentications and redirects --- spec/system/admin/authentication_spec.rb | 32 ++++++++++++++---------- spec/system/admin/products_spec.rb | 6 ----- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/spec/system/admin/authentication_spec.rb b/spec/system/admin/authentication_spec.rb index 74a7d71412..80bedbd3c9 100644 --- a/spec/system/admin/authentication_spec.rb +++ b/spec/system/admin/authentication_spec.rb @@ -10,21 +10,27 @@ RSpec.describe "Authentication" do let(:user) { create(:user, password: "password", password_confirmation: "password") } let!(:enterprise) { create(:enterprise, owner: user) } # Required for access to admin - it "logging into admin redirects home, then back to admin" do - visit spree.admin_dashboard_path + context "as anonymous user" do + it "logging into admin redirects home, then back to admin" do + visit spree.admin_dashboard_path - fill_in "Email", with: user.email - fill_in "Password", with: user.password - click_login_button - expect(page).to have_content "DASHBOARD" - expect(page).to have_current_path spree.admin_dashboard_path - expect(page).not_to have_content "CONFIGURATION" - end + fill_in "Email", with: user.email + fill_in "Password", with: user.password + click_login_button + expect(page).to have_content "DASHBOARD" + expect(page).to have_current_path spree.admin_dashboard_path + expect(page).not_to have_content "CONFIGURATION" + end - it "viewing my account" do - login_to_admin_section - click_link "Account" - expect(page).to have_current_path spree.account_path + it "viewing my account" do + login_to_admin_section + click_link "Account" + expect(page).to have_current_path spree.account_path + end + + it "is redirected to login page when attempting to access product listing" do + expect { visit spree.admin_products_path }.not_to raise_error + end end context "logged in" do diff --git a/spec/system/admin/products_spec.rb b/spec/system/admin/products_spec.rb index c9823e8f03..c979f34b49 100644 --- a/spec/system/admin/products_spec.rb +++ b/spec/system/admin/products_spec.rb @@ -20,12 +20,6 @@ RSpec.describe ' @enterprise_fees = (0..2).map { |i| create(:enterprise_fee, enterprise: @distributors[i]) } end - context "as anonymous user" do - it "is redirected to login page when attempting to access product listing" do - expect { visit spree.admin_products_path }.not_to raise_error - end - end - describe "creating a product" do let!(:tax_category) { create(:tax_category, name: 'Test Tax Category') }