mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-17 04:34:24 +00:00
Admin create order can set distributor and order cycle
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
/ insert_before "[data-hook='admin_order_form_buttons']"
|
||||
|
||||
%fieldset.no-border-bottom
|
||||
%legend{align => 'center'} Distribution
|
||||
|
||||
.alpha.six.columns
|
||||
.field
|
||||
= f.label :distributor_id
|
||||
= f.collection_select :distributor_id, Enterprise.is_distributor.managed_by(spree_current_user), :id, :name, include_blank: true
|
||||
|
||||
.omega.six.columns
|
||||
.field
|
||||
= f.label :order_cycle_id
|
||||
= f.collection_select :order_cycle_id, OrderCycle.managed_by(spree_current_user), :id, :name, include_blank: true
|
||||
@@ -17,26 +17,52 @@ feature %q{
|
||||
create :check_payment, order: @order, amount: @order.total
|
||||
end
|
||||
|
||||
context "managing orders" do
|
||||
scenario "capture multiple payments from the orders index page" do
|
||||
# d.cook: could also test for an order that has had payment voided, then a new check payment created but not yet captured. But it's not critical and I know it works anyway.
|
||||
scenario "creating an order with distributor and order cycle", js: true do
|
||||
order_cycle = create(:order_cycle)
|
||||
distributor = order_cycle.distributors.first
|
||||
product = order_cycle.products.first
|
||||
|
||||
login_to_admin_section
|
||||
login_to_admin_section
|
||||
|
||||
click_link 'Orders'
|
||||
current_path.should == spree.admin_orders_path
|
||||
click_link 'Orders'
|
||||
click_link 'New Order'
|
||||
|
||||
# click the 'capture' link for the order
|
||||
page.find("[data-action=capture][href*=#{@order.number}]").click
|
||||
page.should have_content 'ADD PRODUCT'
|
||||
targetted_select2_search product.name, from: '#add_variant_id', dropdown_css: '.select2-drop'
|
||||
click_link 'Add'
|
||||
page.has_selector? "table.index tbody[data-hook='admin_order_form_line_items'] tr" # Wait for JS
|
||||
page.should have_selector 'td', text: product.name
|
||||
|
||||
flash_message.should == "Payment Updated"
|
||||
select distributor.name, from: 'order_distributor_id'
|
||||
select order_cycle.name, from: 'order_order_cycle_id'
|
||||
click_button 'Update'
|
||||
|
||||
# check the order was captured
|
||||
@order.reload
|
||||
@order.payment_state.should == "paid"
|
||||
page.should have_selector 'h1', text: 'Customer Details'
|
||||
o = Spree::Order.last
|
||||
o.distributor.should == distributor
|
||||
o.order_cycle.should == order_cycle
|
||||
end
|
||||
|
||||
# we should still be on the same page
|
||||
current_path.should == spree.admin_orders_path
|
||||
end
|
||||
it "can't change distributor and order cycle once order is created (or similar restriction)"
|
||||
|
||||
scenario "capture multiple payments from the orders index page" do
|
||||
# d.cook: could also test for an order that has had payment voided, then a new check payment created but not yet captured. But it's not critical and I know it works anyway.
|
||||
|
||||
login_to_admin_section
|
||||
|
||||
click_link 'Orders'
|
||||
current_path.should == spree.admin_orders_path
|
||||
|
||||
# click the 'capture' link for the order
|
||||
page.find("[data-action=capture][href*=#{@order.number}]").click
|
||||
|
||||
flash_message.should == "Payment Updated"
|
||||
|
||||
# check the order was captured
|
||||
@order.reload
|
||||
@order.payment_state.should == "paid"
|
||||
|
||||
# we should still be on the same page
|
||||
current_path.should == spree.admin_orders_path
|
||||
end
|
||||
end
|
||||
|
||||
@@ -22,6 +22,7 @@ WebMock.disable_net_connect!(:allow_localhost => true)
|
||||
# in spec/support/ and its subdirectories.
|
||||
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
||||
require 'spree/core/testing_support/controller_requests'
|
||||
require 'spree/core/testing_support/capybara_ext'
|
||||
|
||||
require 'active_record/fixtures'
|
||||
fixtures_dir = File.expand_path('../../db/default', __FILE__)
|
||||
|
||||
Reference in New Issue
Block a user