diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb index bfa68da912..8794b17932 100644 --- a/spec/controllers/shop_controller_spec.rb +++ b/spec/controllers/shop_controller_spec.rb @@ -111,14 +111,6 @@ describe ShopController do response.body.should be_empty end - it "scopes variants for a product to the order cycle and distributor" do - controller.stub(:current_order_cycle).and_return order_cycle - controller.stub(:current_distributor).and_return d - Spree::Product.any_instance.should_receive(:variants_for).with(order_cycle, d).and_return(m = double()) - m.stub(:in_stock).and_return [] - xhr :get, :products - end - context "RABL tests" do render_views before do diff --git a/spec/serializers/product_serializer_spec.rb b/spec/serializers/product_serializer_spec.rb new file mode 100644 index 0000000000..0091668dbb --- /dev/null +++ b/spec/serializers/product_serializer_spec.rb @@ -0,0 +1,14 @@ +describe Api::ProductSerializer do + let(:hub) { create(:distributor_enterprise) } + let(:oc) { create(:simple_order_cycle, distributors: [hub], variants: [v1]) } + let(:p) { create(:simple_product) } + let!(:v1) { create(:variant, product: p, unit_value: 3) } + let!(:v2) { create(:variant, product: p, unit_value: 5) } + + it "scopes variants to distribution" do + s = Api::ProductSerializer.new p, current_distributor: hub, current_order_cycle: oc + json = s.to_json + json.should include v1.options_text + json.should_not include v2.options_text + end +end