summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/request_profiler_spec.rb
blob: fd8cbf39bcead6e20550dfe67e520eb2e98dde31 (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
require 'spec_helper'

describe Gitlab::RequestProfiler do
  describe '.profile_token' do
    it 'returns a token' do
      expect(described_class.profile_token).to be_present
    end

    it 'caches the token' do
      expect(Rails.cache).to receive(:fetch).with('profile-token')

      described_class.profile_token
    end
  end

  describe '.remove_all_profiles' do
    it 'removes Gitlab::RequestProfiler::PROFILES_DIR directory' do
      dir = described_class::PROFILES_DIR
      FileUtils.mkdir_p(dir)

      expect(Dir.exist?(dir)).to be true

      described_class.remove_all_profiles
      expect(Dir.exist?(dir)).to be false
    end
  end
end