debian-mirror-gitlab/spec/serializers/group_link/group_group_link_entity_spec.rb

33 lines
841 B
Ruby
Raw Normal View History

2020-11-24 15:15:51 +05:30
# frozen_string_literal: true
require 'spec_helper'
2021-03-11 19:13:27 +05:30
RSpec.describe GroupLink::GroupGroupLinkEntity do
2020-11-24 15:15:51 +05:30
include_context 'group_group_link'
2021-01-03 14:25:43 +05:30
let_it_be(:current_user) { create(:user) }
2021-04-29 21:17:54 +05:30
2021-01-03 14:25:43 +05:30
let(:entity) { described_class.new(group_group_link) }
before do
allow(entity).to receive(:current_user).and_return(current_user)
end
2020-11-24 15:15:51 +05:30
it 'matches json schema' do
2021-03-11 19:13:27 +05:30
expect(entity.to_json).to match_schema('group_link/group_group_link')
2021-01-03 14:25:43 +05:30
end
2021-03-11 19:13:27 +05:30
context 'when current user has `:admin_group_member` permissions' do
2021-01-03 14:25:43 +05:30
before do
allow(entity).to receive(:can?).with(current_user, :admin_group_member, shared_group).and_return(true)
end
2021-03-11 19:13:27 +05:30
it 'exposes `can_update` and `can_remove` as `true`' do
2021-01-03 14:25:43 +05:30
json = entity.as_json
expect(json[:can_update]).to be true
expect(json[:can_remove]).to be true
end
2020-11-24 15:15:51 +05:30
end
end