diff --git a/app/controllers/partners/children_controller.rb b/app/controllers/partners/children_controller.rb index 74b842f7bd..378f6abf2a 100644 --- a/app/controllers/partners/children_controller.rb +++ b/app/controllers/partners/children_controller.rb @@ -6,7 +6,7 @@ class ChildrenController < BaseController def index @filterrific = initialize_filterrific( current_partner.children - .includes(:family) + .includes(:family, :requested_items) .order(sort_order), params[:filterrific] ) || return diff --git a/app/models/partners/child.rb b/app/models/partners/child.rb index 9f1fa2dea9..3cc260ebdd 100644 --- a/app/models/partners/child.rb +++ b/app/models/partners/child.rb @@ -89,7 +89,7 @@ def display_name def self.csv_export_headers %w[ id first_name last_name date_of_birth gender child_lives_with race agency_child_id - health_insurance comments created_at updated_at family_id requested_item_ids active archived + health_insurance comments created_at updated_at guardian_last_name guardian_first_name requested_items active archived ].freeze end @@ -107,8 +107,9 @@ def csv_export_attributes comments, created_at, updated_at, - family_id, - requested_item_ids, + family.guardian_last_name, + family.guardian_first_name, + requested_items.map(&:name).join(", "), active, archived ] diff --git a/spec/requests/partners/children_requests_spec.rb b/spec/requests/partners/children_requests_spec.rb index 82fc7d52e9..8547c91a30 100644 --- a/spec/requests/partners/children_requests_spec.rb +++ b/spec/requests/partners/children_requests_spec.rb @@ -1,9 +1,9 @@ RSpec.describe "/partners/children", type: :request do let(:partner_user) { partner.primary_user } let(:partner) { create(:partner) } - let(:family) { create(:partners_family, partner: partner) } - let(:item1) { create(:item, organization: partner.organization) } - let(:item2) { create(:item, organization: partner.organization) } + let(:family) { create(:partners_family, partner: partner, guardian_first_name: "First Name", guardian_last_name: "Last Name") } + let(:item1) { create(:item, organization: partner.organization, name: "Item A") } + let(:item2) { create(:item, organization: partner.organization, name: "Item B") } let!(:child1) do create(:partners_child, first_name: "John", @@ -51,9 +51,9 @@ headers = {"Accept" => "text/csv", "Content-Type" => "text/csv"} get partners_children_path, headers: headers csv = <<~CSV - id,first_name,last_name,date_of_birth,gender,child_lives_with,race,agency_child_id,health_insurance,comments,created_at,updated_at,family_id,requested_item_ids,active,archived - #{child1.id},John,Smith,2019-01-01,Male,"mother,grandfather",Other,Agency McAgence,Private insurance,Some comment,#{child1.created_at},#{child1.updated_at},#{family.id},"",true,false - #{child2.id},Jane,Smith,2018-01-01,Female,father,Hispanic,Agency McAgence,Private insurance,Some comment,#{child2.created_at},#{child2.updated_at},#{family.id},"#{item1.id},#{item2.id}",true,false + id,first_name,last_name,date_of_birth,gender,child_lives_with,race,agency_child_id,health_insurance,comments,created_at,updated_at,guardian_last_name,guardian_first_name,requested_items,active,archived + #{child1.id},John,Smith,2019-01-01,Male,"mother,grandfather",Other,Agency McAgence,Private insurance,Some comment,#{child1.created_at},#{child1.updated_at},Last Name,First Name,"",true,false + #{child2.id},Jane,Smith,2018-01-01,Female,father,Hispanic,Agency McAgence,Private insurance,Some comment,#{child2.created_at},#{child2.updated_at},Last Name,First Name,"Item A, Item B",true,false CSV expect(response.body).to eq(csv) end