Skip to content

Commit

Permalink
Merge pull request #4530 from rubyforgood/feat/improve-children-expor…
Browse files Browse the repository at this point in the history
…t-fields

Feat/improve children export fields
  • Loading branch information
awwaiid authored Aug 4, 2024
2 parents c5fb10e + 6dff365 commit d303832
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/controllers/partners/children_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions app/models/partners/child.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
]
Expand Down
12 changes: 6 additions & 6 deletions spec/requests/partners/children_requests_spec.rb
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d303832

Please sign in to comment.