diff options
author | Rémy Coutable <remy@rymai.me> | 2017-06-07 14:37:50 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-06-07 14:37:50 +0000 |
commit | ee0e3ffc057d9a033dab3fcc9025e71a6e76bc74 (patch) | |
tree | f326227fa14deacbdd323378d58bd2f6ef86f6d0 /spec/serializers | |
parent | d030393adb414a9264623f403d2b6f39adcf3b4e (diff) | |
parent | 3d70eeb5bb9dac8073a149547dc3b85c90d65e7d (diff) | |
download | gitlab-ce-ee0e3ffc057d9a033dab3fcc9025e71a6e76bc74.tar.gz |
Merge branch '3191-deploy-keys-update' into 'master'
Implement ability to update deploy keys
Closes #3191
See merge request !10383
Diffstat (limited to 'spec/serializers')
-rw-r--r-- | spec/serializers/deploy_key_entity_spec.rb | 61 |
1 files changed, 39 insertions, 22 deletions
diff --git a/spec/serializers/deploy_key_entity_spec.rb b/spec/serializers/deploy_key_entity_spec.rb index e73fbe190ca..ed89fccc3d0 100644 --- a/spec/serializers/deploy_key_entity_spec.rb +++ b/spec/serializers/deploy_key_entity_spec.rb @@ -12,27 +12,44 @@ describe DeployKeyEntity do let(:entity) { described_class.new(deploy_key, user: user) } - it 'returns deploy keys with projects a user can read' do - expected_result = { - id: deploy_key.id, - user_id: deploy_key.user_id, - title: deploy_key.title, - fingerprint: deploy_key.fingerprint, - can_push: deploy_key.can_push, - destroyed_when_orphaned: true, - almost_orphaned: false, - created_at: deploy_key.created_at, - updated_at: deploy_key.updated_at, - projects: [ - { - id: project.id, - name: project.name, - full_path: namespace_project_path(project.namespace, project), - full_name: project.full_name - } - ] - } - - expect(entity.as_json).to eq(expected_result) + describe 'returns deploy keys with projects a user can read' do + let(:expected_result) do + { + id: deploy_key.id, + user_id: deploy_key.user_id, + title: deploy_key.title, + fingerprint: deploy_key.fingerprint, + can_push: deploy_key.can_push, + destroyed_when_orphaned: true, + almost_orphaned: false, + created_at: deploy_key.created_at, + updated_at: deploy_key.updated_at, + can_edit: false, + projects: [ + { + id: project.id, + name: project.name, + full_path: namespace_project_path(project.namespace, project), + full_name: project.full_name + } + ] + } + end + + it { expect(entity.as_json).to eq(expected_result) } + end + + describe 'returns can_edit true if user is a master of project' do + before do + project.add_master(user) + end + + 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) } + + it { expect(entity.as_json).to include(can_edit: true) } end end |