From 163a5f2f2613cf106966002ffc18e6da1cc2c514 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Fri, 11 May 2018 10:47:20 +0200 Subject: [PATCH] Refactoring - DRYing up code. Use existing `.backends` method. --- app/models/import_job.rb | 10 +--------- spec/models/import_job_spec.rb | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/app/models/import_job.rb b/app/models/import_job.rb index 16bae41c4..335fd2a06 100644 --- a/app/models/import_job.rb +++ b/app/models/import_job.rb @@ -109,15 +109,7 @@ class ImportJob < ApplicationModel # # return [nil] def self.queue_registered - import_backends = Setting.get('import_backends') - return if import_backends.blank? - - import_backends.each do |backend| - - if !backend_valid?(backend) - Rails.logger.error "Invalid import backend '#{backend}'" - next - end + backends.each do |backend| # skip backends that are not "ready" yet next if !backend.constantize.queueable? diff --git a/spec/models/import_job_spec.rb b/spec/models/import_job_spec.rb index 0f5f88f34..a99d029a4 100644 --- a/spec/models/import_job_spec.rb +++ b/spec/models/import_job_spec.rb @@ -120,7 +120,7 @@ RSpec.describe ImportJob do it 'logs errors for invalid registered backends' do allow(Setting).to receive(:get) expect(Setting).to receive(:get).with('import_backends').and_return(['InvalidBackend']) - expect(Rails.logger).to receive(:error) + expect(described_class.logger).to receive(:error) described_class.queue_registered end