Skip to content

Commit

Permalink
add more tests for profile pick_up_emails
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusPirvulescu committed Sep 15, 2024
1 parent 1fb21ab commit f9db471
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/models/partners/profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@
profile.update(pick_up_email: "")
expect(profile.split_pick_up_emails).to match_array([])
end

it "should correctly split strings" do
profile.update(pick_up_email: "test me, pick_up@org.com, pick_up2@org.com, test me")
expect(profile.split_pick_up_emails).to match_array(["test", "me", "pick_up@org.com", "pick_up2@org.com", "test", "me"])
profile.update(pick_up_email: "test me. pick_up@org.com, pick_up2@org.com. test me")
expect(profile.split_pick_up_emails).to match_array(["test", "me.", "pick_up@org.com", "pick_up2@org.com.", "test", "me"])
end
end

describe "pick up email address validation" do
Expand All @@ -210,11 +217,28 @@
context "invalid emails" do
let(:profile) { build(:partner_profile, pick_up_email: "pick_up@org.com, pick_up2@org.com, asdf") }
it "should not allow invalid email addresses" do
expect(profile).to_not be_valid
profile.update(pick_up_email: "test me, pick_up@org.com, pick_up2@org.com, test me")
expect(profile).to_not be_valid
profile.update(pick_up_email: "pick_up@org.com, pick_up2@org.com")
expect(profile).to be_valid
end

it "should not allow input having emails separated by non-word characters" do
profile.update(pick_up_email: "test me. pick_up@org.com, pick_up2@org.com. test me")
expect(profile).to_not be_valid
profile.update(pick_up_email: "pick_up@org.com. pick_up2@org.com")
expect(profile).to_not be_valid
profile.update(pick_up_email: "pick_up@org.com.pick_up2@org.com")
expect(profile).to_not be_valid
profile.update(pick_up_email: "pick_up@org.com/ pick_up2@org.com/ pick_up3@org.com")
expect(profile).to_not be_valid
profile.update(pick_up_email: "pick_up@org.com- pick_up2@org.com- pick_up3@org.com")
expect(profile).to_not be_valid
profile.update(pick_up_email: "pick_up@org.com' pick_up2@org.com' pick_up3@org.com")
expect(profile).to_not be_valid
end

it "should handle nil value" do
profile.update(pick_up_email: nil)
expect(profile).to be_valid
Expand Down

0 comments on commit f9db471

Please sign in to comment.