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

representable_spec.rb « representation « github_import « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4bc495c40f5455aa5da971971ccc1087c9cd3702 (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
36
37
38
39
40
41
42
43
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::GithubImport::Representation::Representable, feature_category: :importers do
  let(:representation_class) do
    subject_module = described_class

    Class.new do
      include subject_module
    end
  end

  let(:representable) { representation_class.new }

  describe '#github_identifiers' do
    subject(:github_identifiers) { representable.github_identifiers }

    context 'when class does not define `#github_identifiers`' do
      it 'tracks the error' do
        error = NotImplementedError.new('Subclasses must implement #github_identifiers')

        expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception).with(error)
        is_expected.to eq({})
      end
    end

    context 'when class defines `#github_identifiers`' do
      let(:representation_class) do
        Class.new(super()) do
          def github_identifiers
            { id: 1 }
          end
        end
      end

      it 'does not track an exception and returns the identifiers' do
        expect(Gitlab::ErrorTracking).not_to receive(:track_and_raise_for_dev_exception)
        is_expected.to eq({ id: 1 })
      end
    end
  end
end