From 63956b89e7c7e3b8357a1b9a5e40788c50c0edfc Mon Sep 17 00:00:00 2001 From: Alan Covarrubias Date: Tue, 8 Apr 2025 22:23:43 -0700 Subject: [PATCH] update casa_admins/edit_spec.rb to account for race condition --- spec/system/casa_admins/edit_spec.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/spec/system/casa_admins/edit_spec.rb b/spec/system/casa_admins/edit_spec.rb index 26ff9ae3ab..210f65f784 100644 --- a/spec/system/casa_admins/edit_spec.rb +++ b/spec/system/casa_admins/edit_spec.rb @@ -9,7 +9,7 @@ it "can successfully edit user display name and phone number" do expected_display_name = "Root Admin" expected_phone_number = "+14398761234" - expected_date_of_birth = "1997/04/16" + expected_date_of_birth = "1997-04-16" visit edit_casa_admin_path(admin) @@ -20,14 +20,11 @@ click_on "Submit" - admin.reload - expect(page).to have_text "Casa Admin was successfully updated." - - expect(admin.display_name).to eq expected_display_name - expect(admin.phone_number).to eq expected_phone_number - expect(admin.date_of_birth.strftime("%Y/%m/%d")).to eq expected_date_of_birth - expect(admin.monthly_learning_hours_report).to be_truthy + expect(page).to have_field "Display name", with: expected_display_name + expect(page).to have_field "Phone number", with: expected_phone_number + expect(page).to have_field "Date of birth", with: expected_date_of_birth + expect(page).to have_checked_field("Receive Monthly Learning Hours Report") end end @@ -49,15 +46,16 @@ expect(page).to have_text "Admin was successfully updated. Confirmation Email Sent." expect(page).to have_field("Email", with: @old_email) + admin.reload expect(admin.unconfirmed_email).to eq("new_admin_email@example.com") end it "succesfully updates the user email once the user confirms the changes" do admin.confirm - admin.reload visit edit_casa_admin_path(admin) expect(page).to have_field("Email", with: "new_admin_email@example.com") + admin.reload expect(admin.old_emails).to eq([@old_email]) end end