Display ship address options checkboxes

+ Create the associated test: the trick is is that the selected delivery method is the one that required address **and** is before others that do not required ship address
This commit is contained in:
Jean-Baptiste Bellet
2022-03-07 16:39:56 +01:00
parent 20d5c45b7a
commit 60ad92c4ff
2 changed files with 21 additions and 3 deletions

View File

@@ -89,7 +89,7 @@
= shipping_method_form.label shipping_method.id, shipping_method.name, {for: "shipping_method_" + shipping_method.id.to_s }
%em.light
= payment_or_shipping_price(shipping_method, @order)
- display_ship_address = (shipping_method.id == selected_shipping_method.to_i && shipping_method.require_ship_address)
- display_ship_address = display_ship_address || (shipping_method.id == selected_shipping_method.to_i && shipping_method.require_ship_address)
- if shipping_method.id == selected_shipping_method.to_i
- ship_method_description = shipping_method.description

View File

@@ -32,6 +32,9 @@ describe "As a consumer, I want to checkout my order", js: true do
let(:fee_tax_category) { create(:tax_category, tax_rates: [fee_tax_rate]) }
let(:enterprise_fee) { create(:enterprise_fee, amount: 1.23, tax_category: fee_tax_category) }
let(:free_shipping_with_required_address) {
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",
calculator: Calculator::FlatRate.new(preferred_amount: 0.00))
@@ -43,6 +46,9 @@ describe "As a consumer, I want to checkout my order", js: true do
name: "Shipping with Fee", description: "blue",
calculator: Calculator::FlatRate.new(preferred_amount: 4.56))
}
let(:free_shipping_without_required_address) {
create(:shipping_method, require_ship_address: false, name: "Z Free Shipping without required address")
}
let!(:payment_with_fee) {
create(:payment_method, distributors: [distributor],
name: "Payment with Fee", description: "Payment with fee",
@@ -56,8 +62,7 @@ describe "As a consumer, I want to checkout my order", js: true do
add_enterprise_fee enterprise_fee
set_order order
distributor.shipping_methods << free_shipping
distributor.shipping_methods << shipping_with_fee
distributor.shipping_methods = [free_shipping_with_required_address, free_shipping, shipping_with_fee, free_shipping_without_required_address]
end
context "guest checkout when distributor doesn't allow guest orders" do
@@ -186,6 +191,19 @@ describe "As a consumer, I want to checkout my order", js: true do
end
context "details step" do
context "when form is submitted but invalid" do
it "display the checkbox about shipping address same as billing address when selecting a shipping method that requires ship address" do
choose free_shipping_with_required_address.name
check "Shipping address same as billing address?"
click_button "Next - Payment method"
expect(page).to have_content "Saving failed, please update the highlighted fields."
expect(page).to have_content "Shipping address same as billing address?"
expect(page).to have_checked_field "Shipping address same as billing address?"
end
end
describe "filling out delivery details" do
before do
fill_out_details