diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /spec/migrations/20220913030624_cleanup_attention_request_related_system_notes_spec.rb | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'spec/migrations/20220913030624_cleanup_attention_request_related_system_notes_spec.rb')
-rw-r--r-- | spec/migrations/20220913030624_cleanup_attention_request_related_system_notes_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/migrations/20220913030624_cleanup_attention_request_related_system_notes_spec.rb b/spec/migrations/20220913030624_cleanup_attention_request_related_system_notes_spec.rb new file mode 100644 index 00000000000..7338a6ab9ae --- /dev/null +++ b/spec/migrations/20220913030624_cleanup_attention_request_related_system_notes_spec.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_migration! + +RSpec.describe CleanupAttentionRequestRelatedSystemNotes, :migration do + let(:notes) { table(:notes) } + let(:system_note_metadata) { table(:system_note_metadata) } + + it 'removes all notes with attention request related system_note_metadata' do + notes.create!(id: 1, note: 'Attention request note', noteable_type: 'MergeRequest') + notes.create!(id: 2, note: 'Attention request remove note', noteable_type: 'MergeRequest') + notes.create!(id: 3, note: 'MergeRequest note', noteable_type: 'MergeRequest') + notes.create!(id: 4, note: 'Commit note', noteable_type: 'Commit') + system_note_metadata.create!(id: 11, action: 'attention_requested', note_id: 1) + system_note_metadata.create!(id: 22, action: 'attention_request_removed', note_id: 2) + system_note_metadata.create!(id: 33, action: 'merged', note_id: 3) + + expect { migrate! }.to change(notes, :count).by(-2) + + expect(system_note_metadata.where(action: %w[attention_requested attention_request_removed]).size).to eq(0) + expect(notes.where(noteable_type: 'MergeRequest').size).to eq(1) + expect(notes.where(noteable_type: 'Commit').size).to eq(1) + expect(system_note_metadata.where(action: 'merged').size).to eq(1) + end +end |