From f2ac888f2c5efbe662602f9015ffb48bab299643 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Thu, 5 May 2022 14:37:27 +0200 Subject: [PATCH] Sort shipping methods case insensitive --- app/controllers/concerns/checkout_callbacks.rb | 2 +- spec/system/consumer/split_checkout_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/concerns/checkout_callbacks.rb b/app/controllers/concerns/checkout_callbacks.rb index 1458a20050..4b6608b947 100644 --- a/app/controllers/concerns/checkout_callbacks.rb +++ b/app/controllers/concerns/checkout_callbacks.rb @@ -47,7 +47,7 @@ module CheckoutCallbacks end def load_shipping_methods - @shipping_methods = available_shipping_methods.sort_by(&:name) + @shipping_methods = available_shipping_methods.sort { |a, b| a.name.casecmp(b.name) } end def redirect_to_shop? diff --git a/spec/system/consumer/split_checkout_spec.rb b/spec/system/consumer/split_checkout_spec.rb index 43252cefb7..cbc5284519 100644 --- a/spec/system/consumer/split_checkout_spec.rb +++ b/spec/system/consumer/split_checkout_spec.rb @@ -36,7 +36,7 @@ describe "As a consumer, I want to checkout my order", js: true do create(:shipping_method, require_ship_address: true, name: "A Free Shipping with required address") } let(:free_shipping) { - create(:shipping_method, require_ship_address: false, name: "Free Shipping", description: "yellow", + create(:shipping_method, require_ship_address: false, name: "free Shipping", description: "yellow", calculator: Calculator::FlatRate.new(preferred_amount: 0.00)) } let(:shipping_tax_rate) { create(:tax_rate, amount: 0.25, zone: zone, included_in_price: true) } @@ -184,7 +184,7 @@ describe "As a consumer, I want to checkout my order", js: true do it 'display shipping methods alphabetically' do shipping_methods = page.all(:field, "shipping_method_id").map { |field| field.sibling("label") }.map(&:text) - expect(shipping_methods).to eq ["A Free Shipping with required address", "Free Shipping", "Local", "Shipping with Fee", "Z Free Shipping without required address"] + expect(shipping_methods).to eq ["A Free Shipping with required address", "free Shipping", "Local", "Shipping with Fee", "Z Free Shipping without required address"] end it_behaves_like "when I have an out of stock product in my cart"