summaryrefslogtreecommitdiff
path: root/users/test/unit
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-07-18 17:17:36 +0200
committerAzul <azul@leap.se>2013-07-24 10:55:51 +0200
commit0acace58c31c96fc1f8836167aeb4f204f72617f (patch)
tree4738cf2fab5f67afdcdae7373914b9bd66cfd95e /users/test/unit
parentd96fac2de074bbe3a44d888af5ceaff45b1b9b27 (diff)
allow available and unique forwards only
Diffstat (limited to 'users/test/unit')
-rw-r--r--users/test/unit/identity_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/users/test/unit/identity_test.rb b/users/test/unit/identity_test.rb
index a5d30b0..4ebd72e 100644
--- a/users/test/unit/identity_test.rb
+++ b/users/test/unit/identity_test.rb
@@ -39,6 +39,24 @@ class IdentityTest < ActiveSupport::TestCase
id.save
end
+ test "prevents duplicates" do
+ id = @user.create_identity address: alias_name, destination: forward_address
+ dup = @user.build_identity address: alias_name, destination: forward_address
+ assert !dup.valid?
+ assert_equal ["This alias already exists"], dup.errors[:base]
+ end
+
+ test "validates availability" do
+ other_user = FactoryGirl.create(:user)
+ id = @user.create_identity address: alias_name, destination: forward_address
+ taken = other_user.build_identity address: alias_name
+ assert !taken.valid?
+ assert_equal ["This email has already been taken"], taken.errors[:base]
+ other_user.destroy
+ end
+
+
+
def alias_name
@alias_name ||= Faker::Internet.user_name
end