From 801ebe5819f27d0a86131b303996bbdddc0b31b0 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Mon, 30 Jan 2023 19:50:35 +0000 Subject: [PATCH] Adds ordering by billing address name --- spec/system/admin/orders_spec.rb | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/spec/system/admin/orders_spec.rb b/spec/system/admin/orders_spec.rb index a01652f3f9..93d9aa9246 100644 --- a/spec/system/admin/orders_spec.rb +++ b/spec/system/admin/orders_spec.rb @@ -73,7 +73,8 @@ describe ' } let!(:order5) { create(:order_ready_to_ship, user: customer5, distributor: distributor5, - order_cycle: order_cycle5,) + order_cycle: order_cycle5, + bill_address_id: billing_address5.id) } context "logging as superadmin and visiting the orders page" do @@ -315,6 +316,23 @@ describe ' expect(page).to have_content(/#{order2.number}.*#{order3.number}.*#{order4.number}.*#{order5.number}/m) end end + + context "orders with different billing addresses" do + before do + billing_address2.update(lastname: "Mad Hatter") + billing_address3.update(lastname: "Duchess") + billing_address4.update(lastname: "Cheshire Cat") + billing_address5.update(lastname: "Alice") + login_as_admin_and_visit spree.admin_orders_path + end + + it "orders by last name" do + find("a", text: 'NAME').click # sets ascending ordering + expect(page).to have_content(/#{order5.number}.*#{order4.number}.*#{order3.number}.*#{order2.number}/m) + find("a", text: 'NAME').click # sets descending ordering + expect(page).to have_content(/#{order2.number}.*#{order3.number}.*#{order4.number}.*#{order5.number}/m) + end + end end end