Skip to content

Commit

Permalink
Add specs for SimpleCoordinator with 3 locations
Browse files Browse the repository at this point in the history
These specs failed with the old Stock::Coordinator
  • Loading branch information
jhawthorn committed Sep 12, 2017
1 parent a40cb18 commit 332e216
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions core/spec/models/spree/stock/simple_coordinator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,55 @@ module Stock
end
end
end

context 'with three stock locations' do
let!(:stock_location_2) { create(:stock_location, propagate_all_variants: false, active: true) }
let!(:stock_location_3) { create(:stock_location, propagate_all_variants: false, active: true) }
before do
stock_item2 = variant.stock_items.create!(stock_location: stock_location_2, backorderable: false)
stock_item2.set_count_on_hand(location_2_inventory)

stock_item3 = variant.stock_items.create!(stock_location: stock_location_3, backorderable: false)
stock_item3.set_count_on_hand(location_3_inventory)
end

# Regression test for https://github.com/solidusio/solidus/issues/2122
context "with sufficient inventory in first two locations" do
let(:location_1_inventory) { 3 }
let(:location_2_inventory) { 3 }
let(:location_3_inventory) { 3 }

it_behaves_like "a fulfillable package"

it "creates only two packages" do
expect(shipments.count).to eq(2)
end
end

context "with sufficient inventory only across all three locations" do
let(:location_1_inventory) { 2 }
let(:location_2_inventory) { 2 }
let(:location_3_inventory) { 2 }

it_behaves_like "a fulfillable package"

it "creates three packages" do
expect(shipments.count).to eq(3)
end
end

context "with sufficient inventory only across all three locations" do
let(:location_1_inventory) { 2 }
let(:location_2_inventory) { 2 }
let(:location_3_inventory) { 2 }

it_behaves_like "a fulfillable package"

it "creates three packages" do
expect(shipments.count).to eq(3)
end
end
end
end
end
end
Expand Down

0 comments on commit 332e216

Please sign in to comment.