Skip to content

Commit

Permalink
Draft Case Contact Filter Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Williams committed Jan 23, 2024
1 parent 54790c8 commit bb1e98e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
7 changes: 2 additions & 5 deletions app/controllers/case_contacts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def index
) || return

case_contacts = CaseContact.case_hash_from_cases(@filterrific.find)
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)
end
Expand Down Expand Up @@ -107,11 +108,7 @@ def current_organization_groups
end

def all_case_contacts
query = policy_scope(current_organization.case_contacts).includes(:creator, contact_types: :contact_type_group)
if params[:casa_case_id].present?
query = query.where(casa_case_id: params[:casa_case_id])
end
query
policy_scope(current_organization.case_contacts).includes(:creator, contact_types: :contact_type_group)
end

def additional_expense_params
Expand Down
2 changes: 1 addition & 1 deletion app/views/learning_hours/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</div>
<div class="field-card mt-4">
<h5 class="mb-3"><%= form.label :occurred_at, "Occurred On" %>:</h5>
<% occurred_at = learning_hour.occurred_at || Time.zone.now %>
<% occurred_at = learning_hour.occurred_at || Date.today %>
<div class="input-style-1">
<%= form.text_field :occurred_at,
value: occurred_at.to_date,
Expand Down
21 changes: 21 additions & 0 deletions spec/system/case_contacts/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@
end
end
end

describe "by casa_case_id" do
let!(:case_contact) { create(:case_contact, :details_status, creator: volunteer, draft_case_ids: [casa_case.id]) }
let!(:other_casa_case) { create(:casa_case, casa_org: organization, case_number: "CINA-2") }

it "displays the draft" do
sign_in volunteer
visit case_contacts_path(casa_case_id: casa_case.id)

expect(page).not_to have_content "You have no case contacts for this case."
expect(page).to have_content "Draft"
end

it "only displays the filtered case" do
sign_in volunteer
visit case_contacts_path(casa_case_id: casa_case.id)

expect(page).not_to have_content other_casa_case.case_number
expect(page).to have_content casa_case.case_number
end
end
end

describe "case contacts text color" do
Expand Down

0 comments on commit bb1e98e

Please sign in to comment.