Skip to content

Commit

Permalink
Adapt customer search override to spree v2 and fix customer details s…
Browse files Browse the repository at this point in the history
…pec in admin orders spec
  • Loading branch information
luisramos0 committed Feb 3, 2019
1 parent 7a29a72 commit e26801c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/ replace "code[erb-loud]:contains('hidden_field_tag :customer_search')"
/ replace "erb[loud]:contains('hidden_field_tag :customer_search')"
- content_for :app_wrapper_attrs do
= 'ng-app=admin.orders'
Expand Down
12 changes: 9 additions & 3 deletions spec/features/admin/orders_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,25 +147,31 @@ def new_order_with_distribution(distributor, order_cycle)

scenario "filling customer details" do
# Given a customer with an order, which includes their shipping and billing address

# We change the 1st order's address details
# This way we validate that the original details (stored in customer) are picked up in the 2nd order
@order.ship_address = create(:address, lastname: 'Ship')
@order.bill_address = create(:address, lastname: 'Bill')
shipping_method = create(:shipping_method_with, :delivery)
@order.shipments << create(:shipment_with, :shipping_method, shipping_method: shipping_method)
@order.save!

# We set the existing shipping method to delivery, this shipping method will be used in the 2nd order
# Otherwise order_updater.shipping_address_from_distributor will set the 2nd order address to the distributor address
@order.shipping_method.update_attribute :require_ship_address, true

# When I create a new order
quick_login_as @user
new_order_with_distribution(@distributor, @order_cycle)
targetted_select2_search @product.name, from: '#add_variant_id', dropdown_css: '.select2-drop'
find('button.add_variant').click
page.has_selector? "table.index tbody[data-hook='admin_order_form_line_items'] tr" # Wait for JS
click_button 'Update'

expect(page).to have_selector 'h1.page-title', text: "Customer Details"

# And I select that customer's email address and save the order
targetted_select2_search @customer.email, from: '#customer_search_override', dropdown_css: '.select2-drop'
click_button 'Update'
expect(page).to have_selector "h1.page-title", text: "Shipments"
expect(page).to have_selector "h1.page-title", text: "Customer Details"

# Then their addresses should be associated with the order
order = Spree::Order.last
Expand Down

0 comments on commit e26801c

Please sign in to comment.