set_user_source_ldap_from_external_sync_spec.rb 939 B

123456789101112131415161718192021222324252627282930
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe SetUserSourceLdapFromExternalSync, db_strategy: :reset, type: :db_migration do
  4. let(:users) { create_list(:user, 2) }
  5. let(:other_user) { create(:user) }
  6. before do
  7. 2.times do |count|
  8. index = count - 1
  9. create(:external_sync,
  10. source: 'Ldap::User',
  11. source_id: "uid=#{users[index].login},ou=People,dc=example,dc=org",
  12. object: 'User',
  13. o_id: users[index].id)
  14. end
  15. end
  16. context 'when having users from the ldap integration' do
  17. it 'source key for users are filled' do
  18. expect { migrate }.to change { users[0].reload.source }.to('Ldap').and change { users[1].reload.source }.to('Ldap')
  19. end
  20. it 'other user should not be touched' do
  21. expect { migrate }.not_to change { other_user.reload.source }
  22. end
  23. end
  24. end