diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/services/users/destroy_service_spec.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/services/users/destroy_service_spec.rb')
-rw-r--r-- | spec/services/users/destroy_service_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/services/users/destroy_service_spec.rb b/spec/services/users/destroy_service_spec.rb index 602db66dba1..80a506bb1d6 100644 --- a/spec/services/users/destroy_service_spec.rb +++ b/spec/services/users/destroy_service_spec.rb @@ -332,4 +332,39 @@ RSpec.describe Users::DestroyService do expect(User.exists?(other_user.id)).to be(false) end end + + context 'batched nullify' do + let(:other_user) { create(:user) } + + context 'when :nullify_in_batches_on_user_deletion feature flag is enabled' do + it 'nullifies related associations in batches' do + expect(other_user).to receive(:nullify_dependent_associations_in_batches).and_call_original + + described_class.new(user).execute(other_user, skip_authorization: true) + end + + it 'nullifies last_updated_issues and closed_issues' do + issue = create(:issue, closed_by: other_user, updated_by: other_user) + + described_class.new(user).execute(other_user, skip_authorization: true) + + issue.reload + + expect(issue.closed_by).to be_nil + expect(issue.updated_by).to be_nil + end + end + + context 'when :nullify_in_batches_on_user_deletion feature flag is disabled' do + before do + stub_feature_flags(nullify_in_batches_on_user_deletion: false) + end + + it 'does not use batching' do + expect(other_user).not_to receive(:nullify_dependent_associations_in_batches) + + described_class.new(user).execute(other_user, skip_authorization: true) + end + end + end end |