diff options
Diffstat (limited to 'spec/workers/concerns')
-rw-r--r-- | spec/workers/concerns/gitlab/github_import/object_importer_spec.rb | 37 | ||||
-rw-r--r-- | spec/workers/concerns/waitable_worker_spec.rb | 43 |
2 files changed, 37 insertions, 43 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 diff --git a/spec/workers/concerns/waitable_worker_spec.rb b/spec/workers/concerns/waitable_worker_spec.rb index bf156c3b8cb..1449c327052 100644 --- a/spec/workers/concerns/waitable_worker_spec.rb +++ b/spec/workers/concerns/waitable_worker_spec.rb @@ -14,12 +14,6 @@ RSpec.describe WaitableWorker do include ApplicationWorker prepend WaitableWorker - # This is a workaround for a Ruby 2.3.7 bug. rspec-mocks cannot restore - # the visibility of prepended modules. See - # https://github.com/rspec/rspec-mocks/issues/1231 for more details. - def self.bulk_perform_inline(args_list) - end - def perform(count = 0) self.class.counter += count end @@ -37,27 +31,6 @@ RSpec.describe WaitableWorker do worker.bulk_perform_and_wait(arguments) end - - context 'when the feature flag `always_async_project_authorizations_refresh` is turned off' do - before do - stub_feature_flags(always_async_project_authorizations_refresh: false) - end - - it 'inlines the job' do - args_list = [[1]] - expect(worker).to receive(:bulk_perform_inline).with(args_list).and_call_original - expect(Gitlab::AppJsonLogger).to( - receive(:info).with(a_hash_including('message' => 'running inline', - 'class' => 'Gitlab::Foo::Bar::DummyWorker', - 'job_status' => 'running', - 'queue' => 'foo_bar_dummy')) - .once) - - worker.bulk_perform_and_wait(args_list) - - expect(worker.counter).to eq(1) - end - end end context 'between 2 and 3 jobs' do @@ -81,22 +54,6 @@ RSpec.describe WaitableWorker do end end - describe '.bulk_perform_inline' do - it 'runs the jobs inline' do - expect(worker).not_to receive(:bulk_perform_async) - - worker.bulk_perform_inline([[1], [2]]) - - expect(worker.counter).to eq(3) - end - - it 'enqueues jobs if an error is raised' do - expect(worker).to receive(:bulk_perform_async).with([['foo']]) - - worker.bulk_perform_inline([[1], ['foo']]) - end - end - describe '#perform' do shared_examples 'perform' do it 'notifies the JobWaiter when done if the key is provided' do |