trabajo-afectivo/spec/db/migrate/set_user_source_ldap_from_external_sync_spec.rb

31 lines
933 B
Ruby

# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
require 'rails_helper'
RSpec.describe SetUserSourceLdapFromExternalSync, type: :db_migration, db_strategy: :reset do
let(:users) { create_list(:user, 2) }
let(:other_user) { create(:user) }
before do
2.times do |count|
index = count - 1
create(:external_sync,
source: 'Ldap::User',
source_id: "uid=#{users[index].login},ou=People,dc=example,dc=org",
object: 'User',
o_id: users[index].id)
end
end
context 'when having users from the ldap integration' do
it 'source key for users are filled' do
expect { migrate }.to change { users[0].reload.source }.to('Ldap').and change { users[1].reload.source }.to('Ldap')
end
it 'other user should not be touched' do
expect { migrate }.not_to change { other_user.reload.source }
end
end
end