mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-11 18:26:50 +00:00
Finally presence of distributor and order_cycle in set_distribution step
This commit is contained in:
@@ -30,6 +30,8 @@ module Spree
|
||||
on_update
|
||||
|
||||
@order.update(order_params)
|
||||
return unless @order.valid?(:set_distribution_step)
|
||||
|
||||
@order.save
|
||||
redirect_to spree.admin_order_customer_path(@order)
|
||||
end
|
||||
|
||||
@@ -97,6 +97,8 @@ module Spree
|
||||
validates :email, presence: true,
|
||||
format: /\A([\w.%+\-']+)@([\w\-]+\.)+(\w{2,})\z/i,
|
||||
if: :require_email
|
||||
validates :order_cycle, presence: true, on: :set_distribution_step
|
||||
validates :distributor, presence: true, on: :set_distribution_step
|
||||
|
||||
make_permalink field: :number
|
||||
|
||||
|
||||
@@ -89,6 +89,28 @@ describe '
|
||||
click_button 'Update'
|
||||
end
|
||||
|
||||
context "can't create an order without selecting a distributor nor an order cycle" do
|
||||
before do
|
||||
login_as_admin
|
||||
visit spree.admin_orders_path
|
||||
click_link 'New Order'
|
||||
end
|
||||
|
||||
it 'shows error when distributor is not selected' do
|
||||
click_button 'Next'
|
||||
|
||||
expect(page).to have_content "Order cycle can't be blank"
|
||||
expect(page).to have_content "Distributor can't be blank"
|
||||
end
|
||||
|
||||
it 'shows error when order cycle is not selected' do
|
||||
select2_select distributor.name, from: 'order_distributor_id'
|
||||
click_button 'Next'
|
||||
|
||||
expect(page).to have_content "Order cycle can't be blank"
|
||||
end
|
||||
end
|
||||
|
||||
it "can add a product to an existing order" do
|
||||
login_as_admin
|
||||
visit spree.edit_admin_order_path(order)
|
||||
|
||||
Reference in New Issue
Block a user