From 61bb1bdcdcb5ad5ed9dd3253db0df005894ce717 Mon Sep 17 00:00:00 2001 From: ricchen Date: Thu, 8 Apr 2021 20:53:20 -0400 Subject: [PATCH 1/2] fix incorrect last name sorting for packing report --- lib/open_food_network/packing_report.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/open_food_network/packing_report.rb b/lib/open_food_network/packing_report.rb index 34c1e0e730..8fcc1eb904 100644 --- a/lib/open_food_network/packing_report.rb +++ b/lib/open_food_network/packing_report.rb @@ -53,7 +53,7 @@ module OpenFoodNetwork { group_by: proc { |line_item| line_item.order.distributor }, sort_by: proc { |distributor| distributor.name } }, { group_by: proc { |line_item| line_item.order }, - sort_by: proc { |order| order.bill_address.lastname }, + sort_by: proc { |order| order.bill_address.lastname.downcase }, summary_columns: [proc { |_line_items| "" }, proc { |_line_items| "" }, proc { |_line_items| "" }, @@ -89,7 +89,7 @@ module OpenFoodNetwork { group_by: proc { |line_item| line_item.full_name }, sort_by: proc { |full_name| full_name } }, { group_by: proc { |line_item| line_item.order }, - sort_by: proc { |order| order.bill_address.lastname } }] + sort_by: proc { |order| order.bill_address.lastname.downcase } }] end end From 8c391251b329ffd2e3c4427fb3c2799632cfb7ba Mon Sep 17 00:00:00 2001 From: ricchen Date: Thu, 8 Apr 2021 23:57:33 -0400 Subject: [PATCH 2/2] added test case for alphabetically sorting --- spec/features/admin/reports_spec.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/spec/features/admin/reports_spec.rb b/spec/features/admin/reports_spec.rb index 2f0dde6e40..ff049e3368 100644 --- a/spec/features/admin/reports_spec.rb +++ b/spec/features/admin/reports_spec.rb @@ -93,8 +93,8 @@ feature ' login_as_admin_and_visit spree.admin_reports_path end - let(:bill_address1) { create(:address, lastname: "Aman") } - let(:bill_address2) { create(:address, lastname: "Bman") } + let(:bill_address1) { create(:address, lastname: "MULLER") } + let(:bill_address2) { create(:address, lastname: "Mistery") } let(:distributor_address) { create(:address, address1: "distributor address", city: 'The Shire', zipcode: "1234") } let(:distributor) { create(:distributor_enterprise, address: distributor_address) } let(:order1) { create(:order, distributor: distributor, bill_address: bill_address1) } @@ -129,6 +129,22 @@ feature ' expect(page).to have_selector 'table#listing_orders tbody tr', count: 5 # Totals row per order end + scenario "Alphabetically Sorted Pack by Customer" do + click_link "Pack By Customer" + click_button 'Search' + + rows = find("table#listing_orders").all("tr") + table = rows.map { |r| r.all("th,td").map { |c| c.text.strip }[3] } + expect(table).to eq([ + "Last Name", + order2.bill_address.lastname, + "", + order1.bill_address.lastname, + order1.bill_address.lastname, + "" + ]) + end + scenario "Pack By Supplier" do click_link "Pack By Supplier" fill_in 'q_completed_at_gt', with: '2013-04-25 13:00:00'