summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/reports/security/link_spec.rb
blob: 7b55af27f4dcae45fdc122c73f988a9ac31da8dc (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'

RSpec.describe Gitlab::Ci::Reports::Security::Link do
  subject(:security_link) { described_class.new(name: 'CVE-2020-0202', url: 'https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-0202') }

  describe '#initialize' do
    context 'when all params are given' do
      it 'initializes an instance' do
        expect { subject }.not_to raise_error

        expect(subject).to have_attributes(
          name: 'CVE-2020-0202',
          url: 'https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-0202'
        )
      end
    end

    describe '#to_hash' do
      it 'returns expected hash' do
        expect(security_link.to_hash).to eq(
          {
            name: 'CVE-2020-0202',
            url: 'https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-0202'
          }
        )
      end
    end
  end
end