From 1a270af82b5bb9dc507c1a038a728ed22f40b714 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Mon, 10 Jan 2022 14:57:01 +0100 Subject: [PATCH 1/2] Test the presence of the firstname and the lastname if company is not present Co-Authored-By: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> --- app/models/spree/address.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/spree/address.rb b/app/models/spree/address.rb index 9bd500a41d..3538336d7d 100644 --- a/app/models/spree/address.rb +++ b/app/models/spree/address.rb @@ -15,7 +15,9 @@ module Spree validates :address1, :city, :country, :phone, presence: true validates :company, presence: true, unless: -> { first_name.blank? || last_name.blank? } - validates :firstname, :lastname, presence: true, unless: -> { company.present? } + validates :firstname, :lastname, presence: true, if: -> do + company.blank? || company == 'unused' + end validates :zipcode, presence: true, if: :require_zipcode? validate :state_validate From 6e62985e195b9ff85030497d0b257c9f90562906 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Mon, 10 Jan 2022 15:17:40 +0100 Subject: [PATCH 2/2] update tests as there are now 2 more mandatory fields First name and last name --- spec/system/consumer/split_checkout_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/system/consumer/split_checkout_spec.rb b/spec/system/consumer/split_checkout_spec.rb index 37c0bb1c81..b911197b4f 100644 --- a/spec/system/consumer/split_checkout_spec.rb +++ b/spec/system/consumer/split_checkout_spec.rb @@ -68,9 +68,9 @@ describe "As a consumer, I want to checkout my order", js: true do it "should display error when fields are empty" do click_button "Next - Payment method" expect(page).to have_content("Saving failed, please update the highlighted fields") - expect(page).to have_css 'span.field_with_errors label', count: 4 - expect(page).to have_css 'span.field_with_errors input', count: 4 - expect(page).to have_css 'span.formError', count: 5 + expect(page).to have_css 'span.field_with_errors label', count: 6 + expect(page).to have_css 'span.field_with_errors input', count: 6 + expect(page).to have_css 'span.formError', count: 7 end it "should validate once each needed field is filled" do