diff options
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/account_test.rb | 20 | ||||
-rw-r--r-- | test/unit/identity_test.rb | 10 |
2 files changed, 20 insertions, 10 deletions
diff --git a/test/unit/account_test.rb b/test/unit/account_test.rb index 6b814b6..7c26d5c 100644 --- a/test/unit/account_test.rb +++ b/test/unit/account_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require_relative '../test_helper' class AccountTest < ActiveSupport::TestCase @@ -23,10 +23,10 @@ class AccountTest < ActiveSupport::TestCase test "create a new account" do with_config invite_required: false do - user = Account.create(FactoryGirl.attributes_for(:user)) - assert user.valid?, "unexpected errors: #{user.errors.inspect}" - assert user.persisted? - user.account.destroy + user = Account.create(FactoryGirl.attributes_for(:user)) + assert user.valid?, "unexpected errors: #{user.errors.inspect}" + assert user.persisted? + user.account.destroy end end @@ -80,4 +80,14 @@ class AccountTest < ActiveSupport::TestCase assert_equal 0, user_code.invite_count end + + test "disabled accounts have no cert fingerprints" do + user = Account.create(FactoryGirl.attributes_for(:user)) + 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 + user.account.disable + assert_equal({}, Identity.for(user).cert_fingerprints) + end end diff --git a/test/unit/identity_test.rb b/test/unit/identity_test.rb index f5c95f8..1f93109 100644 --- a/test/unit/identity_test.rb +++ b/test/unit/identity_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require_relative '../test_helper' class IdentityTest < ActiveSupport::TestCase include StubRecordHelper @@ -177,9 +177,9 @@ class IdentityTest < ActiveSupport::TestCase end def cert_stub - # make this expire later than the others so it's on top - # when sorting by expiry descending. - @cert_stub ||= stub expiry: 2.month.from_now, - fingerprint: SecureRandom.hex + # make this expire later than the other test identities + # so that the query that returns certs sorted by expiry will + # return cert_stub first. + @cert_stub ||= stub(expiry: 2.month.from_now, fingerprint: SecureRandom.hex) end end |