summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/lfs_token_spec.rb
blob: 76b348637c7730b011111d74f2e5fb0074622375 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'spec_helper'

describe Gitlab::LfsToken, lib: true do
  describe '#set_token and #get_value' do
    shared_examples 'an LFS token generator' do
      it 'returns a randomly generated token' do
        token = handler.set_token

        expect(token).not_to be_nil
        expect(token).to be_a String
        expect(token.length).to eq 50
      end

      it 'returns the correct token based on the key' do
        token = handler.set_token

        expect(handler.get_value).to eq(token)
      end
    end

    context 'when the actor is a user' do
      let(:actor) { create(:user) }
      let(:handler) { described_class.new(actor) }

      it_behaves_like 'an LFS token generator'
    end

    context 'when the actor is a deploy key' do
      let(:actor) { create(:deploy_key) }
      let(:handler) { described_class.new(actor) }

      it_behaves_like 'an LFS token generator'
    end
  end
end