From 037c524df28f19127ccb2a0e8ad2fd856aeec5c5 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 7 Jan 2016 16:35:54 +1100 Subject: [PATCH] Preserve max quantity when reloading shopfront --- app/serializers/api/line_item_serializer.rb | 2 +- spec/features/consumer/shopping/shopping_spec.rb | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/serializers/api/line_item_serializer.rb b/app/serializers/api/line_item_serializer.rb index d791febdfc..35d3f9c540 100644 --- a/app/serializers/api/line_item_serializer.rb +++ b/app/serializers/api/line_item_serializer.rb @@ -1,5 +1,5 @@ class Api::LineItemSerializer < ActiveModel::Serializer - attributes :id, :quantity, :price + attributes :id, :quantity, :max_quantity, :price has_one :variant, serializer: Api::VariantSerializer end diff --git a/spec/features/consumer/shopping/shopping_spec.rb b/spec/features/consumer/shopping/shopping_spec.rb index 12e9d8323b..e81a792881 100644 --- a/spec/features/consumer/shopping/shopping_spec.rb +++ b/spec/features/consumer/shopping/shopping_spec.rb @@ -187,7 +187,7 @@ feature "As a consumer I want to shop with a distributor", js: true do visit shop_path end - it "should save group buy data to the cart" do + it "should save group buy data to the cart and display it on shopfront reload" do # -- Quantity fill_in "variants[#{variant.id}]", with: 6 page.should have_in_cart product.name @@ -202,6 +202,11 @@ feature "As a consumer I want to shop with a distributor", js: true do li = Spree::Order.order(:created_at).last.line_items.order(:created_at).last li.max_quantity.should == 7 + + # -- Reload + visit shop_path + page.should have_field "variants[#{variant.id}]", with: 6 + page.should have_field "variant_attributes[#{variant.id}][max_quantity]", with: 7 end end end