Merge pull request #7886 from apricot12/invalid_customer_email_subscription_fail

Add valid_email2 gem for email validation to fix subscription failures with invalid emails.
This commit is contained in:
Maikel
2021-07-16 10:20:37 +10:00
committed by GitHub
3 changed files with 7 additions and 1 deletions

View File

@@ -25,6 +25,8 @@ gem "activerecord-import"
gem "db2fog", github: "openfoodfoundation/db2fog", branch: "rails-6"
gem "fog-aws", "~> 2.0" # db2fog does not support v3
gem "valid_email2"
gem "catalog", path: "./engines/catalog"
gem 'dfc_provider', path: './engines/dfc_provider'
gem "order_management", path: "./engines/order_management"

View File

@@ -633,6 +633,9 @@ GEM
get_process_mem (~> 0)
unicorn (>= 4, < 7)
uniform_notifier (1.14.2)
valid_email2 (4.0.0)
activemodel (>= 3.2)
mail (~> 2.5)
view_component (2.35.0)
activesupport (>= 5.0.0, < 8.0)
method_source (~> 1.0)
@@ -792,6 +795,7 @@ DEPENDENCIES
uglifier (>= 1.0.3)
unicorn-rails
unicorn-worker-killer
valid_email2
view_component
view_component_storybook
web!

View File

@@ -20,7 +20,7 @@ class Customer < ApplicationRecord
before_validation :empty_code
validates :code, uniqueness: { scope: :enterprise_id, allow_nil: true }
validates :email, presence: true,
validates :email, presence: true, 'valid_email_2/email': true,
uniqueness: { scope: :enterprise_id, message: I18n.t('validation_msg_is_associated_with_an_exising_customer') }
validates :enterprise, presence: true