Skip to content

Commit 87b581f

Browse files
seabeeberryseabeeberry
authored andcommitted
Implemented tests using TestInventory.create_item
1 parent 0a3cd08 commit 87b581f

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

spec/services/request_itemized_breakdown_service_spec.rb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,15 @@
1010
let(:storage_location) { create(:storage_location, organization: organization) }
1111

1212
before do
13-
create(:inventory_item, storage_location: storage_location, item: item_a, quantity: 3)
14-
create(:inventory_item, storage_location: storage_location, item: item_b, quantity: 20)
13+
TestInventory.create_inventory(organization, {
14+
storage_location.id => {
15+
item_a.id => 3,
16+
item_b.id => 20
17+
}
18+
})
1519

1620
create(:item_request, request: request_1, partner_request_id: request_1.id, item: item_a, quantity: 5, request_unit: nil)
1721
create(:item_request, request: request_2, partner_request_id: request_2.id, item: item_b, quantity: 10, request_unit: nil)
18-
19-
allow_any_instance_of(RequestItemizedBreakdownService)
20-
.to receive(:current_onhand_quantities)
21-
.and_return({item_a.name => 3, item_b.name => 20, item_a.id => 3, item_b.id => 20})
22-
allow_any_instance_of(RequestItemizedBreakdownService)
23-
.to receive(:current_onhand_minimums)
24-
.and_return({item_a.name => 4, item_b.name => 8, item_a.id => 4, item_b.id => 8})
2522
end
2623

2724
describe "#fetch" do
@@ -38,7 +35,7 @@
3835
end
3936

4037
describe "#fetch_csv" do
41-
subject { service.fetch_csv }
38+
subject(:subject) { service.fetch_csv }
4239
let(:service) { described_class.new(organization: organization, request_ids: [request_1.id, request_2.id]) }
4340

4441
it "should output the expected output but in CSV format" do

0 commit comments

Comments
 (0)