summaryrefslogtreecommitdiff
path: root/spec/factories/personal_access_tokens.rb
blob: 1b12f84d7b8b4f38b3bb6254c2fec9d77d284177 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
FactoryBot.define do
  factory :personal_access_token do
    user
    token { SecureRandom.hex(50) }
    sequence(:name) { |n| "PAT #{n}" }
    revoked false
    expires_at { 5.days.from_now }
    scopes ['api']
    impersonation false

    trait :impersonation do
      impersonation true
    end

    trait :revoked do
      revoked true
    end

    trait :expired do
      expires_at { 1.day.ago }
    end

    trait :invalid do
      token nil
    end
  end
end