mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Merge pull request #8692 from jibees/8691-make-first-name-and-last-name-fields-mandatory
Validate the presence of first/last name if there is no company
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user