mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-11 03:40:20 +00:00
Convert to modern rspec and remove specs not applicable to ofn
This commit is contained in:
@@ -17,29 +17,31 @@ module Spree
|
||||
context 'packages' do
|
||||
it 'builds an array of packages' do
|
||||
packages = subject.packages
|
||||
packages.size.should eq 1
|
||||
packages.first.contents.size.should eq 5
|
||||
expect(packages.size).to eq 1
|
||||
expect(packages.first.contents.size).to eq 5
|
||||
end
|
||||
|
||||
it 'allows users to set splitters to an empty array' do
|
||||
packages = Packer.new(stock_location, order, []).packages
|
||||
packages.size.should eq 1
|
||||
expect(packages.size).to eq 1
|
||||
end
|
||||
end
|
||||
|
||||
context 'default_package' do
|
||||
before { order.line_items.first.variant.update(weight: 1) }
|
||||
|
||||
it 'contains all the items' do
|
||||
package = subject.default_package
|
||||
package.contents.size.should eq 5
|
||||
package.weight.should > 0
|
||||
expect(package.contents.size).to eq 5
|
||||
expect(package.weight).to be_positive
|
||||
end
|
||||
|
||||
it 'variants are added as backordered without enough on_hand' do
|
||||
stock_location.should_receive(:fill_status).exactly(5).times.and_return([2, 3])
|
||||
expect(stock_location).to receive(:fill_status).exactly(5).times.and_return([2, 3])
|
||||
|
||||
package = subject.default_package
|
||||
package.on_hand.size.should eq 5
|
||||
package.backordered.size.should eq 5
|
||||
expect(package.on_hand.size).to eq 5
|
||||
expect(package.backordered.size).to eq 5
|
||||
end
|
||||
|
||||
context 'when a packer factory is not specified' do
|
||||
@@ -73,31 +75,6 @@ module Spree
|
||||
subject.default_package
|
||||
end
|
||||
end
|
||||
|
||||
context "location doesn't have order items in stock" do
|
||||
let(:stock_location) { create(:stock_location, propagate_all_variants: false) }
|
||||
let(:packer) { Packer.new(stock_location, order) }
|
||||
|
||||
it "builds an empty package" do
|
||||
packer.default_package.contents.should be_empty
|
||||
end
|
||||
end
|
||||
|
||||
context "doesn't track inventory levels" do
|
||||
let(:order) { Order.create }
|
||||
let!(:line_item) { order.contents.add(create(:variant), 30) }
|
||||
|
||||
before { Config.track_inventory_levels = false }
|
||||
|
||||
it "doesn't bother stock items status in stock location" do
|
||||
expect(subject.stock_location).not_to receive(:fill_status)
|
||||
subject.default_package
|
||||
end
|
||||
|
||||
it "still creates package with proper quantity" do
|
||||
expect(subject.default_package.quantity).to eql 30
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user