Sha256: ba483f668b2e808e8834c3a9588e5ed3702eb1d1ba56ccd9279f9ca6706b8122

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 KB

Contents

require 'test_helper'

class AccountTest < ActiveSupport::TestCase
  include ActionMailer::TestHelper

  test 'confirmed?' do
    account = QuoVadis::Account.new
    refute account.confirmed?

    account.confirmed_at = Time.now
    assert account.confirmed?
  end


  test 'notifies on identifier change when notifier is not email' do
    p = Person.create! username: 'bob', email: 'bob@example.com', password: 'secretsecret'
    assert_enqueued_email_with QuoVadis::Mailer, :identifier_change_notification, args: {email: 'bob@example.com', identifier: 'username'} do
      assert_enqueued_emails 1 do
        p.update username: 'robert@example.com'
      end
    end
  end


  test 'does not notify on identifier change when notifier is email' do
    u = User.create! name: 'bob', email: 'bob@example.com', password: '123456789abc'
    assert_enqueued_email_with QuoVadis::Mailer, :email_change_notification, args: {email: 'bob@example.com'} do
      assert_enqueued_emails 1 do
        u.update email: 'robert@example.com'
      end
    end
  end


  test 'revoke' do
    u = User.create! name: 'bob', email: 'bob@example.com', password: '123456789abc'
    account = u.qv_account
    account.create_totp last_used_at: 1.minute.ago
    account.generate_recovery_codes

    u.revoke_authentication_credentials
    account.reload

    assert_nil account.password
    assert_nil account.totp
    assert_empty account.recovery_codes
    assert_empty account.sessions
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quo_vadis-2.1.2 test/models/account_test.rb
quo_vadis-2.1.1 test/models/account_test.rb