configs_spec.rb 1.1 KB

123456789101112131415161718192021222324252627282930
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Sequencer::Unit::Import::Ldap::Sources::Configs, sequencer: :unit do
  4. let(:import_job) { build_stubbed(:import_job, name: 'Import::Ldap') }
  5. before do
  6. create(:ldap_source, preferences: { dummy: true })
  7. create(:ldap_source, active: false, preferences: { dummy: true })
  8. create(:ldap_source, preferences: { dummy: true })
  9. end
  10. it 'does include active ldap sources' do
  11. result = process(import_job: import_job, dry_run: false)
  12. expect(result[:configs].count).to eq(2)
  13. end
  14. it 'does include dry run config' do
  15. dry_config = { dry_run_config: true }
  16. result = process(import_job: import_job, dry_run: true, ldap_config: dry_config)
  17. expect(result[:configs].last).to eq(dry_config)
  18. end
  19. it 'does replace updated config' do
  20. dry_config = { dry_run_config: true, id: LdapSource.first.id }
  21. result = process(import_job: import_job, dry_run: true, ldap_config: dry_config)
  22. expect(result[:configs].first).to eq(dry_config)
  23. end
  24. end