diff options
Diffstat (limited to 'spec/lib/gitlab/github_import/representation/representable_spec.rb')
-rw-r--r-- | spec/lib/gitlab/github_import/representation/representable_spec.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/lib/gitlab/github_import/representation/representable_spec.rb b/spec/lib/gitlab/github_import/representation/representable_spec.rb new file mode 100644 index 00000000000..4bc495c40f5 --- /dev/null +++ b/spec/lib/gitlab/github_import/representation/representable_spec.rb @@ -0,0 +1,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 |