Refactoring checkout specs some more

This commit is contained in:
Will Marshall
2014-04-01 13:53:37 +11:00
parent a4fcabe11f
commit bf6eb4ace1
5 changed files with 27 additions and 21 deletions

1
.rspec
View File

@@ -1 +1,2 @@
--colour
--profile

View File

@@ -3,11 +3,13 @@ require 'spec_helper'
feature "As a consumer I want to check out my cart", js: true do
include AuthenticationWorkflow
include WebHelper
include ShopWorkflow
let(:distributor) { create(:distributor_enterprise) }
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

View File

@@ -3,12 +3,14 @@ require 'spec_helper'
feature "As a consumer I want to check out my cart", js: true do
include AuthenticationWorkflow
include ShopWorkflow
include WebHelper
let(:distributor) { create(:distributor_enterprise) }
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

View File

@@ -3,6 +3,7 @@ require 'spec_helper'
feature "As a consumer I want to check out my cart", js: true do
include AuthenticationWorkflow
include ShopWorkflow
include WebHelper
let(:distributor) { create(:distributor_enterprise) }
@@ -151,24 +152,3 @@ feature "As a consumer I want to check out my cart", js: true do
end
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"
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
create(:line_item, variant: product.master, order: order)
end

View File

@@ -0,0 +1,21 @@
module ShopWorkflow
def select_distributor
visit "/"
click_link distributor.name
end
# These methods are naughty and write 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"
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
create(:line_item, variant: product.master, order: order)
end
end