mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Refactoring checkout specs some more
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
21
spec/support/request/shop_workflow.rb
Normal file
21
spec/support/request/shop_workflow.rb
Normal 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
|
||||
Reference in New Issue
Block a user