Working on issue #981 - Fixed bug: LDAP integration admin interface shows error if functionality is enabled but not configured yet.

This commit is contained in:
Thorsten Eckel 2017-05-10 09:51:19 +02:00
parent 6c2ae15c8d
commit bb230519be
2 changed files with 17 additions and 9 deletions

View file

@ -6,8 +6,9 @@ require 'ldap/group'
module Import
class Ldap < Import::Base
# Checks if the integration is activated. Otherwise it won't get queued
# since it will display an error which is confusing and wrong.
# Checks if the integration is activated and configured.
# Otherwise it won't get queued since it will display
# an error which is confusing and wrong.
#
# @example
# Import::LDAP.queueable?
@ -15,7 +16,7 @@ module Import
#
# return [Boolean]
def self.queueable?
Setting.get('ldap_integration')
Setting.get('ldap_integration') && Setting.get('ldap_config').present?
end
# Starts a live or dry run LDAP import.

View file

@ -6,13 +6,21 @@ RSpec.describe Import::Ldap do
describe '#queueable?' do
it 'is queueable if ldap integration is activated' do
expect(Setting).to receive(:get).with('ldap_integration').and_return(true)
it 'is queueable if LDAP integration is activated and configured' do
allow(Setting).to receive(:get).with('ldap_integration').and_return(true)
allow(Setting).to receive(:get).with('ldap_config').and_return({ host: 'some' })
expect(described_class.queueable?).to be true
end
it "isn't queueable if ldap integration is deactivated" do
expect(Setting).to receive(:get).with('ldap_integration').and_return(false)
it "isn't queueable if LDAP integration is deactivated" do
allow(Setting).to receive(:get).with('ldap_integration').and_return(false)
allow(Setting).to receive(:get).with('ldap_config').and_return({ host: 'some' })
expect(described_class.queueable?).to be false
end
it "isn't queueable if LDAP configuration is missing" do
allow(Setting).to receive(:get).with('ldap_integration').and_return(true)
allow(Setting).to receive(:get).with('ldap_config').and_return({})
expect(described_class.queueable?).to be false
end
end
@ -20,11 +28,10 @@ RSpec.describe Import::Ldap do
describe '.start' do
it 'starts LDAP import resource factories' do
import_job = create(:import_job)
instance = described_class.new(import_job)
expect(Setting).to receive(:get).with('ldap_integration').and_return(true)
allow(Setting).to receive(:get).with('ldap_integration').and_return(true)
expect(Import::Ldap::UserFactory).to receive(:import)
instance.start