summaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/account_test.rb7
-rw-r--r--test/unit/identity_test.rb29
2 files changed, 22 insertions, 14 deletions
diff --git a/test/unit/account_test.rb b/test/unit/account_test.rb
index 7c26d5c..9680b33 100644
--- a/test/unit/account_test.rb
+++ b/test/unit/account_test.rb
@@ -8,7 +8,7 @@ class AccountTest < ActiveSupport::TestCase
end
teardown do
- Identity.destroy_all_disabled
+ Identity.destroy_all_orphaned
end
test "create a new account when invited" do
@@ -86,8 +86,11 @@ class AccountTest < ActiveSupport::TestCase
cert = stub(expiry: 1.month.from_now, fingerprint: SecureRandom.hex)
user.identity.register_cert cert
user.identity.save
- assert_equal cert.fingerprint, Identity.for(user).cert_fingerprints.keys.first
+ assert_equal(cert.fingerprint, Identity.for(user).cert_fingerprints.keys.first)
user.account.disable
assert_equal({}, Identity.for(user).cert_fingerprints)
+ assert_equal(cert.fingerprint, Identity.for(user).read_attribute(:disabled_cert_fingerprints).keys.first)
+ user.account.enable
+ assert_equal(cert.fingerprint, Identity.for(user).cert_fingerprints.keys.first)
end
end
diff --git a/test/unit/identity_test.rb b/test/unit/identity_test.rb
index 1f93109..9d4bc90 100644
--- a/test/unit/identity_test.rb
+++ b/test/unit/identity_test.rb
@@ -110,33 +110,38 @@ class IdentityTest < ActiveSupport::TestCase
assert @id.errors.messages[:destination].include? "needs to be a valid email address"
end
- test "disabled identity" do
+ test "disable identity" do
@id = Identity.for(@user)
- @id.disable
+ @id.disable!
+ assert !@id.enabled?
+ assert @id.valid?
+ end
+
+ test "orphan identity" do
+ @id = Identity.for(@user)
+ @id.orphan!
assert_equal @user.email_address, @id.address
assert_equal nil, @id.destination
assert_equal nil, @id.user
- assert !@id.enabled?
+ assert @id.orphaned?
assert @id.valid?
end
- test "disabled identity blocks handle" do
+ test "orphaned identity blocks handle" do
@id = Identity.for(@user)
- @id.disable
- @id.save
+ @id.orphan!
other_user = find_record :user
taken = Identity.build_for other_user, address: @id.address
assert !taken.valid?
assert_equal ["has already been taken"], taken.errors[:address]
end
- test "destroy all disabled identities" do
+ test "destroy all orphaned identities" do
@id = Identity.for(@user)
- @id.disable
- @id.save
- assert Identity.disabled.count > 0
- Identity.destroy_all_disabled
- assert_equal 0, Identity.disabled.count
+ @id.orphan!
+ assert Identity.orphaned.count > 0
+ Identity.destroy_all_orphaned
+ assert_equal 0, Identity.orphaned.count
end
test "store cert fingerprint" do