Add missing spec coverage for LfsToken

Added specs for #deploy_key_pushable?() and #type()
This commit is contained in:
Ash McKenzie 2018-12-05 15:22:03 +11:00
parent 22954f2202
commit 1beb7ffc54
No known key found for this signature in database
GPG key ID: A1253B4953E8D3E6

View file

@ -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