From d3f2c72730359b1e6d18a143844b1e770cf9b1de Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 29 Nov 2023 11:20:16 +1100 Subject: [PATCH 1/2] DRY Terms of Service spec to save time The test conditions were already checked in the normal file upload. Run time reduced from 7.2s to 5.8s. --- .../admin/configuration/terms_of_service_files_spec.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/spec/system/admin/configuration/terms_of_service_files_spec.rb b/spec/system/admin/configuration/terms_of_service_files_spec.rb index f917c54dbd..b18488e9dd 100644 --- a/spec/system/admin/configuration/terms_of_service_files_spec.rb +++ b/spec/system/admin/configuration/terms_of_service_files_spec.rb @@ -10,15 +10,12 @@ describe "Terms of Service files" do before { login_as_admin } - it "can be reached via Configuration" do + it "can be uploaded" do visit spree.edit_admin_general_settings_path click_link "Terms of Service" expect(page).to have_content "No terms of services have been uploaded yet." - end - it "can be uploaded" do - visit admin_terms_of_service_files_path attach_file "Attachment", Rails.root.join(test_file_path) click_button "Create Terms of service file" @@ -26,11 +23,6 @@ describe "Terms of Service files" do expect(page).to have_link "Delete file" end - it "provides Rails' standard action for a new file" do - visit new_admin_terms_of_service_files_path - expect(page).to have_button "Create Terms of service file" - end - it "can delete the current file" do attachment = File.open(Rails.root.join(test_file_path)) file = Rack::Test::UploadedFile.new(attachment, "application/pdf") From f6e9bfe15d1655d005d98d75f882282beb9b541b Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 29 Nov 2023 11:23:25 +1100 Subject: [PATCH 2/2] Further simplify Terms of Service spec Since system specs are expensive, the standard workflow can be tested in one "smoke test", as one scenario. Run time reduced from 5.8s to 4.9s. --- .../configuration/terms_of_service_files_spec.rb | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/spec/system/admin/configuration/terms_of_service_files_spec.rb b/spec/system/admin/configuration/terms_of_service_files_spec.rb index b18488e9dd..fad947a089 100644 --- a/spec/system/admin/configuration/terms_of_service_files_spec.rb +++ b/spec/system/admin/configuration/terms_of_service_files_spec.rb @@ -10,7 +10,7 @@ describe "Terms of Service files" do before { login_as_admin } - it "can be uploaded" do + it "can be uploaded and deleted" do visit spree.edit_admin_general_settings_path click_link "Terms of Service" @@ -20,15 +20,6 @@ describe "Terms of Service files" do click_button "Create Terms of service file" expect(page).to have_link "Terms of Service" - expect(page).to have_link "Delete file" - end - - it "can delete the current file" do - attachment = File.open(Rails.root.join(test_file_path)) - file = Rack::Test::UploadedFile.new(attachment, "application/pdf") - TermsOfServiceFile.create!(attachment: file) - - visit admin_terms_of_service_files_path accept_alert { click_link "Delete" }