Skip to content

Commit 220b025

Browse files
committed
fill in simple information verification tests
1 parent f248ba3 commit 220b025

1 file changed

Lines changed: 22 additions & 32 deletions

File tree

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
require "rails_helper"
22

33
RSpec.describe "court_dates/edit", type: :system do
4-
let(:now) { Date.new(2021, 1, 1) }
54
let(:organization) { create(:casa_org) }
6-
let(:admin) { create(:casa_admin, casa_org: organization) }
7-
let(:supervisor) { create(:supervisor, casa_org: organization) }
8-
let(:volunteer) { create(:volunteer, casa_org: organization) }
9-
let!(:casa_case) { create(:casa_case, casa_org: organization) }
10-
let!(:court_date) { create(:court_date, :with_court_details, casa_case: casa_case, date: now + 1.week) }
5+
6+
let(:now) { Date.new(2021, 1, 1) }
7+
let(:displayed_date_format) { "%B %e, %Y" }
8+
let(:casa_case_number) { "CASA-CASE-NUMBER" }
9+
let!(:casa_case) { create(:casa_case, casa_org: organization, case_number: casa_case_number) }
10+
let(:court_date_as_date_object) { now + 1.week }
11+
let(:court_report_due_date_as_object) { now + 2.weeks }
12+
let!(:court_date) { create(:court_date, :with_court_details, casa_case: casa_case, court_report_due_date: court_report_due_date_as_object, date: court_date_as_date_object) }
1113

1214
before do
1315
travel_to now
1416
end
1517

16-
shared_examples "user able to view court date" do |user_type|
18+
shared_examples "a user able to view court date" do |user_type|
1719
let(:user) { create(user_type, casa_org: organization) }
1820

1921
before(:all) do
@@ -22,16 +24,19 @@
2224
end
2325

2426
it "can visit the court order page" do
25-
expect(page).not_to have_content "Sorry, you are not authorized to perform this action."
27+
expect(page).not_to have_text "Sorry, you are not authorized to perform this action."
2628
end
2729

2830
it "can see the court date" do
31+
expect(page).to have_text court_date_as_date_object.strftime(displayed_date_format)
2932
end
3033

3134
it "can see the associated case number" do
35+
expect(page).to have_text casa_case_number
3236
end
3337

3438
it "can see the associated court report due date" do
39+
expect(page).to have_text court_report_due_date.strftime(displayed_date_format)
3540
end
3641

3742
it "can see the associated judge" do
@@ -44,45 +49,30 @@
4449
end
4550
end
4651

47-
shared_examples "user unable to view court date" do |user_type|
52+
shared_examples "a user unable to view court date" do |user_type|
4853
let(:user) { create(user_type, casa_org: organization) }
4954

5055
it "is not allowed to visit the court order page" do
5156
sign_in user
5257
visit casa_case_court_date_path(casa_case, court_date)
5358

54-
expect(page).to have_content "Sorry, you are not authorized to perform this action."
59+
expect(page).to have_text "Sorry, you are not authorized to perform this action."
5560
end
5661
end
5762

5863
context "as a user from an organization not containing the court date" do
5964
let(:organization) { create(:casa_org) }
6065

61-
it_should_behave_like "user unable to view court date", :admin
62-
end
63-
64-
context "as a volunteer not assigned to the case associated with the court case" do
65-
it_should_behave_like "user unable to view court date", :volunteer
66+
it_should_behave_like "a user unable to view court date", :casa_admin
6667
end
6768

68-
context "as a volunteer" do
69-
it "can download a report which focuses on the court date", :js do
70-
volunteer.casa_cases = [casa_case]
71-
sign_in volunteer
72-
73-
visit root_path
74-
click_on "Cases"
75-
click_on casa_case.case_number
76-
77-
expect(CourtDate.count).to eq 2
78-
click_on "January 8, 2021"
79-
expect(page).to have_content "Court Date"
80-
81-
click_on "Download Report"
82-
83-
wait_for_download
69+
context "as a user under the same org as the court date" do
70+
context "as a volunteer not assigned to the case associated with the court date" do
71+
it_should_behave_like "a user unable to view court date", :volunteer
72+
end
8473

85-
expect(download_docx.paragraphs.map(&:to_s)).to include("Hearing Date: January 8, 2021")
74+
context "as a volunteer assigned to the case associated with the court date" do
75+
it_should_behave_like "a user able to view court date"
8676
end
8777
end
8878
end

0 commit comments

Comments
 (0)