|
70 | 70 | hours: 1, minutes: 45 |
71 | 71 | ) |
72 | 72 |
|
73 | | - expect { click_on "Submit" }.not_to change(CaseContact, :count) |
| 73 | + expect do |
| 74 | + click_on "Submit" |
| 75 | + expect(page).to have_text("Medium type can't be blank") |
| 76 | + end.not_to change(CaseContact, :count) |
74 | 77 |
|
75 | | - expect(page).to have_text("Medium type can't be blank") |
76 | 78 |
|
77 | 79 | expect(page).to have_field("case_contact_duration_hours", with: 1) |
78 | 80 | expect(page).to have_field("case_contact_duration_minutes", with: 45) |
|
83 | 85 |
|
84 | 86 | describe "contact types" do |
85 | 87 | # TODO: Fix this test |
86 | | - xit "requires a contact type" do |
| 88 | + it "requires a contact type" do |
87 | 89 | subject |
88 | 90 |
|
89 | 91 | fill_in_contact_details(contact_types: nil) |
90 | 92 |
|
91 | | - expect { click_on "Submit" }.to not_change(CaseContact.active, :count) |
92 | | - expect(page).to have_text("Contact Type must be selected") |
| 93 | + expect do |
| 94 | + click_on "Submit" |
| 95 | + expect(page).to have_text("Contact Type must be selected") |
| 96 | + end.to not_change(CaseContact.active, :count) |
| 97 | + |
93 | 98 | check contact_types.first.name |
94 | | - expect { click_on "Submit" }.to change(CaseContact.active, :count).by(1) |
| 99 | + expect do |
| 100 | + click_on "Submit" |
| 101 | + expect(page).to have_text("Case contact successfully created.") |
| 102 | + end.to change(CaseContact.active, :count).by(1) |
95 | 103 | end |
96 | 104 |
|
97 | 105 | it "does not display empty contact groups or hidden contact types" do |
|
180 | 188 |
|
181 | 189 | context "when org has no contact topics" do |
182 | 190 | # TODO: Fix this test |
183 | | - xit "allows entering contact notes" do |
| 191 | + it "allows entering contact notes" do |
184 | 192 | expect(casa_org.contact_topics.size).to eq 0 |
185 | 193 | subject |
186 | 194 |
|
|
190 | 198 |
|
191 | 199 | expect { |
192 | 200 | click_on "Submit" |
| 201 | + expect(page).to have_text("Case contact successfully created.") |
193 | 202 | }.to change(CaseContact.active, :count).by(1) |
194 | 203 |
|
195 | 204 | case_contact = CaseContact.active.last |
|
268 | 277 | fill_in volunteer_address_input, with: "123 Example St" |
269 | 278 | uncheck reimbursement_checkbox |
270 | 279 |
|
271 | | - expect { click_on "Submit" }.to change(CaseContact.active, :count).by(1) |
| 280 | + expect { |
| 281 | + click_on "Submit" |
| 282 | + expect(page).to have_text("Case contact successfully created.") |
| 283 | + }.to change(CaseContact.active, :count).by(1) |
272 | 284 | case_contact = CaseContact.active.last |
273 | 285 |
|
274 | 286 | expect(case_contact.want_driving_reimbursement).to be false |
275 | 287 | expect(case_contact.miles_driven).to be_zero |
276 | 288 | end |
277 | 289 |
|
278 | | - xit "saves mileage and address information" do # TODO make test not flaky |
| 290 | + it "saves mileage and address information" do # TODO make test not flaky |
279 | 291 | subject |
280 | 292 | fill_in_contact_details contact_types: %w[School] |
281 | 293 |
|
|
284 | 296 | fill_in miles_driven_input, with: 50 |
285 | 297 | fill_in volunteer_address_input, with: "123 Example St" |
286 | 298 |
|
287 | | - expect { click_on "Submit" }.to change(CaseContact.active, :count).by(1) |
| 299 | + expect { |
| 300 | + click_on "Submit" |
| 301 | + expect(page).to have_text("Case contact successfully created.") |
| 302 | + }.to change(CaseContact.active, :count).by(1) |
288 | 303 | case_contact = CaseContact.active.last |
289 | 304 |
|
290 | 305 | expect(case_contact.want_driving_reimbursement).to be true |
|
310 | 325 |
|
311 | 326 | check reimbursement_checkbox |
312 | 327 |
|
313 | | - expect { click_on "Submit" }.not_to change(CaseContact.active, :count) |
314 | | - expect(page).to have_text("Must enter a valid mailing address for the reimbursement") |
| 328 | + expect { |
| 329 | + click_on "Submit" |
| 330 | + expect(page).to have_text("Must enter a valid mailing address for the reimbursement") |
| 331 | + }.not_to change(CaseContact.active, :count) |
315 | 332 | expect(page).to have_text("Must enter miles driven to receive driving reimbursement") |
316 | 333 | end |
317 | 334 |
|
|
391 | 408 | ) |
392 | 409 |
|
393 | 410 | check "Create Another" |
394 | | - expect { click_on "Submit" } |
| 411 | + expect { |
| 412 | + click_on "Submit" |
| 413 | + expect(page).to have_text "Case contact successfully created." |
| 414 | + } |
395 | 415 | .to change(CaseContact, :count).by(1) |
396 | 416 | # .to change(CaseContact.active, :count).by(1) |
397 | 417 | # .and change(CaseContact.started, :count).by(1) |
|
441 | 461 | it "redirects to the new CaseContact form with the same cases selected" do |
442 | 462 | expect { |
443 | 463 | visit new_case_contact_path(casa_case, {draft_case_ids:}) |
| 464 | + expect(page).to have_content("Record New Case Contact") |
444 | 465 | }.to change(CaseContact.started, :count).by(1) |
445 | 466 | this_case_contact = CaseContact.started.last |
446 | 467 |
|
|
452 | 473 |
|
453 | 474 | expect { |
454 | 475 | click_on "Submit" |
| 476 | + expect(page).to have_text "Case contacts successfully created." |
455 | 477 | }.to change(CaseContact.active, :count).by(2) |
456 | 478 |
|
457 | 479 | expect(page).to have_text "New Case Contact" |
|
516 | 538 |
|
517 | 539 | expect { |
518 | 540 | click_on "Submit" |
| 541 | + expect(page).to have_text "Case contact successfully created." |
519 | 542 | }.to change(CaseContact.active, :count).by(1) |
520 | 543 | contact = CaseContact.active.last |
521 | 544 | expect(contact.casa_case_id).to eq casa_case.id |
|
0 commit comments