diff --git a/app/views/shop/_products.html.haml b/app/views/shop/_products.html.haml
index 494a03412e..200a7cf93a 100644
--- a/app/views/shop/_products.html.haml
+++ b/app/views/shop/_products.html.haml
@@ -24,7 +24,7 @@
%td {{ product.master.options_text }}
%td
%span{"ng-show" => "(product.variants.length == 0)"}
- %input{type: :number, value: 0, min: 0, name: "variants[{{product.master.id}}]"}
+ %input{type: :number, value: 0, min: 0, name: "variants[{{product.master.id}}]", id: "variants_{{product.master.id}}"}
%td.group_buy
%span{"ng-show" => "product.group_buy"}
Available
@@ -37,7 +37,7 @@
%td{colspan: 3}
%td {{variant.options_text}}
%td
- %input{type: :number, value: 0, min: 0, name: "variants[{{variant.id}}]"}
+ %input{type: :number, value: 0, min: 0, name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}"}
%td.group_buy
%span{"ng-show" => "product.group_buy"}
Available
diff --git a/spec/features/consumer/shopping_spec.rb b/spec/features/consumer/shopping_spec.rb
index bbf127f1cb..e976320381 100644
--- a/spec/features/consumer/shopping_spec.rb
+++ b/spec/features/consumer/shopping_spec.rb
@@ -95,17 +95,26 @@ feature "As a consumer I want to shop with a distributor", js: true do
end
end
+ describe "with products with variants" do
+ let(:oc) { create(:simple_order_cycle, distributors: [distributor]) }
+ let(:product) { create(:simple_product) }
+ let(:variant) { create(:variant, product: product) }
+
+ before do
+ build_and_select_order_cycle
+ end
+
+ it "should not show quantity field for product with variants" do
+ page.should_not have_selector("#variants_#{product.master.id}", visible: true)
+ end
+ end
+
describe "adding products to cart" do
let(:oc) { create(:simple_order_cycle, distributors: [distributor]) }
let(:product) { create(:simple_product) }
let(:variant) { create(:variant, product: product) }
before do
- exchange = Exchange.find(oc.exchanges.to_enterprises(distributor).outgoing.first.id)
- exchange.update_attribute :pickup_time, "frogs"
- exchange.variants << product.master
- exchange.variants << variant
- visit shop_path
- select "frogs", :from => "order_cycle_id"
+ build_and_select_order_cycle
end
it "should let us add products to our cart" do
fill_in "variants[#{variant.id}]", with: "1"
@@ -134,3 +143,12 @@ feature "As a consumer I want to shop with a distributor", js: true do
end
end
end
+
+def build_and_select_order_cycle
+ exchange = Exchange.find(oc.exchanges.to_enterprises(distributor).outgoing.first.id)
+ exchange.update_attribute :pickup_time, "frogs"
+ exchange.variants << product.master
+ exchange.variants << variant
+ visit shop_path
+ select "frogs", :from => "order_cycle_id"
+end