diff options
author | Ash McKenzie <amckenzie@gitlab.com> | 2018-12-05 07:22:03 +0300 |
---|---|---|
committer | Ash McKenzie <amckenzie@gitlab.com> | 2018-12-05 07:22:43 +0300 |
commit | 1beb7ffc547d9be0f35dc02f15eaf9fe0bbd34e7 (patch) | |
tree | 2f42928368dd8c09e5379c831874a689687c0c8b | |
parent | 22954f220231281360377922b709efb904559949 (diff) |
Add missing spec coverage for LfsToken
Added specs for #deploy_key_pushable?() and #type()
-rw-r--r-- | spec/lib/gitlab/lfs_token_spec.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/lib/gitlab/lfs_token_spec.rb b/spec/lib/gitlab/lfs_token_spec.rb index 9842ecb0e4d..1ec1ba19e39 100644 --- a/spec/lib/gitlab/lfs_token_spec.rb +++ b/spec/lib/gitlab/lfs_token_spec.rb @@ -185,4 +185,59 @@ describe Gitlab::LfsToken, :clean_gitlab_redis_shared_state do end end end + + describe '#deploy_key_pushable?' do + let(:lfs_token) { described_class.new(actor) } + + context 'when actor is not a DeployKey' do + let(:actor) { create(:user) } + let(:project) { create(:project) } + + it 'returns false' do + expect(lfs_token.deploy_key_pushable?(project)).to be_falsey + end + end + + context 'when actor is a DeployKey' do + let(:deploy_keys_project) { create(:deploy_keys_project, can_push: can_push) } + let(:project) { deploy_keys_project.project } + let(:actor) { deploy_keys_project.deploy_key } + + context 'but the DeployKey cannot push to the project' do + let(:can_push) { false } + + it 'returns false' do + expect(lfs_token.deploy_key_pushable?(project)).to be_falsey + end + end + + context 'and the DeployKey can push to the project' do + let(:can_push) { true } + + it 'returns true' do + expect(lfs_token.deploy_key_pushable?(project)).to be_truthy + end + end + end + end + + describe '#type' do + let(:lfs_token) { described_class.new(actor) } + + context 'when actor is not a User' do + let(:actor) { create(:deploy_key) } + + it 'returns false' do + expect(lfs_token.type).to eq(:lfs_deploy_token) + end + end + + context 'when actor is a User' do + let(:actor) { create(:user) } + + it 'returns false' do + expect(lfs_token.type).to eq(:lfs_token) + end + end + end end |