diff options
Diffstat (limited to 'spec/workers/concerns/gitlab/github_import/object_importer_spec.rb')
-rw-r--r-- | spec/workers/concerns/gitlab/github_import/object_importer_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb b/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb index ece0c5053cb..02190201986 100644 --- a/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb +++ b/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb @@ -194,6 +194,43 @@ RSpec.describe Gitlab::GithubImport::ObjectImporter, :aggregate_failures do .to raise_error(NoMethodError, /^undefined method `github_identifiers/) end end + + context 'when the record is invalid' do + it 'logs an error' do + expect(Gitlab::GithubImport::Logger) + .to receive(:info) + .with( + { + github_identifiers: github_identifiers, + message: 'starting importer', + project_id: project.id, + importer: 'klass_name' + } + ) + + expect(importer_class) + .to receive(:new) + .with(instance_of(MockRepresantation), project, client) + .and_return(importer_instance) + + exception = ActiveRecord::RecordInvalid.new + expect(importer_instance) + .to receive(:execute) + .and_raise(exception) + + expect(Gitlab::Import::ImportFailureService) + .to receive(:track) + .with( + project_id: project.id, + exception: exception, + error_source: 'klass_name', + fail_import: false + ) + .and_call_original + + worker.import(project, client, { 'number' => 10, 'github_id' => 1 }) + end + end end describe '#increment_object_counter?' do |