diff --git a/spec/system/supervisors/edit_spec.rb b/spec/system/supervisors/edit_spec.rb index 3cc71eb0a0..f08a10c900 100644 --- a/spec/system/supervisors/edit_spec.rb +++ b/spec/system/supervisors/edit_spec.rb @@ -6,7 +6,7 @@ context "logged in as an admin" do let(:user) { create(:casa_admin, casa_org: organization) } - it "can edit supervisor by clicking on the edit link from the supervisors list page", :js do + it "can edit supervisor by clicking on the edit link from the supervisors list page" do supervisor_name = "Leslie Knope" create(:supervisor, display_name: supervisor_name, casa_org: organization) sign_in user @@ -22,7 +22,7 @@ expect(page).to have_text("Editing Supervisor") end - it "can edit supervisor by clicking on the supervisor's name from the supervisors list page", :js do + it "can edit supervisor by clicking on the supervisor's name from the supervisors list page" do supervisor_name = "Leslie Knope" create(:supervisor, display_name: supervisor_name, casa_org: organization) sign_in user @@ -84,11 +84,11 @@ visit edit_supervisor_path(supervisor) dismiss_confirm do - find("a[href='#{deactivate_supervisor_path(supervisor)}']").click + click_link "Deactivate Supervisor" end accept_confirm do - find("a[href='#{deactivate_supervisor_path(supervisor)}']").click + click_link "Deactivate Supervisor" end expect(page).to have_text("Supervisor was deactivated on") @@ -110,7 +110,7 @@ expect(inactive_supervisor.reload).to be_active end - it "can resend invitation to a supervisor", :js do + it "can resend invitation to a supervisor" do supervisor = create :supervisor, casa_org: organization sign_in user @@ -126,7 +126,7 @@ expect(deliveries.last.subject).to have_text "CASA Console invitation instructions" end - it "can convert the supervisor to an admin", :js do + it "can convert the supervisor to an admin" do supervisor = create(:supervisor, casa_org_id: organization.id) sign_in user @@ -143,7 +143,7 @@ context "logged in as a supervisor" do let(:supervisor) { create(:supervisor) } - it "can't deactivate a supervisor", :js do + it "can't deactivate a supervisor" do supervisor2 = create :supervisor, casa_org: organization sign_in supervisor @@ -179,14 +179,14 @@ end it "sends a confirmation email to the supervisor and displays current email" do + expect(page).to have_text "Supervisor was successfully updated. Confirmation Email Sent." + expect(page).to have_field("Email", with: @old_email) + expect(@supervisor.unconfirmed_email).to eq("new_supervisor_email@example.com") + expect(ActionMailer::Base.deliveries.count).to eq(1) expect(ActionMailer::Base.deliveries.first).to be_a(Mail::Message) expect(ActionMailer::Base.deliveries.first.body.encoded) .to match("Click here to confirm your email") - - expect(page).to have_text "Supervisor was successfully updated. Confirmation Email Sent." - expect(page).to have_field("Email", with: @old_email) - expect(@supervisor.unconfirmed_email).to eq("new_supervisor_email@example.com") end it "correctly updates the supervisor email once confirmed" do