blob: 922a433d7ac689b7e89c1c12bbd577adc9d21856 (
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
|
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GrapeLogging::Loggers::CloudflareLogger do
subject { described_class.new }
describe "#parameters" do
let(:mock_request) { ActionDispatch::Request.new({}) }
let(:start_time) { Time.new(2018, 01, 01) }
describe 'with no Cloudflare headers' do
it 'returns an empty hash' do
expect(subject.parameters(mock_request, nil)).to eq({})
end
end
describe 'with Cloudflare headers' do
before do
mock_request.headers['Cf-Ray'] = SecureRandom.hex
mock_request.headers['Cf-Request-Id'] = SecureRandom.hex
end
it 'returns the correct duration in seconds' do
data = subject.parameters(mock_request, nil)
expect(data.keys).to contain_exactly(:cf_ray, :cf_request_id)
end
end
end
end
|