mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Move controller spec to serializer spec
This commit is contained in:
@@ -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
|
||||
|
||||
14
spec/serializers/product_serializer_spec.rb
Normal file
14
spec/serializers/product_serializer_spec.rb
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user