Remove controller specs that are now covered by OrderPopulator

This commit is contained in:
Rohan Mitchell
2013-06-14 14:57:31 +10:00
parent 4e5f0b9963
commit 065ea6a1a1

View File

@@ -31,106 +31,6 @@ describe Spree::OrdersController do
order.distributor.should be_nil
end
context "adding the first product to the cart" do
it "does not add the product if the user does not specify a distributor" do
create(:distributor_enterprise)
p = create(:product)
expect do
spree_post :populate, :variants => {p.master.id => 1}
end.to change(Spree::LineItem, :count).by(0)
end
it "does not add the product if the user specifies a distributor that the product is not available at" do
distributor_product = create(:distributor_enterprise)
distributor_no_product = create(:distributor_enterprise)
p = create(:product, :distributors => [distributor_product])
expect do
spree_post :populate, :variants => {p.master.id => 1}, :distributor_id => distributor_no_product.id
end.to change(Spree::LineItem, :count).by(0)
end
it "adds the product and sets the distributor even if the order has a different distributor set" do
distributor_product = create(:distributor_enterprise)
distributor_no_product = create(:distributor_enterprise)
p = create(:product, :distributors => [distributor_product])
order = subject.current_order(true)
order.distributor = distributor_no_product
order.save!
expect do
spree_post :populate, :variants => {p.master.id => 1}, :distributor_id => distributor_product.id
end.to change(Spree::LineItem, :count).by(1)
order.reload.distributor.should == distributor_product
end
it "sets the order's distributor" do
# Given a product in a distributor
d = create(:distributor_enterprise)
p = create(:product, :distributors => [d])
# When we add the product to our cart
spree_post :populate, :variants => {p.master.id => 1}, :distributor_id => d.id
# Then our order should have its distributor set to the chosen distributor
subject.current_order(false).distributor.should == d
end
end
context "adding a subsequent product to the cart" do
before(:each) do
# Given a product and a distributor
@distributor = create(:distributor_enterprise)
@product = create(:product, :distributors => [@distributor])
# And the product is in the cart
spree_post :populate, :variants => {@product.master.id => 1}, :distributor_id => @distributor.id
subject.current_order(false).line_items.reload.map { |li| li.product }.should == [@product]
subject.current_order(false).distributor.reload.should == @distributor
end
it "does not add the product if the product is not available at the order's distributor" do
# Given a product at another distributor
d2 = create(:distributor_enterprise)
p2 = create(:product, :distributors => [d2])
# When I attempt to add the product to the cart
spree_post :populate, :variants => {p2.master.id => 1}, :distributor_id => d2.id
# Then the product should not be added to the cart
subject.current_order(false).line_items.reload.map { |li| li.product }.should == [@product]
subject.current_order(false).distributor.reload.should == @distributor
end
it "does not add the product if the product is not available at the given distributor" do
# Given a product at another distributor
d2 = create(:distributor_enterprise)
p2 = create(:product, :distributors => [d2])
# When I attempt to add the product to the cart with a fake distributor_id
spree_post :populate, :variants => {p2.master.id => 1}, :distributor_id => @distributor.id
# Then the product should not be added to the cart
subject.current_order(false).line_items.reload.map { |li| li.product }.should == [@product]
subject.current_order(false).distributor.reload.should == @distributor
end
it "does not add the product if the chosen distributor is different from the order's distributor" do
# Given a product that's available at the chosen distributor and another distributor
d2 = create(:distributor_enterprise)
p2 = create(:product, :distributors => [@distributor, d2])
# When I attempt to add the product to the cart with the alternate distributor
spree_post :populate, :variants => {p2.master.id => 1}, :distributor_id => d2
# Then the product should not be added to the cart
subject.current_order(false).line_items.reload.map { |li| li.product }.should == [@product]
subject.current_order(false).distributor.reload.should == @distributor
end
end
context "adding a group buy product to the cart" do
it "sets a variant attribute for the max quantity" do