mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-01 21:47:16 +00:00
Merge pull request #7450 from jibees/6205-remove-line-items-empty-error-on-order-creation-in-backoffice
Suppress "Line items can't be blank" message on order creation process
This commit is contained in:
@@ -38,11 +38,12 @@ module Spree
|
||||
@order.recreate_all_fees!
|
||||
|
||||
unless order_params.present? && @order.update(order_params) && @order.line_items.present?
|
||||
if @order.line_items.empty?
|
||||
if @order.line_items.empty? && !params[:suppress_error_msg]
|
||||
@order.errors.add(:line_items, Spree.t('errors.messages.blank'))
|
||||
end
|
||||
return redirect_to(spree.edit_admin_order_path(@order),
|
||||
flash: { error: @order.errors.full_messages.join(', ') })
|
||||
|
||||
flash[:error] = @order.errors.full_messages.join(', ') if @order.errors.present?
|
||||
return redirect_to spree.edit_admin_order_path(@order)
|
||||
end
|
||||
|
||||
if @order.complete?
|
||||
|
||||
@@ -61,6 +61,13 @@ feature '
|
||||
select2_select order_cycle.name, from: 'order_order_cycle_id'
|
||||
click_button 'Next'
|
||||
|
||||
expect(page).not_to have_selector '.flash.error'
|
||||
expect(page).not_to have_content "Line items can't be blank"
|
||||
|
||||
click_button "Update And Recalculate Fees"
|
||||
expect(page).to have_selector '.flash.error'
|
||||
expect(page).to have_content "Line items can't be blank"
|
||||
|
||||
# it suppresses validation errors when setting distribution
|
||||
expect(page).not_to have_selector '#errorExplanation'
|
||||
expect(page).to have_content 'ADD PRODUCT'
|
||||
|
||||
Reference in New Issue
Block a user