Skip to content

Instantly share code, notes, and snippets.

@schof
Created October 12, 2010 18:28
Show Gist options
  • Select an option

  • Save schof/622651 to your computer and use it in GitHub Desktop.

Select an option

Save schof/622651 to your computer and use it in GitHub Desktop.
describe LineItem do
context "#save" do
context "when track inventory is true" do
it "should adjust inventory counts" do
# set preference here
InventoryUnit.should_receive(:adjust_inventory_counts).with(order)
order.save
end
end
context "when track inventory is false" do
it "should not adjust inventory counts"
end
context "when create inventory is true" do
it "should manage inventory units"
end
context "when create inventory is false" do
it "should not manage inventory units"
end
end
end
describe "InventoryUnits" do
let(:order) { mock_model Order }
let(:variant) { mock_model Variant }
let(:line_item) { mock_model(LineItem, :order => order, :variant => variant, :quantity => 2 }
context "#adjust_counts" do
end
context "#adjust_units" do
context "when new units are called for" do
berfore { order.stub_chain :inventory_units, :by_variant, :count => 1 }
it "should create the required units" do
InventoryUntis.should_receive(:create_units).with(variant, 1)
InventoryUnits.adjust_units(line_item)
end
it "should not destroy units"
end
context "when less units are called for" do
berfore { order.stub_chain :inventory_units, :by_variant, :count => 3 }
it "should not add units" do
InventoryUnits.should_not_receive :create_units
end
it "should remove the correct units" do
end
end
it "should add units when called for" do
end
it "should remove units when called for"
end
context "#create_units" do
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment