Skip to content

Commit

Permalink
Fix Ship Order Button: modal should close itself
Browse files Browse the repository at this point in the history
 - returns to the same processing for customer, invoices etc.
   that edit
 - need a bit of sleep in spec bc 2 tasks are asynchroneous
  • Loading branch information
cyrillefr committed Apr 24, 2024
1 parent 320b551 commit 37616c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion app/reflexes/admin/orders_reflex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def capture
def ship
@order.send_shipment_email = false unless params[:send_shipment_email]
if @order.ship
return set_param_for_controller if request.url.match?('edit')
return set_param_for_controller if Regexp.union(Constants::PATHS).match? request.url

morph dom_id(@order), render(partial: "spree/admin/orders/table_row",
locals: { order: @order.reload, success: true })
Expand Down Expand Up @@ -134,4 +134,8 @@ def render_business_number_required_error(distributors)
morph_admin_flashes
end
end

module Constants
PATHS = %w[edit customer payments adjustments invoices return_authorizations].freeze
end
end
5 changes: 3 additions & 2 deletions spec/system/admin/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -971,10 +971,10 @@ def new_order_with_distribution(distributor, order_cycle)
find_button("Confirm").click
end

find_button("Cancel").click # closes modal as it is not automatic
expect(page).to have_selector('.reveal-modal', visible: false)
click_link('Order Details') unless subpage == 'Order Details'

sleep(0.5) # avoid flakyness
expect(order.reload.shipped?).to be true
expect(page).to have_text 'SHIPPED'
expect(ActionMailer::MailDeliveryJob).to have_been_enqueued
Expand All @@ -995,9 +995,10 @@ def new_order_with_distribution(distributor, order_cycle)
find_button("Confirm").click
end

find_button("Cancel").click # closes modal as it is not automatic
expect(page).to have_selector('.reveal-modal', visible: false)
click_link('Order Details') unless subpage == 'Order Details'

sleep(0.5) # avoir flakyness
expect(order.reload.shipped?).to be true
expect(page).to have_text 'SHIPPED'
expect(ActionMailer::MailDeliveryJob).not_to have_been_enqueued
Expand Down

0 comments on commit 37616c6

Please sign in to comment.