2017-05-05 08:58:05 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
require 'lib/import/import_job_backend_examples'
|
|
|
|
|
|
|
|
RSpec.describe Import::Ldap do
|
|
|
|
it_behaves_like 'ImportJob backend'
|
|
|
|
|
|
|
|
describe '#queueable?' do
|
|
|
|
|
2017-05-10 07:51:19 +00:00
|
|
|
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' })
|
2017-05-05 08:58:05 +00:00
|
|
|
expect(described_class.queueable?).to be true
|
|
|
|
end
|
|
|
|
|
2017-05-10 07:51:19 +00:00
|
|
|
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({})
|
2017-05-05 08:58:05 +00:00
|
|
|
expect(described_class.queueable?).to be false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.start' do
|
|
|
|
|
|
|
|
it 'starts LDAP import resource factories' do
|
|
|
|
import_job = create(:import_job)
|
|
|
|
instance = described_class.new(import_job)
|
|
|
|
|
2017-05-10 07:51:19 +00:00
|
|
|
allow(Setting).to receive(:get).with('ldap_integration').and_return(true)
|
2017-05-05 08:58:05 +00:00
|
|
|
expect(Import::Ldap::UserFactory).to receive(:import)
|
|
|
|
|
|
|
|
instance.start
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|