diff options
author | Krasimir Angelov <kangelov@gitlab.com> | 2019-07-02 21:56:48 +0300 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2019-07-02 21:56:48 +0300 |
commit | d745ff0431130a760a7a59899c26410dc887f77a (patch) | |
tree | 8f12c60eaad6a5eb897be9cd03d048e971218511 /spec/services/deploy_tokens | |
parent | 4b050fc283fcc0f703d219a54dab4a02f10e475d (diff) |
Add username to deploy tokens
This new attribute is optional and used when set instead of the default
format `gitlab+deploy-token-#{id}`.
Empty usernames will be saved as null in the database.
Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/50228.
Diffstat (limited to 'spec/services/deploy_tokens')
-rw-r--r-- | spec/services/deploy_tokens/create_service_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/services/deploy_tokens/create_service_spec.rb b/spec/services/deploy_tokens/create_service_spec.rb index 886ffd4593d..fbb66fe4cb7 100644 --- a/spec/services/deploy_tokens/create_service_spec.rb +++ b/spec/services/deploy_tokens/create_service_spec.rb @@ -32,6 +32,22 @@ describe DeployTokens::CreateService do end end + context 'when username is empty string' do + let(:deploy_token_params) { attributes_for(:deploy_token, username: '') } + + it 'converts it to nil' do + expect(subject.read_attribute(:username)).to be_nil + end + end + + context 'when username is provided' do + let(:deploy_token_params) { attributes_for(:deploy_token, username: 'deployer') } + + it 'keeps the provided username' do + expect(subject.read_attribute(:username)).to eq('deployer') + end + end + context 'when the deploy token is invalid' do let(:deploy_token_params) { attributes_for(:deploy_token, read_repository: false, read_registry: false) } |