Skip to content

Commit 6871686

Browse files
stefannibrasilcompwron
authored andcommitted
Check for page assertions before DB checks
Also, check for what the user sees in the page.
1 parent acd55ca commit 6871686

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

spec/system/volunteers/invite_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
fill_in "Display name", with: "Jane Doe"
1717
fill_in "Date of birth", with: Date.new(1995, 5, 15)
1818

19-
expect {
20-
click_on "Create Volunteer"
21-
}.to change(Volunteer, :count).by(1)
19+
click_on "Create Volunteer"
20+
21+
expect(page).to have_selector(".notice", text: "New volunteer created successfully")
2222

2323
volunteer = Volunteer.find_by(email: "new_volunteer@example.com")
2424
expect(volunteer).to be_present
@@ -41,6 +41,8 @@
4141

4242
click_on "Create Volunteer"
4343

44+
expect(page).to have_selector(".notice", text: "New volunteer created successfully")
45+
4446
volunteer = Volunteer.find_by(email: "volunteer_with_token@example.com")
4547
expect(volunteer.invitation_created_at).to be_present
4648
expect(volunteer.invitation_accepted_at).to be_nil
@@ -77,11 +79,11 @@
7779

7880
click_on "Set my password"
7981

82+
expect(page).to have_selector(".notice", text: "Your password was set successfully. You are now signed in")
83+
expect(page).to have_text("My Cases")
84+
8085
volunteer.reload
8186
expect(volunteer.invitation_accepted_at).not_to be_nil
82-
83-
# Should be redirected to dashboard after accepting invitation
84-
expect(page).to have_text("My Cases")
8587
end
8688

8789
it "shows error when passwords don't match" do
@@ -137,9 +139,7 @@
137139
it "allows admin to resend invitation to volunteer who hasn't accepted" do
138140
visit edit_volunteer_path(volunteer)
139141

140-
expect {
141-
click_on "Resend Invitation"
142-
}.to change { ActionMailer::Base.deliveries.count }.by(1)
142+
click_on "Resend Invitation"
143143

144144
expect(page).to have_text "Invitation sent"
145145

@@ -172,9 +172,9 @@
172172
fill_in "Display name", with: "Supervisor's Volunteer"
173173
fill_in "Date of birth", with: Date.new(1992, 3, 20)
174174

175-
expect {
176-
click_on "Create Volunteer"
177-
}.to change(Volunteer, :count).by(1)
175+
click_on "Create Volunteer"
176+
177+
expect(page).to have_selector(".notice", text: "New volunteer created successfully")
178178

179179
volunteer = Volunteer.find_by(email: "supervisor_volunteer@example.com")
180180
expect(volunteer).to be_present

0 commit comments

Comments
 (0)