diff options
author | Azul <azul@leap.se> | 2013-11-05 12:12:13 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2013-11-05 12:15:08 +0100 |
commit | 99ecdbf71632970d4c83f99beea325e5d213e4c6 (patch) | |
tree | 6e57e8d24fe1c5a07e90c9e9203ff13580848077 /users/test | |
parent | b4ca13257341792f5e6496264c421af1888bcdb8 (diff) |
disabled identities to block handles after a user was deleted
Diffstat (limited to 'users/test')
-rw-r--r-- | users/test/unit/account_test.rb | 3 | ||||
-rw-r--r-- | users/test/unit/identity_test.rb | 20 |
2 files changed, 22 insertions, 1 deletions
diff --git a/users/test/unit/account_test.rb b/users/test/unit/account_test.rb index 94a9980..a8c6efd 100644 --- a/users/test/unit/account_test.rb +++ b/users/test/unit/account_test.rb @@ -13,7 +13,8 @@ class AccountTest < ActiveSupport::TestCase end test "create and remove a user account" do - assert_no_difference "Identity.count" do + # We keep an identity that will block the handle from being reused. + assert_difference "Identity.count" do assert_no_difference "User.count" do user = Account.create(FactoryGirl.attributes_for(:user)) user.account.destroy diff --git a/users/test/unit/identity_test.rb b/users/test/unit/identity_test.rb index 0842a77..8270689 100644 --- a/users/test/unit/identity_test.rb +++ b/users/test/unit/identity_test.rb @@ -90,6 +90,26 @@ class IdentityTest < ActiveSupport::TestCase assert id.errors.messages[:destination].include? "needs to be a valid email address" end + test "disabled identity" do + id = Identity.for(@user) + id.disable + assert_equal @user.email_address, id.address + assert_equal nil, id.destination + assert_equal nil, id.user + assert !id.enabled? + assert id.valid? + end + + test "disabled identity blocks handle" do + id = Identity.for(@user) + id.disable + id.save + other_user = find_record :user + taken = Identity.build_for other_user, address: id.address + assert !taken.valid? + id.destroy + end + def alias_name @alias_name ||= Faker::Internet.user_name end |