Skip to content

Commit 275e3d1

Browse files
Added tests to verify the export service works when there are no partners
1 parent 7d69c9b commit 275e3d1

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

spec/services/exports/export_partners_csv_service_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,24 @@
398398
end
399399
end
400400

401+
context "when there are no partners" do
402+
let(:partners) { Partner.none }
403+
it "should have the correct headers and no other rows" do
404+
expect(subject[0]).to eq(headers_base + partial_to_headers.values.flatten)
405+
expect(subject[1]).to eq(nil)
406+
end
407+
408+
it "should only export columns in profile sections the org has enabled" do
409+
partial_to_headers.keys.each do |partial|
410+
organization.update(partner_form_fields: [partial])
411+
partners.reload
412+
limited_export = CSV.parse(described_class.new(partners, organization).generate_csv)
413+
expect(limited_export[0]).to eq(headers_base + partial_to_headers[partial])
414+
expect(limited_export[1]).to eq(nil)
415+
end
416+
end
417+
end
418+
401419
context "when partner has a distribution in the last 12 months" do
402420
let(:distribution) { create(:distribution, partner: partner) }
403421

0 commit comments

Comments
 (0)