|
3 | 3 | RSpec.describe "court_dates/edit", type: :system do |
4 | 4 | let(:now) { Date.new(2021, 1, 1) } |
5 | 5 | let(:organization_containing_court_date) { create(:casa_org) } |
6 | | - let(:organization_not_containing_court_date) { create(:casa_org) } |
7 | 6 | let(:admin) { create(:casa_admin, casa_org: organization_containing_court_date) } |
8 | 7 | let(:volunteer) { create(:volunteer, casa_org: organization_containing_court_date) } |
9 | 8 | let!(:casa_case) { create(:casa_case, casa_org: organization_containing_court_date) } |
|
13 | 12 | travel_to now |
14 | 13 | end |
15 | 14 |
|
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| |
17 | 16 | let(:user) { create(user_type, casa_org: organization) } |
18 | 17 |
|
19 | 18 | before(:all) do |
|
44 | 43 | end |
45 | 44 | end |
46 | 45 |
|
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| |
48 | 47 | let(:user) { create(user_type, casa_org: organization) } |
49 | 48 |
|
50 | 49 | 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 | + |
51 | 53 | expect(page).to have_content "Sorry, you are not authorized to perform this action." |
52 | 54 | end |
53 | 55 | end |
54 | 56 |
|
| 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 | + |
55 | 69 | context "as a volunteer" do |
56 | 70 | it "can download a report which focuses on the court date", :js do |
57 | 71 | volunteer.casa_cases = [casa_case] |
|
0 commit comments