diff options
author | Mayra Cabrera <mcabrera@gitlab.com> | 2018-04-05 20:22:34 +0300 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2018-04-07 05:20:16 +0300 |
commit | 8315861c9a50675b4f4f4ca536f0da90f27994f3 (patch) | |
tree | b5f25e5dbd74621ef77d480ba69f4f21d5c00d7d /spec/services/deploy_tokens | |
parent | 72220a99d1cdbcf8a914f9e765c43e63eaee2548 (diff) |
Include ProjectDeployTokens
Also:
- Changes scopes from serializer to use boolean columns
- Fixes broken specs
Diffstat (limited to 'spec/services/deploy_tokens')
-rw-r--r-- | spec/services/deploy_tokens/create_service_spec.rb | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/spec/services/deploy_tokens/create_service_spec.rb b/spec/services/deploy_tokens/create_service_spec.rb index df18213cf84..4830f17faa8 100644 --- a/spec/services/deploy_tokens/create_service_spec.rb +++ b/spec/services/deploy_tokens/create_service_spec.rb @@ -13,42 +13,50 @@ describe DeployTokens::CreateService, :clean_gitlab_redis_shared_state do expect { subject }.to change { DeployToken.count }.by(1) end - it 'returns a DeployToken' do - expect(subject).to be_an_instance_of DeployToken + it 'should create a new ProjectDeployToken' do + expect { subject }.to change { ProjectDeployToken.count }.by(1) end - it 'should assign the DeployToken to the project' do - expect(subject.project).to eq(project) + it 'returns a DeployToken' do + expect(subject).to be_an_instance_of DeployToken end it 'should store the token on redis' do - redis_key = subject.redis_shared_state_key(user.id) + redis_key = DeployToken.redis_shared_state_key(user.id) + subject 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" + it 'should not store deploy token attributes on redis' do + redis_key = DeployToken.redis_shared_state_key(user.id) + ":attributes" + subject 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: []) } + let(:deploy_token_params) { attributes_for(:deploy_token, read_repository: false, read_registry: false) } - it 'it should not create a new DeployToken' do + it 'should not create a new DeployToken' do expect { subject }.not_to change { DeployToken.count } end + it 'should not create a new ProjectDeployToken' do + expect { subject }.not_to change { ProjectDeployToken.count } + end + it 'should not store the token on redis' do - redis_key = subject.redis_shared_state_key(user.id) + redis_key = DeployToken.redis_shared_state_key(user.id) + subject 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" + redis_key = DeployToken.redis_shared_state_key(user.id) + ":attributes" + subject expect(Gitlab::Redis::SharedState.with { |redis| redis.get(redis_key) }).not_to be_nil end |