Welcome to mirror list, hosted at ThFree Co, Russian Federation.

safe_device_detector_spec.rb « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 56ba084c4357ddd3c5f7a16025caf5e534ccb65e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

require 'fast_spec_helper'
require 'device_detector'
require_relative '../../../lib/gitlab/safe_device_detector'

RSpec.describe Gitlab::SafeDeviceDetector, feature_category: :system_access do
  it 'retains the behavior for normal user agents' do
    chrome_user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 \
    (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"

    expect(described_class.new(chrome_user_agent).user_agent).to be_eql(chrome_user_agent)
    expect(described_class.new(chrome_user_agent).name).to be_eql('Chrome')
  end

  it 'truncates big user agents' do
    big_user_agent = "chrome #{'abc' * 1024}"
    expect(described_class.new(big_user_agent).user_agent).not_to be_eql(big_user_agent)
  end
end