Skip to content

Commit 75ba45e

Browse files
authored
Merge pull request #6278 from rubyforgood/6199-bug-case-contacts-showing-for-unassigned-volunteers
[6199] BUG: case contacts showing for unassigned volunteers
2 parents 78c8a83 + 4b8ccb1 commit 75ba45e

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

.standard_todo.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ignore:
1010
- Rails/TimeZone
1111
- app/controllers/case_contacts_controller.rb:
1212
- Rails/LexicallyScopedActionFilter
13+
- Style/HashSlice
1314
- app/controllers/checklist_items_controller.rb:
1415
- Rails/TimeZone
1516
- app/controllers/court_dates_controller.rb:
@@ -806,6 +807,7 @@ ignore:
806807
- spec/requests/case_contacts_spec.rb:
807808
- RSpec/MultipleMemoizedHelpers
808809
- RSpec/MultipleExpectations
810+
- RSpec/LetSetup
809811
- RSpec/PendingWithoutReason
810812
- spec/requests/case_court_reports_spec.rb:
811813
- RSpec/ContextWording
@@ -1161,7 +1163,6 @@ ignore:
11611163
- RSpec/MultipleExpectations
11621164
- RSpec/PredicateMatcher
11631165
- RSpec/ContextWording
1164-
- RSpec/PendingWithoutReason
11651166
- spec/system/case_contacts/index_spec.rb:
11661167
- RSpec/LetSetup
11671168
- RSpec/MultipleMemoizedHelpers
@@ -1174,7 +1175,6 @@ ignore:
11741175
- RSpec/MultipleExpectations
11751176
- RSpec/NamedSubject
11761177
- RSpec/ExampleLength
1177-
- RSpec/PendingWithoutReason
11781178
- RSpec/NestedGroups
11791179
- Rails/Date
11801180
- spec/system/case_court_reports/index_spec.rb:

app/controllers/case_contacts_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def index
2121

2222
@pagy, @filtered_case_contacts = pagy(@filterrific.find)
2323
case_contacts = CaseContact.case_hash_from_cases(@filtered_case_contacts)
24+
case_contacts = case_contacts.select { |k, _v| current_user.casa_cases.pluck(:id).include?(k) } if current_user.volunteer?
2425
case_contacts = case_contacts.select { |k, _v| k == params[:casa_case_id].to_i } if params[:casa_case_id].present?
2526

2627
@presenter = CaseContactPresenter.new(case_contacts)

spec/requests/case_contacts_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@
3535
expect(page).not_to include(past_contact.creator.display_name)
3636
end
3737
end
38+
39+
context "when logged in as a volunteer" do
40+
let(:assigned_case) { create(:casa_case, :with_one_case_assignment, casa_org: organization) }
41+
let(:unassigned_case) { casa_case }
42+
let(:volunteer) { assigned_case.assigned_volunteers.first }
43+
let!(:assigned_case_contact) { create(:case_contact, casa_case: assigned_case, creator: volunteer) }
44+
let!(:unassigned_case_contact) { create(:case_contact, casa_case: unassigned_case, creator: volunteer, duration_minutes: 180) }
45+
46+
before { sign_in volunteer }
47+
48+
it "returns only currently assigned cases" do
49+
page = request.parsed_body.to_html
50+
expect(page).to include("60 minutes")
51+
expect(page).not_to include("3 hours")
52+
end
53+
end
3854
end
3955

4056
describe "GET /new" do

0 commit comments

Comments
 (0)