File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 11class LowInventoryQuery
22 def self . call ( organization )
33 inventory = View ::Inventory . new ( organization . id )
4- items = inventory . all_items
4+ items = inventory . all_items . uniq ( & :item_id )
55
66 low_inventory_items = [ ]
77 items . each do |item |
Original file line number Diff line number Diff line change 8484 } )
8585 }
8686 end
87+
88+ context "when items are in multiple storage locations" do
89+ let ( :recommended_quantity ) { 300 }
90+ let ( :secondary_storage_location ) { create :storage_location , organization : organization }
91+ let! ( :secondary_purchase ) {
92+ create :purchase ,
93+ :with_items ,
94+ organization : organization ,
95+ storage_location : secondary_storage_location ,
96+ item : item ,
97+ item_quantity : inventory_item_quantity ,
98+ issued_at : Time . current
99+ }
100+
101+ it {
102+ expect ( subject . count ) . to eq 1
103+ }
104+
105+ it {
106+ is_expected . to include ( {
107+ id : item . id ,
108+ name : item . name ,
109+ on_hand_minimum_quantity : 0 ,
110+ on_hand_recommended_quantity : 300 ,
111+ total_quantity : 200
112+ } )
113+ }
114+ end
87115end
You can’t perform that action at this time.
0 commit comments