Skip to content

Commit ae77992

Browse files
committed
Working tests
1 parent 4001b62 commit ae77992

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

app/services/exports/export_distributions_csv_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def generate_csv_data
4242
def generate_csv_stream
4343
yield CSV.generate_line(base_headers + item_headers)
4444

45-
distributions.find_each(batch_size: 500) do |distribution|
45+
distributions.each do |distribution|
4646
yield CSV.generate_line(build_row_data(distribution))
4747
end
4848
end

spec/services/exports/export_distributions_csv_service_spec.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@
55
let(:include_in_kind_values) { false }
66
let(:include_packages) { false }
77

8-
describe '#generate_csv' do
9-
subject { described_class.new(distributions: distributions, organization: organization, filters: filters).generate_csv }
8+
describe '#generate_csv_stream' do
9+
subject do
10+
rows = ""
11+
described_class.new(distributions: distributions, organization: organization, filters: filters).generate_csv_stream do |row|
12+
rows << row
13+
end
14+
rows
15+
end
1016

1117
let(:duplicate_item) { create(:item, name: "Dupe Item", value_in_cents: 300, organization: organization, package_size: 2) }
1218

@@ -174,7 +180,7 @@
174180
end
175181

176182
context 'when there are no distributions but the report is requested' do
177-
subject { described_class.new(distributions: [], organization: organization, filters: filters).generate_csv }
183+
let(:distributions) { [] }
178184
it 'returns a csv with only headers and no rows' do
179185
csv = <<~CSV
180186
Partner,Initial Allocation,Scheduled for,Source Inventory,Total Number of #{item_name},Total Value of #{item_name},Delivery Method,Shipping Cost,Status,Agency Representative,Comments,Reporting Category,Dupe Item

0 commit comments

Comments
 (0)