Skip to content

Commit

Permalink
update test with unique pick up emails
Browse files Browse the repository at this point in the history
  • Loading branch information
panacotar committed Sep 12, 2024
1 parent 1389c1d commit 5be76e1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions spec/models/partners/profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,29 +169,31 @@

describe "pick up email address validation" do
context "number of email addresses" do
let(:profile) { build(:partner_profile, pick_up_email: "[email protected], [email protected], [email protected], [email protected]") }
let(:profile) { build(:partner_profile, pick_up_email: "[email protected], [email protected], [email protected], [email protected]") }
it "should not allow more than three email addresses" do
expect(profile.valid?).to eq(false)
profile.update(pick_up_email: "[email protected], [email protected], [email protected]")
profile.update(pick_up_email: "[email protected], [email protected], [email protected]")
expect(profile.valid?).to eq(true)
end

it "should allow optional whitespace between email addresses" do
profile.update(pick_up_email: "[email protected],[email protected]")
profile.update(pick_up_email: "[email protected], [email protected]")
expect(profile.valid?).to eq(true)
profile.update(pick_up_email: "[email protected],[email protected]")
expect(profile.valid?).to eq(true)
end

it "should disregard commas at the beginning or end of the string" do
profile.update(pick_up_email: ", [email protected], [email protected], ")
profile.update(pick_up_email: ", [email protected], [email protected],")
expect(profile.valid?).to eq(true)
end
end

context "invalid emails" do
let(:profile) { build(:partner_profile, pick_up_email: "[email protected], [email protected], asdf") }
let(:profile) { build(:partner_profile, pick_up_email: "[email protected], [email protected], asdf") }
it "should not allow invalid email addresses" do
expect(profile.valid?).to eq(false)
profile.update(pick_up_email: "[email protected]")
profile.update(pick_up_email: "[email protected], [email protected]")
expect(profile.valid?).to eq(true)
end

Expand Down

0 comments on commit 5be76e1

Please sign in to comment.