Sort shipping methods case insensitive

This commit is contained in:
Jean-Baptiste Bellet
2022-05-05 14:37:27 +02:00
parent fb834d3143
commit f2ac888f2c
2 changed files with 3 additions and 3 deletions

View File

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

View File

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