Merge pull request #7362 from richardc2117/master

Fixes Alphabetical Sorting In Packing Reports
This commit is contained in:
Andy Brett
2021-04-15 09:50:02 -07:00
committed by GitHub
2 changed files with 20 additions and 4 deletions

View File

@@ -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

View File

@@ -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'