summaryrefslogtreecommitdiff
path: root/users/test/unit/identity_test.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-10-10 09:52:16 +0200
committerAzul <azul@leap.se>2013-10-10 09:52:16 +0200
commitb676e6e6f5367d1be540af817062a77ee3fe7f00 (patch)
tree107c50e838d3fe2feb7da932869a9aabc62ce46b /users/test/unit/identity_test.rb
parentb60a75d8cbe25ac47bb037e9e54a7cf4e2ba4e1f (diff)
parenteaedf19e2e54ccb9933caa8dc21df13e48609b18 (diff)
Merge remote-tracking branch 'leap/develop'
Diffstat (limited to 'users/test/unit/identity_test.rb')
-rw-r--r--users/test/unit/identity_test.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/users/test/unit/identity_test.rb b/users/test/unit/identity_test.rb
index fa88315..0842a77 100644
--- a/users/test/unit/identity_test.rb
+++ b/users/test/unit/identity_test.rb
@@ -70,6 +70,26 @@ 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 same 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
+
def alias_name
@alias_name ||= Faker::Internet.user_name
end