From 67a5a1cdc2e809fce34ff097bbdc686f8606787d Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Thu, 31 Oct 2019 12:10:22 +0000 Subject: [PATCH] Fix incorrectly ordered entries with duplicate product names in OC and custom taxon ordering applied --- app/services/products_renderer.rb | 2 +- spec/controllers/api/order_cycles_controller_spec.rb | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/app/services/products_renderer.rb b/app/services/products_renderer.rb index 6e279a828a..ca9c728267 100644 --- a/app/services/products_renderer.rb +++ b/app/services/products_renderer.rb @@ -64,7 +64,7 @@ class ProductsRenderer distributor .preferred_shopfront_taxon_order .split(",").map { |id| "spree_products.primary_taxon_id=#{id} DESC" } - .join(", ") + ", spree_products.name ASC" + .join(", ") + ", spree_products.name ASC, spree_products.id ASC" else "spree_products.name ASC" end diff --git a/spec/controllers/api/order_cycles_controller_spec.rb b/spec/controllers/api/order_cycles_controller_spec.rb index f24e3936cb..595e734113 100644 --- a/spec/controllers/api/order_cycles_controller_spec.rb +++ b/spec/controllers/api/order_cycles_controller_spec.rb @@ -204,25 +204,17 @@ module Api it "displays products in new order" do api_get :products, id: order_cycle.id, distributor: distributor.id - - expect(product_ids.length).to eq 7 expect(product_ids).to eq [product7.id, product8.id, product2.id, product3.id, product5.id, product6.id, product1.id] end - xit "displays products in correct order across multiple pages" do + it "displays products in correct order across multiple pages" do api_get :products, id: order_cycle.id, distributor: distributor.id, per_page: 3 - - expect(product_ids.length).to eq 3 expect(product_ids).to eq [product7.id, product8.id, product2.id] api_get :products, id: order_cycle.id, distributor: distributor.id, per_page: 3, page: 2 - - expect(product_ids.length).to eq 3 expect(product_ids).to eq [product3.id, product5.id, product6.id] api_get :products, id: order_cycle.id, distributor: distributor.id, per_page: 3, page: 3 - - expect(product_ids.length).to eq 1 expect(product_ids).to eq [product1.id] end end