Skip to content
Open
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
2 changes: 1 addition & 1 deletion app/controllers/casa_cases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class CasaCasesController < ApplicationController

def index
authorize CasaCase
org_cases = current_user.casa_org.casa_cases.includes(:assigned_volunteers)
org_cases = current_user.casa_org.casa_cases.includes(:assigned_volunteers, :casa_case_emancipation_categories)
@casa_cases = policy_scope(org_cases).includes([:hearing_type, :judge])
@casa_cases_filter_id = policy(CasaCase).can_see_filters? ? "casa-cases" : ""
@duties = OtherDuty.where(creator_id: current_user.id)
Expand Down
2 changes: 1 addition & 1 deletion app/decorators/casa_case_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def unsuccessful_contacts_this_week_before(date)
end

def emancipation_checklist_count
"#{object.casa_case_emancipation_categories.count} / #{EmancipationCategory.count}"
"#{object.casa_case_emancipation_categories.size} / #{h.emancipation_category_total_count}"
end

def show_contact_type?(contact_type_id)
Expand Down
6 changes: 6 additions & 0 deletions app/helpers/emancipations_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
module EmancipationsHelper
# Memoized per request so the casa_cases index doesn't re-issue COUNT(*)
# for every casa_case row when rendering the emancipation badge.
def emancipation_category_total_count
@emancipation_category_total_count ||= EmancipationCategory.count
end

def emancipation_category_checkbox_checked(casa_case, emancipation_category)
case_contains_category?(casa_case, emancipation_category) ? "checked" : nil
end
Expand Down
2 changes: 1 addition & 1 deletion spec/decorators/casa_case_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@

expect(casa_case).to(
receive(:casa_case_emancipation_categories).and_return(
double(:categories, count: 2)
double(:categories, size: 2)
)
)
expect(EmancipationCategory).to receive(:count).and_return(5)
Expand Down
Loading