From 5b5bdc3af9f4439690f19e42c756883cecd85a87 Mon Sep 17 00:00:00 2001 From: Joe Woodward <jwoodward@gitlab.com> Date: Tue, 11 Jul 2023 15:15:38 +0100 Subject: [PATCH] Return deploy key title when humanizing access levels When we humanize a protected ref access level with a deploy key we used to return "Deploy Key", however, if we look at how users and groups are humanized we return their names which identifies the user or group rather than the role. As a deploy key is not a role but rather a thing we should return the name so users have more context. Changelog: changed --- app/models/concerns/protected_ref_deploy_key_access.rb | 2 +- spec/requests/api/protected_branches_spec.rb | 2 +- spec/requests/api/protected_tags_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/protected_ref_deploy_key_access.rb b/app/models/concerns/protected_ref_deploy_key_access.rb index a62cce1368d5c..4275476a1ffec 100644 --- a/app/models/concerns/protected_ref_deploy_key_access.rb +++ b/app/models/concerns/protected_ref_deploy_key_access.rb @@ -24,7 +24,7 @@ def type end def humanize - return "Deploy key" if deploy_key.present? + return deploy_key.title if deploy_key? super end diff --git a/spec/requests/api/protected_branches_spec.rb b/spec/requests/api/protected_branches_spec.rb index 04d5f7ac20a92..ad3a69fec9d11 100644 --- a/spec/requests/api/protected_branches_spec.rb +++ b/spec/requests/api/protected_branches_spec.rb @@ -121,7 +121,7 @@ get api(route, user) expect(json_response['push_access_levels']).to include( - a_hash_including('access_level_description' => 'Deploy key', 'deploy_key_id' => deploy_key.id) + a_hash_including('access_level_description' => deploy_key.title, 'deploy_key_id' => deploy_key.id) ) end end diff --git a/spec/requests/api/protected_tags_spec.rb b/spec/requests/api/protected_tags_spec.rb index c6398e624f802..4e7227b229411 100644 --- a/spec/requests/api/protected_tags_spec.rb +++ b/spec/requests/api/protected_tags_spec.rb @@ -95,7 +95,7 @@ get api(route, user) expect(json_response['create_access_levels']).to include( - a_hash_including('access_level_description' => 'Deploy key', 'deploy_key_id' => deploy_key.id) + a_hash_including('access_level_description' => deploy_key.title, 'deploy_key_id' => deploy_key.id) ) end end -- GitLab