Getting in ze test for previous commit

This commit is contained in:
Will Marshall
2014-01-16 16:25:41 +11:00
parent d68551c6eb
commit b6d796e3bc
2 changed files with 26 additions and 8 deletions

View File

@@ -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

View File

@@ -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