Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft Case Contact Filter Fix #5496

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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 %>
Copy link
Collaborator Author

@schoork schoork Jan 23, 2024

Choose a reason for hiding this comment

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

Unrelated, but fixes some flakiness if the test is run late enough in the date that Time.zone.now ends up being tomorrow.

<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
Loading