-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1412: Email validation fixes. Accepting a more sensible email address…
… format (#291) * Ensuring that email addresses contain TLDs in order to be considered valid. * added more conditional for the email validation. Email addresses containing spaces are not valid * Comma delimited emails are still considered valid. We should investigate this * Applying PR feedback * removing test in place of comment * Update app/app/models/cbv_flow_invitation.rb Co-authored-by: Tom Dooner <[email protected]> * fixed rubocop linting errors --------- Co-authored-by: Tom Dooner <[email protected]>
- Loading branch information
1 parent
792cf5b
commit 6a21eef
Showing
2 changed files
with
42 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,38 @@ | |
|
||
RSpec.describe CbvFlowInvitation, type: :model do | ||
let(:valid_attributes) do | ||
attributes_for(:cbv_flow_invitation, :nyc) | ||
attributes_for(:cbv_flow_invitation, :nyc).merge(user: create(:user, site_id: "nyc")) | ||
end | ||
let(:invalid_email_no_tld) { "johndoe@gmail" } | ||
let(:valid_email) { "[email protected]" } | ||
|
||
describe "validations" do | ||
context "for all invitations" do | ||
context "validates email addresses" do | ||
context "when email address is valid" do | ||
valid_email_addresses = %w[[email protected] [email protected] [email protected],[email protected]] | ||
valid_email_addresses.each do |email| | ||
it "#{email} is valid" do | ||
invitation = CbvFlowInvitation.new(valid_attributes.merge(email_address: email)) | ||
expect(invitation).to be_valid | ||
end | ||
end | ||
end | ||
|
||
context "when email address is invalid" do | ||
invalid_email_addresses = %w[johndoe@gmail [email protected] [email protected] johndoe@gmail\ .\ com] | ||
invalid_email_addresses.each do |email| | ||
it "determines #{email} is invalid" do | ||
invitation = CbvFlowInvitation.new(valid_attributes.merge(email_address: email)) | ||
expect(invitation).not_to be_valid | ||
expect(invitation.errors[:email_address]).to include( | ||
I18n.t('activerecord.errors.models.cbv_flow_invitation.attributes.email_address.invalid_format') | ||
) | ||
end | ||
end | ||
end | ||
end | ||
|
||
it "requires email_address" do | ||
invitation = CbvFlowInvitation.new(valid_attributes.merge(email_address: nil)) | ||
expect(invitation).not_to be_valid | ||
|