ldap_spec.rb 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. require 'lib/import/import_job_backend_examples'
  4. RSpec.describe Import::Ldap, sequencer: :caller do
  5. it_behaves_like 'ImportJob backend'
  6. describe '#start' do
  7. it 'starts LDAP import resource factories' do
  8. import_job = create(:import_job)
  9. instance = described_class.new(import_job)
  10. allow(Setting).to receive(:get).with('ldap_integration').and_return(true)
  11. expect_sequence
  12. instance.start
  13. end
  14. context 'requirements' do
  15. it 'lets dry runs always start' do
  16. import_job = create(:import_job, dry_run: true)
  17. instance = described_class.new(import_job)
  18. expect_sequence
  19. instance.start
  20. end
  21. it 'informs about deactivated ldap_integration' do
  22. import_job = create(:import_job)
  23. instance = described_class.new(import_job)
  24. allow(Setting).to receive(:get).with('ldap_integration').and_return(false)
  25. expect_no_sequence
  26. expect do
  27. instance.start
  28. import_job.reload
  29. end.to change {
  30. import_job.result
  31. }
  32. expect(import_job.result.key?(:info)).to be true
  33. end
  34. end
  35. end
  36. describe '#reschedule?' do
  37. it 'initiates always a rescheduling' do
  38. import_job = create(:import_job)
  39. instance = described_class.new(import_job)
  40. delayed_job = double
  41. expect(instance.reschedule?(delayed_job)).to be true
  42. end
  43. it 'updates the result with an info text' do
  44. import_job = create(:import_job)
  45. instance = described_class.new(import_job)
  46. delayed_job = double
  47. expect do
  48. instance.reschedule?(delayed_job)
  49. end.to change {
  50. import_job.result
  51. }
  52. expect(import_job.result.key?(:info)).to be true
  53. end
  54. end
  55. end