Welcome to mirror list, hosted at ThFree Co, Russian Federation.

personal_access_token_with_details_spec.rb « entities « api « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a53d6febba1a8fc18953e955fcd41bab68f51d0b (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
28
29
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe API::Entities::PersonalAccessTokenWithDetails do
  describe '#as_json' do
    let_it_be(:user) { create(:user) }
    let_it_be(:token) { create(:personal_access_token, user: user, expires_at: nil) }

    let(:entity) { described_class.new(token) }

    it 'returns token data' do
      expect(entity.as_json).to eq({
         id: token.id,
         name: token.name,
         revoked: false,
         created_at: token.created_at,
         scopes: ['api'],
         user_id: user.id,
         last_used_at: nil,
         active: true,
         expires_at: nil,
         expired: false,
         expires_soon: false,
         revoke_path: Gitlab::Routing.url_helpers.revoke_profile_personal_access_token_path(token)
       })
    end
  end
end