Require a distributor when adding a product to the cart

This commit is contained in:
Rohan Mitchell
2012-06-24 12:13:33 +10:00
parent b5082009ce
commit 99d6f0baa9
2 changed files with 25 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
Spree::OrdersController.class_eval do
before_filter :populate_order_distributor, :only => :populate
def populate_order_distributor
@distributor = Spree::Distributor.find params[:distributor_id]
if @distributor.nil?
return false
end
end
end

View File

@@ -0,0 +1,14 @@
require 'spec_helper'
describe Spree::OrdersController do
context "adding the first product to the cart" do
it "does nothing if the user does not specify a distributor" do
create(:distributor)
p = create(:product)
expect do
spree_put :populate, :variants => {p.id => 1}
end.to change(Spree::LineItem, :count).by(0)
end
end
end