diff --git a/.standard_todo.yml b/.standard_todo.yml index 5b7b610db8..6349c349ba 100644 --- a/.standard_todo.yml +++ b/.standard_todo.yml @@ -10,6 +10,7 @@ ignore: - Rails/TimeZone - app/controllers/case_contacts_controller.rb: - Rails/LexicallyScopedActionFilter + - Style/HashSlice - app/controllers/checklist_items_controller.rb: - Rails/TimeZone - app/controllers/court_dates_controller.rb: @@ -806,6 +807,7 @@ ignore: - spec/requests/case_contacts_spec.rb: - RSpec/MultipleMemoizedHelpers - RSpec/MultipleExpectations + - RSpec/LetSetup - RSpec/PendingWithoutReason - spec/requests/case_court_reports_spec.rb: - RSpec/ContextWording @@ -1161,7 +1163,6 @@ ignore: - RSpec/MultipleExpectations - RSpec/PredicateMatcher - RSpec/ContextWording - - RSpec/PendingWithoutReason - spec/system/case_contacts/index_spec.rb: - RSpec/LetSetup - RSpec/MultipleMemoizedHelpers @@ -1174,7 +1175,6 @@ ignore: - RSpec/MultipleExpectations - RSpec/NamedSubject - RSpec/ExampleLength - - RSpec/PendingWithoutReason - RSpec/NestedGroups - Rails/Date - spec/system/case_court_reports/index_spec.rb: diff --git a/app/controllers/case_contacts_controller.rb b/app/controllers/case_contacts_controller.rb index 6b4cb91d64..cb350158eb 100644 --- a/app/controllers/case_contacts_controller.rb +++ b/app/controllers/case_contacts_controller.rb @@ -21,6 +21,7 @@ def index @pagy, @filtered_case_contacts = pagy(@filterrific.find) case_contacts = CaseContact.case_hash_from_cases(@filtered_case_contacts) + case_contacts = case_contacts.select { |k, _v| current_user.casa_cases.pluck(:id).include?(k) } if current_user.volunteer? case_contacts = case_contacts.select { |k, _v| k == params[:casa_case_id].to_i } if params[:casa_case_id].present? @presenter = CaseContactPresenter.new(case_contacts) diff --git a/spec/requests/case_contacts_spec.rb b/spec/requests/case_contacts_spec.rb index 6c033cd379..217040a4a0 100644 --- a/spec/requests/case_contacts_spec.rb +++ b/spec/requests/case_contacts_spec.rb @@ -35,6 +35,22 @@ expect(page).not_to include(past_contact.creator.display_name) end end + + context "when logged in as a volunteer" do + let(:assigned_case) { create(:casa_case, :with_one_case_assignment, casa_org: organization) } + let(:unassigned_case) { casa_case } + let(:volunteer) { assigned_case.assigned_volunteers.first } + let!(:assigned_case_contact) { create(:case_contact, casa_case: assigned_case, creator: volunteer) } + let!(:unassigned_case_contact) { create(:case_contact, casa_case: unassigned_case, creator: volunteer, duration_minutes: 180) } + + before { sign_in volunteer } + + it "returns only currently assigned cases" do + page = request.parsed_body.to_html + expect(page).to include("60 minutes") + expect(page).not_to include("3 hours") + end + end end describe "GET /new" do