diff options
Diffstat (limited to 'users/test/unit')
-rw-r--r-- | users/test/unit/email_aliases_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/users/test/unit/email_aliases_test.rb b/users/test/unit/email_aliases_test.rb index 5ded5bb..cec0c0b 100644 --- a/users/test/unit/email_aliases_test.rb +++ b/users/test/unit/email_aliases_test.rb @@ -20,6 +20,28 @@ class EmailAliasTest < ActiveSupport::TestCase assert_equal email_alias, @user.email_aliases.first.to_s end + test "duplicated email aliases are invalid" do + email_alias = "valid_alias@domain.net" + email_aliases = { + "0" => {:email => email_alias}, + "1" => {:email => email_alias} + } + @user.attributes = {:email_aliases_attributes => email_aliases} + @user.save + # add some more + @user.attributes = {:email_aliases_attributes => email_aliases} + assert @user.changed? + assert !@user.valid? + end + + test "email is invalid as email alias" do + email_alias = "valid_alias@domain.net" + email_aliases = { "0" => {:email => email_alias} } + @user.attributes = {:email_aliases_attributes => email_aliases, :email => email_alias} + assert @user.changed? + assert !@user.valid? + end + test "find user by email alias" do email_alias = "valid_alias@domain.net" @user.attributes = {:email_aliases_attributes => {"0" => {:email => email_alias}}} |