Skip to content

Commit 98ee0f2

Browse files
committed
created tests for unauthorized view attempts
1 parent 65758bb commit 98ee0f2

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

spec/system/court_dates/view_spec.rb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
RSpec.describe "court_dates/edit", type: :system do
44
let(:now) { Date.new(2021, 1, 1) }
55
let(:organization_containing_court_date) { create(:casa_org) }
6-
let(:organization_not_containing_court_date) { create(:casa_org) }
76
let(:admin) { create(:casa_admin, casa_org: organization_containing_court_date) }
87
let(:volunteer) { create(:volunteer, casa_org: organization_containing_court_date) }
98
let!(:casa_case) { create(:casa_case, casa_org: organization_containing_court_date) }
@@ -13,7 +12,7 @@
1312
travel_to now
1413
end
1514

16-
shared_examples "user can view court date" do |user_type, organization|
15+
shared_examples "user able to view court date" do |user_type, organization|
1716
let(:user) { create(user_type, casa_org: organization) }
1817

1918
before(:all) do
@@ -44,14 +43,29 @@
4443
end
4544
end
4645

47-
shared_examples "user cannot view court date" do |user_type, organization|
46+
shared_examples "user unable to view court date" do |user_type, organization|
4847
let(:user) { create(user_type, casa_org: organization) }
4948

5049
it "is not allowed to visit the court order page" do
50+
sign_in user
51+
visit casa_case_court_date_path(casa_case, court_date)
52+
5153
expect(page).to have_content "Sorry, you are not authorized to perform this action."
5254
end
5355
end
5456

57+
context "as a user from an organization not containing the court date" do
58+
let(:organization_not_containing_court_date) { create(:casa_org) }
59+
60+
it_should_behave_like "user unable to view court date", :admin, organization_not_containing_court_date
61+
end
62+
63+
context "as a volunteer not assigned to the case associated with the court case" do
64+
let(:other_volunteer) { create(:volunteer, casa_org: organization_containing_court_date) }
65+
66+
it_should_behave_like "user unable to view court date", :volunteer, organization_containing_court_date
67+
end
68+
5569
context "as a volunteer" do
5670
it "can download a report which focuses on the court date", :js do
5771
volunteer.casa_cases = [casa_case]

0 commit comments

Comments
 (0)