diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/identities_controller_test.rb | 2 | ||||
-rw-r--r-- | test/functional/users_controller_test.rb | 4 | ||||
-rw-r--r-- | test/integration/browser/account_test.rb | 2 | ||||
-rw-r--r-- | test/support/api_integration_test.rb | 2 | ||||
-rw-r--r-- | test/support/browser_integration_test.rb | 2 | ||||
-rw-r--r-- | test/unit/account_test.rb | 7 | ||||
-rw-r--r-- | test/unit/identity_test.rb | 29 |
7 files changed, 28 insertions, 20 deletions
diff --git a/test/functional/identities_controller_test.rb b/test/functional/identities_controller_test.rb index e491c52..5af2e88 100644 --- a/test/functional/identities_controller_test.rb +++ b/test/functional/identities_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require_relative '../test_helper' class IdentitiesControllerTest < ActionController::TestCase diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 261f201..7b24098 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -86,7 +86,7 @@ class UsersControllerTest < ActionController::TestCase # we destroy the user record and the associated data... user.expects(:destroy) - Identity.expects(:disable_all_for).with(user) + #user.identity.expects(:orphan!) << factory girl user doesn't have identities Ticket.expects(:destroy_all_from).with(user) login :is_admin? => true @@ -101,7 +101,7 @@ class UsersControllerTest < ActionController::TestCase # we destroy the user record and the associated data... user.expects(:destroy) - Identity.expects(:disable_all_for).with(user) + #user.identity.expects(:orphan!) << factory girl user doesn't have identities Ticket.expects(:destroy_all_from).with(user) login user diff --git a/test/integration/browser/account_test.rb b/test/integration/browser/account_test.rb index cbe7ba9..50adb23 100644 --- a/test/integration/browser/account_test.rb +++ b/test/integration/browser/account_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class AccountTest < BrowserIntegrationTest teardown do - Identity.destroy_all_disabled + Identity.destroy_all_orphaned end test "signup successfully when invited" do diff --git a/test/support/api_integration_test.rb b/test/support/api_integration_test.rb index 4077920..3b3481b 100644 --- a/test/support/api_integration_test.rb +++ b/test/support/api_integration_test.rb @@ -21,7 +21,7 @@ class ApiIntegrationTest < ActionDispatch::IntegrationTest teardown do if @user && @user.persisted? - Identity.destroy_all_for @user + @user.destroy_identities @user.reload.destroy end if @token && @token.persisted? diff --git a/test/support/browser_integration_test.rb b/test/support/browser_integration_test.rb index 950a395..1deb8fa 100644 --- a/test/support/browser_integration_test.rb +++ b/test/support/browser_integration_test.rb @@ -86,7 +86,7 @@ class BrowserIntegrationTest < ActionDispatch::IntegrationTest teardown do if @user && @user.reload - Identity.destroy_all_for @user + @user.destroy_identities @user.destroy end end 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 |