Skip to content

Commit af74324

Browse files
update csv specs to be more hardcoded
1 parent 3ffa075 commit af74324

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

spec/models/audit_spec.rb

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,29 @@
129129
end
130130

131131
describe ".generate_csv" do
132-
let!(:audit) { create(:audit, :with_items, organization: organization) }
133-
let!(:audit_2) { create(:audit, :with_items, organization: organization) }
134-
let(:sl) { audit.storage_location }
135-
let(:sl2) { audit_2.storage_location }
132+
let!(:item_1) { create(:item, name: "Baby Diapers") }
133+
let!(:item_2) { create(:item, name: "Adult Diapers") }
134+
let!(:sl_1) { create(:storage_location, organization: organization, name: "Diaperhaus") }
135+
let!(:sl_2) { create(:storage_location, organization: organization, name: "Pawnee Diaper Bank") }
136+
let!(:time_1) { Time.zone.parse("2025-10-02 01:00:00") }
137+
let!(:time_2) { Time.zone.parse("2025-10-03 01:00:00") }
138+
let!(:audit) { create(:audit, organization: organization, storage_location: sl_1, status: 1, updated_at: time_1) }
139+
let!(:audit_2) { create(:audit, organization: organization, storage_location: sl_2, status: 2, updated_at: time_2) }
140+
141+
before do
142+
audit.line_items.create!(item: item_1, quantity: 150)
143+
audit_2.line_items.create!(item: item_2, quantity: 250)
144+
end
136145

137146
it "generates a CSV" do
138147
csv_data = described_class.generate_csv([audit, audit_2])
139148

140149
expect(csv_data).to be_a(String)
141150
expect(csv_data).to eq(
142151
<<~CSV
143-
Audit Date,Audit Status,Storage Location Name,#{audit.line_items.first.name},#{audit_2.line_items.first.name}
144-
#{audit.updated_at.strftime("%B %d %Y")},#{audit.status},#{sl.name},#{audit.line_items.first.quantity},0
145-
#{audit_2.updated_at.strftime("%B %d %Y")},#{audit_2.status},#{sl2.name},0,#{audit_2.line_items.first.quantity}
152+
Audit Date,Audit Status,Storage Location Name,Baby Diapers,Adult Diapers
153+
October 02 2025,confirmed,Diaperhaus,150,0
154+
October 03 2025,finalized,Pawnee Diaper Bank,0,250
146155
CSV
147156
)
148157
end

0 commit comments

Comments
 (0)