summaryrefslogtreecommitdiff
path: root/spec/serializers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-17 00:07:27 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-17 00:07:27 +0000
commitb7e6df1abde1112ae1fa0778f45d6053eec3f052 (patch)
treea879d991b78433cbf419e4968c410982802dece3 /spec/serializers
parente924e9e7cb9df21b3bc3d51d5f955da28ba3a225 (diff)
downloadgitlab-ce-b7e6df1abde1112ae1fa0778f45d6053eec3f052.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers')
-rw-r--r--spec/serializers/deploy_key_entity_spec.rb34
1 files changed, 24 insertions, 10 deletions
diff --git a/spec/serializers/deploy_key_entity_spec.rb b/spec/serializers/deploy_key_entity_spec.rb
index 9e76d36c302..607adfc2488 100644
--- a/spec/serializers/deploy_key_entity_spec.rb
+++ b/spec/serializers/deploy_key_entity_spec.rb
@@ -8,14 +8,15 @@ describe DeployKeyEntity do
let(:user) { create(:user) }
let(:project) { create(:project, :internal)}
let(:project_private) { create(:project, :private)}
- let!(:project_pending_delete) { create(:project, :internal, pending_delete: true) }
let(:deploy_key) { create(:deploy_key) }
- let!(:deploy_key_internal) { create(:deploy_keys_project, project: project, deploy_key: deploy_key) }
- let!(:deploy_key_private) { create(:deploy_keys_project, project: project_private, deploy_key: deploy_key) }
- let!(:deploy_key_pending_delete) { create(:deploy_keys_project, project: project_pending_delete, deploy_key: deploy_key) }
let(:entity) { described_class.new(deploy_key, user: user) }
+ before do
+ project.deploy_keys << deploy_key
+ project_private.deploy_keys << deploy_key
+ end
+
describe 'returns deploy keys with projects a user can read' do
let(:expected_result) do
{
@@ -46,17 +47,30 @@ describe DeployKeyEntity do
it { expect(entity.as_json).to eq(expected_result) }
end
- describe 'returns can_edit true if user is a maintainer of project' do
+ context 'user is an admin' do
+ let(:user) { create(:user, :admin) }
+
+ it { expect(entity.as_json).to include(can_edit: true) }
+ end
+
+ context 'user is a project maintainer' do
before do
project.add_maintainer(user)
end
- it { expect(entity.as_json).to include(can_edit: true) }
- end
+ context 'project deploy key' do
+ it { expect(entity.as_json).to include(can_edit: true) }
+ end
- describe 'returns can_edit true if a user admin' do
- let(:user) { create(:user, :admin) }
+ context 'public deploy key' do
+ let(:deploy_key_public) { create(:deploy_key, public: true) }
+ let(:entity_public) { described_class.new(deploy_key_public, { user: user, project: project }) }
- it { expect(entity.as_json).to include(can_edit: true) }
+ before do
+ project.deploy_keys << deploy_key_public
+ end
+
+ it { expect(entity_public.as_json).to include(can_edit: true) }
+ end
end
end