Refactoring - DRYing up code. Use existing .backends method.

This commit is contained in:
Thorsten Eckel 2018-05-11 10:47:20 +02:00
parent 3034ff7e97
commit 163a5f2f26
2 changed files with 2 additions and 10 deletions

View file

@ -109,15 +109,7 @@ class ImportJob < ApplicationModel
# #
# return [nil] # return [nil]
def self.queue_registered def self.queue_registered
import_backends = Setting.get('import_backends') backends.each do |backend|
return if import_backends.blank?
import_backends.each do |backend|
if !backend_valid?(backend)
Rails.logger.error "Invalid import backend '#{backend}'"
next
end
# skip backends that are not "ready" yet # skip backends that are not "ready" yet
next if !backend.constantize.queueable? next if !backend.constantize.queueable?

View file

@ -120,7 +120,7 @@ RSpec.describe ImportJob do
it 'logs errors for invalid registered backends' do it 'logs errors for invalid registered backends' do
allow(Setting).to receive(:get) allow(Setting).to receive(:get)
expect(Setting).to receive(:get).with('import_backends').and_return(['InvalidBackend']) 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 described_class.queue_registered
end end