Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .standard_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1161,7 +1163,6 @@ ignore:
- RSpec/MultipleExpectations
- RSpec/PredicateMatcher
- RSpec/ContextWording
- RSpec/PendingWithoutReason
- spec/system/case_contacts/index_spec.rb:
- RSpec/LetSetup
- RSpec/MultipleMemoizedHelpers
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions app/controllers/case_contacts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this type of logic would be in a pundit policy file but we are very spotty with that in general, so dont worry about it in this pr

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)
Expand Down
16 changes: 16 additions & 0 deletions spec/requests/case_contacts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down