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