Commit 1beb7ffc authored by Ash McKenzie's avatar Ash McKenzie

Add missing spec coverage for LfsToken

Added specs for #deploy_key_pushable?() and #type()
parent 22954f22
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment