File: group_deploy_key_entity_spec.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (48 lines) | stat: -rw-r--r-- 1,296 bytes parent folder | download
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe GroupDeployKeyEntity do
  include RequestAwareEntity

  let(:user) { create(:user) }
  let(:group) { create(:group) }
  let(:group_deploy_key) { create(:group_deploy_key) }
  let(:options) { { user: user } }

  let(:entity) { described_class.new(group_deploy_key, options) }

  before do
    group.group_deploy_keys << group_deploy_key
  end

  describe 'returns group deploy keys with a group a user can read' do
    let(:expected_result) do
      {
        id: group_deploy_key.id,
        user_id: group_deploy_key.user_id,
        title: group_deploy_key.title,
        fingerprint: group_deploy_key.fingerprint,
        fingerprint_sha256: group_deploy_key.fingerprint_sha256,
        created_at: group_deploy_key.created_at,
        expires_at: group_deploy_key.expires_at,
        updated_at: group_deploy_key.updated_at,
        can_edit: false,
        group_deploy_keys_groups: [
          {
            can_push: false,
            group:
            {
              id: group.id,
              name: group.name,
              full_path: group.full_path,
              full_name: group.full_name
            }
          }
        ]
      }
    end

    it { expect(entity.as_json).to eq(expected_result) }
  end
end