diff --git a/spec/models/storage_location_spec.rb b/spec/models/storage_location_spec.rb index 5ebdb20ba2..ad7a92eb40 100644 --- a/spec/models/storage_location_spec.rb +++ b/spec/models/storage_location_spec.rb @@ -84,15 +84,6 @@ let(:item) { create(:item) } subject { create(:storage_location, :with_items, item_quantity: 10, item: item, organization: organization) } - describe "StorageLocation.items_inventoried" do - it "returns a collection of items that are stored within inventories" do - items = create_list(:item, 3, organization: organization) - create(:storage_location, :with_items, item: items[0], item_quantity: 5, organization: organization) - create(:storage_location, :with_items, item: items[2], item_quantity: 5, organization: organization) - expect(StorageLocation.items_inventoried(organization).length).to eq(2) - end - end - describe "item_total" do it "retrieves the total for a single item" do item = create(:item) diff --git a/spec/models/view/inventory_spec.rb b/spec/models/view/inventory_spec.rb index 4987e32c74..907f6db23f 100644 --- a/spec/models/view/inventory_spec.rb +++ b/spec/models/view/inventory_spec.rb @@ -143,4 +143,19 @@ expect(results.count { |i| i.item_id == item3.id }).to eq(1) end end + + describe "#items_for_select" do + it "returns an array with length equal to number of unique inventory items" do + results = subject.items_for_select + expect(results.size).to eq(3) + end + + it "returns an array of item ids and names sorted by item name" do + results = subject.items_for_select + ids = results.map(&:id) + names = results.map(&:name) + expect(ids).to eq([item3.id, item2.id, item1.id]) + expect(names).to eq([item3.name, item2.name, item1.name]) + end + end end