issue_3141_multi_ldap_spec.rb 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Issue3141MultiLdap, type: :db_migration do
  4. let(:ldap_user) { create(:user, source: 'Ldap') }
  5. before do
  6. ldap_user
  7. Setting.create_or_update(
  8. title: __('LDAP config'),
  9. name: 'ldap_config',
  10. area: 'Integration::LDAP',
  11. description: __('Defines the LDAP config.'),
  12. options: {},
  13. state: { filled: true },
  14. preferences: {
  15. prio: 2,
  16. permission: ['admin.integration'],
  17. },
  18. frontend: false,
  19. )
  20. migrate do |migration|
  21. allow(migration).to receive(:add_table)
  22. end
  23. end
  24. it 'does create ldap source' do
  25. expect(LdapSource.first.preferences).to eq({ 'filled' => true })
  26. end
  27. it 'does remove the setting' do
  28. expect(Setting.find_by(name: 'ldap_config')).to be_nil
  29. end
  30. it 'does migrate source of all users' do
  31. expect(ldap_user.reload.source).to eq("Ldap::#{LdapSource.first.id}")
  32. end
  33. end