Skip to content

Commit 4afee2d

Browse files
check for the page first
1 parent 91470ae commit 4afee2d

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

spec/system/volunteers/edit_spec.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,15 @@
125125

126126
fill_in "Email", with: "newemail@example.com"
127127
click_on "Submit"
128-
volunteer.reload
128+
129+
expect(page).to have_text "Volunteer was successfully updated. Confirmation Email Sent."
130+
expect(page).to have_field("Email", with: old_email)
131+
expect(volunteer.reload.unconfirmed_email).to eq("newemail@example.com")
129132

130133
expect(ActionMailer::Base.deliveries.count).to eq(1)
131134
expect(ActionMailer::Base.deliveries.first).to be_a(Mail::Message)
132135
expect(ActionMailer::Base.deliveries.first.body.encoded)
133136
.to match("Click here to confirm your email")
134-
135-
expect(page).to have_text "Volunteer was successfully updated. Confirmation Email Sent."
136-
expect(page).to have_field("Email", with: old_email)
137-
expect(volunteer.unconfirmed_email).to eq("newemail@example.com")
138137
end
139138

140139
it "succesfully displays the new email once the user confirms" do
@@ -442,6 +441,8 @@
442441
uncheck "with_cc"
443442
click_on "Send Reminder"
444443

444+
expect(page).to have_content("Reminder sent to volunteer")
445+
445446
expect(ActionMailer::Base.deliveries.count).to eq(1)
446447
expect(ActionMailer::Base.deliveries.first.cc).to be_empty
447448
end
@@ -456,6 +457,8 @@
456457
check "with_cc"
457458
click_on "Send Reminder"
458459

460+
expect(page).to have_content("Reminder sent to volunteer")
461+
459462
expect(ActionMailer::Base.deliveries.count).to eq(1)
460463
expect(ActionMailer::Base.deliveries.first.cc).to include(volunteer.supervisor.email)
461464
end
@@ -471,6 +474,8 @@
471474
check "with_cc"
472475
click_on "Send Reminder"
473476

477+
expect(page).to have_content("Reminder sent to volunteer")
478+
474479
expect(ActionMailer::Base.deliveries.count).to eq(1)
475480
expect(ActionMailer::Base.deliveries.first.cc).to be_empty
476481
end
@@ -490,6 +495,8 @@
490495

491496
click_on "Send Reminder"
492497

498+
expect(page).to have_content("Reminder sent to volunteer")
499+
493500
expect(ActionMailer::Base.deliveries.count).to eq(1)
494501
end
495502

@@ -502,6 +509,8 @@
502509
visit edit_volunteer_path(volunteer)
503510
check "with_cc"
504511
click_on "Send Reminder"
512+
513+
expect(page).to have_content("Reminder sent to volunteer")
505514

506515
expect(ActionMailer::Base.deliveries.count).to eq(1)
507516
expect(ActionMailer::Base.deliveries.first.cc).to include(volunteer.supervisor.email)

0 commit comments

Comments
 (0)