Skip to content

Commit a45baa4

Browse files
Added test to specify how a partner with an empty profile should be exported
1 parent 8e8fc2e commit a45baa4

1 file changed

Lines changed: 39 additions & 4 deletions

File tree

spec/services/exports/export_partners_csv_service_spec.rb

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,48 @@
344344
}
345345

346346
it "should have the correct headers" do
347-
expected_headers = headers_base + partial_to_headers.values.flatten
348-
expect(subject[0]).to eq(expected_headers)
347+
expect(subject[0]).to eq(headers_base + partial_to_headers.values.flatten)
349348
end
350349

351350
it "should have the expected info in the columns order" do
352-
expected_values = values_base + partial_to_values.values.flatten
353-
expect(subject[1]).to eq(expected_values)
351+
expect(subject[1]).to eq(values_base + partial_to_values.values.flatten)
352+
end
353+
354+
it "should handle a partner with missing profile info" do
355+
# The partner_profile factory defaults to populating the website, primary_contact_name, and primary_contact_email fields
356+
partners.first.update(profile: create(
357+
:partner_profile,
358+
website: nil,
359+
primary_contact_name: nil,
360+
primary_contact_email: nil
361+
))
362+
expected_value_base = [
363+
partner.name,
364+
partner.email,
365+
", ",
366+
"",
367+
"",
368+
"",
369+
"",
370+
"",
371+
"",
372+
"",
373+
"",
374+
"",
375+
"",
376+
enable_child_based_requests.to_s,
377+
enable_individual_requests.to_s,
378+
enable_quantity_based_requests.to_s,
379+
", ",
380+
"",
381+
"",
382+
"",
383+
notes,
384+
"",
385+
providing_diapers[:value],
386+
providing_period_supplies[:value]
387+
]
388+
expect(subject[1]).to eq(expected_value_base + Array.new(partial_to_values.values.flatten.count) { "" })
354389
end
355390

356391
it "should only export columns in profile sections the org has enabled" do

0 commit comments

Comments
 (0)