summaryrefslogtreecommitdiff
path: root/spec/serializers/group_link/project_group_link_entity_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-18 10:34:06 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-18 10:34:06 +0000
commit859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch)
treed7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/serializers/group_link/project_group_link_entity_spec.rb
parent446d496a6d000c73a304be52587cd9bbc7493136 (diff)
downloadgitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/serializers/group_link/project_group_link_entity_spec.rb')
-rw-r--r--spec/serializers/group_link/project_group_link_entity_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/serializers/group_link/project_group_link_entity_spec.rb b/spec/serializers/group_link/project_group_link_entity_spec.rb
new file mode 100644
index 00000000000..0bb3d06933b
--- /dev/null
+++ b/spec/serializers/group_link/project_group_link_entity_spec.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GroupLink::ProjectGroupLinkEntity do
+ let_it_be(:current_user) { create(:user) }
+ let_it_be(:project_group_link) { create(:project_group_link) }
+ let(:entity) { described_class.new(project_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('group_link/project_group_link')
+ end
+
+ context 'when current user has `admin_project_member` permissions' do
+ before do
+ allow(entity).to receive(:can?).with(current_user, :admin_project_member, project_group_link.project).and_return(true)
+ end
+
+ it 'exposes `can_update` and `can_remove` as `true`' do
+ json = entity.as_json
+
+ expect(json[:can_update]).to be true
+ expect(json[:can_remove]).to be true
+ end
+ end
+end