Reworking the checkout spec slightly

This commit is contained in:
Will Marshall
2014-04-01 13:44:36 +11:00
parent f3f676ce26
commit a4fcabe11f

View File

@@ -9,6 +9,7 @@ feature "As a consumer I want to check out my cart", js: true do
let(:supplier) { create(:supplier_enterprise) }
let(:order_cycle) { create(:order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise)) }
let(:product) { create(:simple_product, supplier: supplier) }
let(:order) { Spree::Order.last }
before do
create_enterprise_group_for distributor
@@ -16,6 +17,7 @@ feature "As a consumer I want to check out my cart", js: true do
exchange.variants << product.master
end
# Disabled :in for performance reasons
[:out].each do |auth_state|
describe "logged #{auth_state.to_s}, distributor selected, order cycle selected, product in cart" do
let(:user) { create_enterprise_user }
@@ -153,15 +155,20 @@ end
def select_distributor
visit "/"
click_link distributor.name
#@order = Spree::Order.last
end
# This method is naughty and writes to the DB directly
# Because loading the whole Angular app is slow
def select_order_cycle
exchange = Exchange.find(order_cycle.exchanges.to_enterprises(distributor).outgoing.first.id)
visit "/shop"
select exchange.pickup_time, from: "order_cycle_id"
#exchange = Exchange.find(order_cycle.exchanges.to_enterprises(distributor).outgoing.first.id)
#visit "/shop"
#select exchange.pickup_time, from: "order_cycle_id"
order.update_attribute :order_cycle, order_cycle
end
def add_product_to_cart
fill_in "variants[#{product.master.id}]", with: product.master.on_hand - 1
first("form.custom > input.button.right").click
#fill_in "variants[#{product.master.id}]", with: product.master.on_hand - 1
#first("form.custom > input.button.right").click
create(:line_item, variant: product.master, order: order)
end