diff options
author | Mayra Cabrera <mcabrera@gitlab.com> | 2018-03-29 20:11:36 -0600 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2018-04-06 21:20:16 -0500 |
commit | 345ac03b7afb1dc9b941c53bc45cc3dfcf22e61c (patch) | |
tree | 42da609254928d746a961465d9ecfbff3ab71ad4 /spec/services | |
parent | 370fc05da7f95bf6621867a71d51493cf3899e25 (diff) | |
download | gitlab-ce-345ac03b7afb1dc9b941c53bc45cc3dfcf22e61c.tar.gz |
Address UX review
- Keep 'Deploy Section' open upon save, otherwise the token might get
lost
- When an error appears, display the error inside the form and also keep
the Deploy Section open
- Changue copy of revoke modal
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/deploy_tokens/create_service_spec.rb | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/spec/services/deploy_tokens/create_service_spec.rb b/spec/services/deploy_tokens/create_service_spec.rb index 84aa17971d6..df18213cf84 100644 --- a/spec/services/deploy_tokens/create_service_spec.rb +++ b/spec/services/deploy_tokens/create_service_spec.rb @@ -6,40 +6,52 @@ describe DeployTokens::CreateService, :clean_gitlab_redis_shared_state do let(:deploy_token_params) { attributes_for(:deploy_token) } describe '#execute' do - subject { described_class.new(project, user, deploy_token_params) } + subject { described_class.new(project, user, deploy_token_params).execute } context 'when the deploy token is valid' do it 'should create a new DeployToken' do - expect { subject.execute }.to change { DeployToken.count }.by(1) + expect { subject }.to change { DeployToken.count }.by(1) end - it 'should assign the DeployToken to the project' do - subject.execute + it 'returns a DeployToken' do + expect(subject).to be_an_instance_of DeployToken + end + it 'should assign the DeployToken to the project' do expect(subject.project).to eq(project) end it 'should store the token on redis' do - subject.execute - redis_key = DeployToken.redis_shared_state_key(user.id) + redis_key = subject.redis_shared_state_key(user.id) expect(Gitlab::Redis::SharedState.with { |redis| redis.get(redis_key) }).not_to be_nil end + + it 'should not store deploy token attributes on redis' do + redis_key = subject.redis_shared_state_key(user.id) + ":attributes" + + expect(Gitlab::Redis::SharedState.with { |redis| redis.get(redis_key) }).to be_nil + end end context 'when the deploy token is invalid' do let(:deploy_token_params) { attributes_for(:deploy_token, scopes: []) } it 'it should not create a new DeployToken' do - expect { subject.execute }.not_to change { DeployToken.count } + expect { subject }.not_to change { DeployToken.count } end it 'should not store the token on redis' do - subject.execute - redis_key = DeployToken.redis_shared_state_key(user.id) + redis_key = subject.redis_shared_state_key(user.id) expect(Gitlab::Redis::SharedState.with { |redis| redis.get(redis_key) }).to be_nil end + + it 'should store deploy token attributes on redis' do + redis_key = subject.redis_shared_state_key(user.id) + ":attributes" + + expect(Gitlab::Redis::SharedState.with { |redis| redis.get(redis_key) }).not_to be_nil + end end end end |