Skip to content

Commit e59b822

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

1 file changed

Lines changed: 23 additions & 29 deletions

File tree

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
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) }
5+
66
let(:admin) { create(:casa_admin, casa_org: organization) }
77
let(:supervisor) { create(:supervisor, casa_org: organization) }
88
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) }
9+
10+
let(:now) { Date.new(2021, 1, 1) }
11+
let(:displayed_date_format) { "%B %e, %Y" }
12+
let(:casa_case_number) { "CASA-CASE-NUMBER" }
13+
let!(:casa_case) { create(:casa_case, casa_org: organization, case_number: casa_case_number) }
14+
let(:court_date_as_date_object) { now + 1.week }
15+
let(:court_report_due_date_as_object) { now + 2.weeks }
16+
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) }
1117

1218
before do
1319
travel_to now
1420
end
1521

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

1925
before(:all) do
@@ -22,16 +28,19 @@
2228
end
2329

2430
it "can visit the court order page" do
25-
expect(page).not_to have_content "Sorry, you are not authorized to perform this action."
31+
expect(page).not_to have_text "Sorry, you are not authorized to perform this action."
2632
end
2733

2834
it "can see the court date" do
35+
expect(page).to have_text court_date_as_date_object.strftime(displayed_date_format)
2936
end
3037

3138
it "can see the associated case number" do
39+
expect(page).to have_text casa_case_number
3240
end
3341

3442
it "can see the associated court report due date" do
43+
expect(page).to have_text court_report_due_date.strftime(displayed_date_format)
3544
end
3645

3746
it "can see the associated judge" do
@@ -44,45 +53,30 @@
4453
end
4554
end
4655

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

5059
it "is not allowed to visit the court order page" do
5160
sign_in user
5261
visit casa_case_court_date_path(casa_case, court_date)
5362

54-
expect(page).to have_content "Sorry, you are not authorized to perform this action."
63+
expect(page).to have_text "Sorry, you are not authorized to perform this action."
5564
end
5665
end
5766

5867
context "as a user from an organization not containing the court date" do
5968
let(:organization) { create(:casa_org) }
6069

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
70+
it_should_behave_like "a user unable to view court date", :admin
6671
end
6772

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
73+
context "as a user under the same org as the court date" do
74+
context "as a volunteer not assigned to the case associated with the court date" do
75+
it_should_behave_like "a user unable to view court date", :volunteer
76+
end
8477

85-
expect(download_docx.paragraphs.map(&:to_s)).to include("Hearing Date: January 8, 2021")
78+
context "as a volunteer assigned to the case associated with the court date" do
79+
it_should_behave_like "a user able to view court date"
8680
end
8781
end
8882
end

0 commit comments

Comments
 (0)