From a9c68ba0bbba7a95e9b4a3ff24554d1b0af6cbc5 Mon Sep 17 00:00:00 2001 From: jessib Date: Mon, 23 Sep 2013 12:23:08 -0700 Subject: This ensures that email addresses contain only lowercase letters, and that an identity's destination is a valid Email. --- users/test/unit/identity_test.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'users/test/unit/identity_test.rb') diff --git a/users/test/unit/identity_test.rb b/users/test/unit/identity_test.rb index b3918f1..02f14c0 100644 --- a/users/test/unit/identity_test.rb +++ b/users/test/unit/identity_test.rb @@ -70,13 +70,13 @@ class IdentityTest < ActiveSupport::TestCase id.destroy end - test "fail to end non-local email address as identity address" do - id = Identity.for @user, address: 'blah@sdlfksjdfljk.com' + test "fail to add non-local email address as identity address" do + id = Identity.for @user, address: forward_address assert !id.valid? assert_match /needs to end in/, id.errors[:address].first end - test "only lowercase alias" do + test "alias must meet some conditions as login" do id = Identity.create_for @user, address: alias_name.capitalize assert !id.valid? #hacky way to do this, but okay for now: @@ -84,6 +84,17 @@ class IdentityTest < ActiveSupport::TestCase assert id.errors.messages.flatten(2).include? "Only lowercase letters, digits, . - and _ allowed." end + test "destination must be valid email address" do + id = Identity.create_for @user, address: @user.email_address, destination: 'ASKJDLFJD' + assert !id.valid? + assert id.errors.messages[:destination].include? "needs to be a valid email address" + end + + test "only lowercase destination" do + id = Identity.create_for @user, address: @user.email_address, destination: forward_address.capitalize + assert !id.valid? + assert id.errors.messages[:destination].include? "letters must be lowercase" + end def alias_name @alias_name ||= Faker::Internet.user_name -- cgit v1.2.3