From 24ac9fa987c29bc72573ab7a86847f560b79dee7 Mon Sep 17 00:00:00 2001 From: Vishal Sadriya Date: Mon, 16 Feb 2026 18:23:05 +0530 Subject: [PATCH] Replace non-webpage expects with page-level assertions in all_casa_admins system specs Fixes #6694 --- .../system/all_casa_admins/all_casa_admin_spec.rb | 15 +-------------- spec/system/all_casa_admins/sessions/new_spec.rb | 7 ++++++- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/spec/system/all_casa_admins/all_casa_admin_spec.rb b/spec/system/all_casa_admins/all_casa_admin_spec.rb index 36903a720a..cf5ad09035 100644 --- a/spec/system/all_casa_admins/all_casa_admin_spec.rb +++ b/spec/system/all_casa_admins/all_casa_admin_spec.rb @@ -52,8 +52,7 @@ fill_in "Address", with: "123 Main St" click_on "Create CASA Organization" expect(page).to have_text "CASA Organization was successfully created." - organization = CasaOrg.find_by(name: "Cool Org Name") - expect(page).to have_current_path "/all_casa_admins/casa_orgs/#{organization.id}", ignore_query: true + expect(page).to have_current_path(%r{/all_casa_admins/casa_orgs/\d+}, ignore_query: true) expect(page).to have_content "Administrators" expect(page).to have_content "Details" expect(page).to have_content "Number of admins: 0" @@ -92,8 +91,6 @@ fill_in "Display name", with: "Freddy Valid" click_button "Submit" expect(page).to have_content "Email has already been taken" - - expect(CasaAdmin.find_by(email: "valid@example.com").invitation_created_at).not_to be_nil end it "edits all casa admins" do @@ -112,7 +109,6 @@ fill_in "all_casa_admin_email", with: "newemail@example.com" click_on "Update Profile" expect(page).to have_text "successfully updated" - expect(ActionMailer::Base.deliveries.last.body.encoded).to match(">Your CASA account's email has been updated to newemail@example.com") # change password click_on "Change Password" @@ -126,14 +122,5 @@ fill_in "all_casa_admin_password_confirmation", with: "newpassword" click_on "Update Password" expect(page).to have_text "Password was successfully updated." - expect(ActionMailer::Base.deliveries.last.body.encoded).to match("Your CASA password has been changed.") - end - - it "admin invitations expire" do - all_casa_admin = AllCasaAdmin.invite!(email: "valid@email.com") - travel 2.days - expect(all_casa_admin.valid_invitation?).to be true - travel 8.days - expect(all_casa_admin.valid_invitation?).to be false end end diff --git a/spec/system/all_casa_admins/sessions/new_spec.rb b/spec/system/all_casa_admins/sessions/new_spec.rb index 08a62800ce..9a48cb5e1e 100644 --- a/spec/system/all_casa_admins/sessions/new_spec.rb +++ b/spec/system/all_casa_admins/sessions/new_spec.rb @@ -57,7 +57,12 @@ end it "denies access to flipper" do - expect { visit "/flipper" }.to raise_error(ActionController::RoutingError) + original = Rails.application.env_config["action_dispatch.show_exceptions"] + Rails.application.env_config["action_dispatch.show_exceptions"] = :rescuable + visit "/flipper" + expect(page).to have_text "No route matches [GET] \"/flipper\"" + ensure + Rails.application.env_config["action_dispatch.show_exceptions"] = original end end end