Skip to content

Commit

Permalink
Move storage location spec to inventory view spec
Browse files Browse the repository at this point in the history
  • Loading branch information
coalest committed Dec 7, 2024
1 parent cfe3b86 commit d9935cb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
9 changes: 0 additions & 9 deletions spec/models/storage_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions spec/models/view/inventory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d9935cb

Please sign in to comment.