Order shipping methods by name

+ create spec
This commit is contained in:
Jean-Baptiste Bellet
2022-04-27 16:37:37 +02:00
parent 6262dc3a2e
commit 34fcb4a1f7
2 changed files with 6 additions and 1 deletions

View File

@@ -47,7 +47,7 @@ module CheckoutCallbacks
end
def load_shipping_methods
@shipping_methods = available_shipping_methods
@shipping_methods = available_shipping_methods.sort_by(&:name)
end
def redirect_to_shop?

View File

@@ -182,6 +182,11 @@ describe "As a consumer, I want to checkout my order", js: true do
expect(page).not_to have_content "Save as default shipping address"
end
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"]
end
it_behaves_like "when I have an out of stock product in my cart"
end