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

group_group_link_entity_spec.rb « serializers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9affe4af3818c1d7f25d754ad982b58b986d9b37 (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
30
31
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe GroupGroupLinkEntity do
  include_context 'group_group_link'

  let_it_be(:current_user) { create(:user) }
  let(:entity) { described_class.new(group_group_link) }

  before do
    allow(entity).to receive(:current_user).and_return(current_user)
  end

  it 'matches json schema' do
    expect(entity.to_json).to match_schema('entities/group_group_link')
  end

  context 'a user with :admin_group_member permissions' do
    before do
      allow(entity).to receive(:can?).with(current_user, :admin_group_member, shared_group).and_return(true)
    end

    it 'sets `can_update` and `can_remove` to `true`' do
      json = entity.as_json

      expect(json[:can_update]).to be true
      expect(json[:can_remove]).to be true
    end
  end
end