summaryrefslogtreecommitdiff
path: root/users/test/unit
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2013-09-24 01:37:57 -0700
committerazul <azul@riseup.net>2013-09-24 01:37:57 -0700
commit98db0cc42019dfcd90d58e0126fe691590fde2e2 (patch)
treec8a3bf7fe4c8001718ea31e56d036b267ee362e6 /users/test/unit
parentc081062ea16526dfbf3ad9ba0fdec724be67949c (diff)
parenta9c68ba0bbba7a95e9b4a3ff24554d1b0af6cbc5 (diff)
Merge pull request #88 from jessib/feature/only_lower_case_aliases
Feature/only lower case aliases
Diffstat (limited to 'users/test/unit')
-rw-r--r--users/test/unit/identity_test.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/users/test/unit/identity_test.rb b/users/test/unit/identity_test.rb
index fa88315..02f14c0 100644
--- a/users/test/unit/identity_test.rb
+++ b/users/test/unit/identity_test.rb
@@ -70,6 +70,32 @@ class IdentityTest < ActiveSupport::TestCase
id.destroy
end
+ 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 "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:
+ assert id.errors.messages.flatten(2).include? "Must begin with a lowercase letter"
+ 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
end