webauthn_credential_spec.rb 740 B

12345678910111213141516171819
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe WebauthnCredential do
  4. describe 'Validations' do
  5. subject { Fabricate.build :webauthn_credential }
  6. it { is_expected.to validate_presence_of(:external_id) }
  7. it { is_expected.to validate_presence_of(:public_key) }
  8. it { is_expected.to validate_presence_of(:nickname) }
  9. it { is_expected.to validate_presence_of(:sign_count) }
  10. it { is_expected.to validate_uniqueness_of(:external_id) }
  11. it { is_expected.to validate_uniqueness_of(:nickname).scoped_to(:user_id) }
  12. it { is_expected.to validate_numericality_of(:sign_count).only_integer.is_greater_than_or_equal_to(0).is_less_than_or_equal_to(described_class::SIGN_COUNT_LIMIT - 1) }
  13. end
  14. end