summaryrefslogtreecommitdiff
path: root/users/test/unit
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-11-05 17:03:55 +0100
committerAzul <azul@leap.se>2013-11-05 17:03:55 +0100
commit4a2490cc5eac1803be80fade65bbe9d32fa0bd9b (patch)
tree0d7ef7845fc9be03ac03576d7691f07c827e6669 /users/test/unit
parent99ecdbf71632970d4c83f99beea325e5d213e4c6 (diff)
Identity.destroy_all_disabled will clean up disabled identities
This is mostly for cleaning up after tests so far. But we might expand this to destroy all identities disabled before a certain date.
Diffstat (limited to 'users/test/unit')
-rw-r--r--users/test/unit/account_test.rb4
-rw-r--r--users/test/unit/identity_test.rb11
2 files changed, 14 insertions, 1 deletions
diff --git a/users/test/unit/account_test.rb b/users/test/unit/account_test.rb
index a8c6efd..4fb3c3d 100644
--- a/users/test/unit/account_test.rb
+++ b/users/test/unit/account_test.rb
@@ -2,6 +2,10 @@ require 'test_helper'
class AccountTest < ActiveSupport::TestCase
+ teardown do
+ Identity.destroy_all_disabled
+ end
+
test "create a new account" do
user = Account.create(FactoryGirl.attributes_for(:user))
assert user.valid?
diff --git a/users/test/unit/identity_test.rb b/users/test/unit/identity_test.rb
index 8270689..78ef52c 100644
--- a/users/test/unit/identity_test.rb
+++ b/users/test/unit/identity_test.rb
@@ -107,7 +107,16 @@ class IdentityTest < ActiveSupport::TestCase
other_user = find_record :user
taken = Identity.build_for other_user, address: id.address
assert !taken.valid?
- id.destroy
+ Identity.destroy_all_disabled
+ end
+
+ test "destroy all disabled identities" do
+ id = Identity.for(@user)
+ id.disable
+ id.save
+ assert Identity.count > 0
+ Identity.destroy_all_disabled
+ assert_equal 0, Identity.count
end
def alias_name