summaryrefslogtreecommitdiff
path: root/spec/migrations/remove_wiki_notes_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
commit3cccd102ba543e02725d247893729e5c73b38295 (patch)
treef36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/migrations/remove_wiki_notes_spec.rb
parent205943281328046ef7b4528031b90fbda70c75ac (diff)
downloadgitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/migrations/remove_wiki_notes_spec.rb')
-rw-r--r--spec/migrations/remove_wiki_notes_spec.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/migrations/remove_wiki_notes_spec.rb b/spec/migrations/remove_wiki_notes_spec.rb
new file mode 100644
index 00000000000..2ffebdee106
--- /dev/null
+++ b/spec/migrations/remove_wiki_notes_spec.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require_migration!
+
+RSpec.describe RemoveWikiNotes, :migration do
+ let(:notes) { table(:notes) }
+
+ it 'removes all wiki notes' do
+ notes.create!(id: 97, note: 'Wiki note', noteable_type: 'Wiki')
+ notes.create!(id: 98, note: 'Commit note', noteable_type: 'Commit')
+ notes.create!(id: 110, note: 'Issue note', noteable_type: 'Issue')
+ notes.create!(id: 242, note: 'MergeRequest note', noteable_type: 'MergeRequest')
+
+ expect(notes.where(noteable_type: 'Wiki').size).to eq(1)
+
+ expect { migrate! }.to change { notes.count }.by(-1)
+
+ expect(notes.where(noteable_type: 'Wiki').size).to eq(0)
+ end
+
+ context 'when not staging nor com' do
+ it 'does not remove notes' do
+ allow(::Gitlab).to receive(:com?).and_return(false)
+ allow(::Gitlab).to receive(:dev_or_test_env?).and_return(false)
+ allow(::Gitlab).to receive(:staging?).and_return(false)
+
+ notes.create!(id: 97, note: 'Wiki note', noteable_type: 'Wiki')
+
+ expect { migrate! }.not_to change { notes.count }
+ end
+ end
+end