Skip to content

Commit

Permalink
Merge pull request #7886 from apricot12/invalid_customer_email_subscr…
Browse files Browse the repository at this point in the history
…iption_fail

Add valid_email2 gem for email validation to fix subscription failures with invalid emails.
  • Loading branch information
mkllnk authored Jul 16, 2021
2 parents ac0c1f3 + db88121 commit f448c95
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -792,6 +795,7 @@ DEPENDENCIES
uglifier (>= 1.0.3)
unicorn-rails
unicorn-worker-killer
valid_email2
view_component
view_component_storybook
web!
Expand Down
2 changes: 1 addition & 1 deletion app/models/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f448c95

Please sign in to comment.