diff options
Diffstat (limited to 'spec/lib/gitlab/background_migration/migrate_promoted_epics_discussion_ids_spec.rb')
-rw-r--r-- | spec/lib/gitlab/background_migration/migrate_promoted_epics_discussion_ids_spec.rb | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/spec/lib/gitlab/background_migration/migrate_promoted_epics_discussion_ids_spec.rb b/spec/lib/gitlab/background_migration/migrate_promoted_epics_discussion_ids_spec.rb deleted file mode 100644 index 16ca0e96ac6..00000000000 --- a/spec/lib/gitlab/background_migration/migrate_promoted_epics_discussion_ids_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -describe Gitlab::BackgroundMigration::FixPromotedEpicsDiscussionIds, :migration, schema: 20190715193142 do - let(:namespaces) { table(:namespaces) } - let(:projects) { table(:projects) } - let(:users) { table(:users) } - let(:issues) { table(:issues) } - let(:epics) { table(:epics) } - let(:notes) { table(:notes) } - - let(:user) { users.create!(email: 'test@example.com', projects_limit: 100, username: 'test') } - let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') } - let(:project) { projects.create(namespace_id: namespace.id, name: 'foo') } - let(:issue) { issues.create(project_id: project.id, title: 'Issue with discussion') } - let!(:issue_note) { notes.create(project_id: project.id, note: 'note comment', noteable_id: issue.id, noteable_type: 'Issue', discussion_id: 'd1') } - - describe '#perform with batch of discussion ids' do - let(:epic1) { epics.create(id: 1, author_id: user.id, iid: 1, group_id: namespace.id, title: 'Epic with discussion', title_html: 'Epic with discussion') } - let!(:epic1_note1) { notes.create(note: 'note comment', noteable_id: epic1.id, noteable_type: 'Epic', discussion_id: 'd1') } - let!(:epic1_note2) { notes.create(system: true, note: 'promoted from issue XXX', noteable_id: epic1.id, noteable_type: 'Epic', discussion_id: 'system1') } - - let(:epic2) { epics.create(id: 2, author_id: user.id, iid: 2, group_id: namespace.id, title: 'Epic with discussion', title_html: 'Epic with discussion') } - let!(:epic2_note1) { notes.create(note: 'note comment', noteable_id: epic2.id, noteable_type: 'Epic', discussion_id: 'd2') } - let!(:epic2_note2) { notes.create(system: true, note: 'promoted from issue YYY', noteable_id: epic2.id, noteable_type: 'Epic', discussion_id: 'system2') } - - it 'executes perform and changes discussion ids on all promoted epic discussions' do - expect(notes.where(discussion_id: 'd1').count).to eq(2) - - subject.perform(%w(d1 system1 d2 system2)) - - old_discussion_notes = notes.where(discussion_id: 'd1') - expect(old_discussion_notes.count).to eq(1) - expect(old_discussion_notes.first.noteable_type).to eq('Issue') - expect(epic1_note1.reload.discussion_id).not_to eq('d1') - expect(epic1_note2.reload.discussion_id).not_to eq('system1') - expect(epic2_note1.reload.discussion_id).not_to eq('d2') - expect(epic2_note2.reload.discussion_id).not_to eq('system2') - end - - it 'sets same new discussion id for all notes with the same old discussion id' do - note = notes.create(note: 'note comment', noteable_id: epic2.id, noteable_type: 'Epic', discussion_id: 'd2') - expect(notes.where(discussion_id: note.discussion_id).count).to eq(2) - - subject.perform(['d2']) - - expect(note.reload.discussion_id).not_to eq('d2') - expect(notes.where(discussion_id: note.discussion_id).count).to eq(2) - end - end -end |