Commit 1e7a034e authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '21801-migrate-epic-mentions-to-db-table-spec-fix' into 'master'

Fix spec so that it does not depend on spec order

See merge request gitlab-org/gitlab!23949
parents 02b721b2 16b3c49b
......@@ -8,14 +8,14 @@ describe MigrateEpicMentionsToDb, :migration, :sidekiq do
let(:namespaces) { table(:namespaces) }
let(:epics) { table(:epics) }
let(:user) { users.create!(name: 'root', email: 'root@example.com', username: 'root', projects_limit: 0) }
let(:group) { namespaces.create!(name: 'group1', path: 'group1', owner_id: user.id, type: 'Group') }
let!(:epic1) { epics.create!(iid: 1, title: "title1", title_html: 'title1', description: 'epic description with @root mention', group_id: group.id, author_id: user.id) }
let!(:epic2) { epics.create!(iid: 2, title: "title2", title_html: 'title2', description: 'epic description with @root mention', group_id: group.id, author_id: user.id) }
let!(:epic3) { epics.create!(iid: 3, title: "title3", title_html: 'title3', description: 'epic description with @root mention', group_id: group.id, author_id: user.id) }
before do
stub_const("#{described_class.name}::BATCH_SIZE", 1)
users.create!(id: 1, name: 'root', email: 'root@example.com', username: 'root', projects_limit: 0)
namespaces.create!(id: 1, name: 'group1', path: 'group1', owner_id: 1)
epics.create!(id: 1, iid: 1, title: "title1", title_html: 'title1', description: 'epic description with @root mention', group_id: 1, author_id: 1)
epics.create!(id: 2, iid: 2, title: "title2", title_html: "title2", description: 'epic description with @group mention', group_id: 1, author_id: 1)
epics.create!(id: 3, iid: 3, title: "title3", title_html: "title3", description: 'epic description with @project mention', group_id: 1, author_id: 1)
end
it 'schedules epic mentions migrations' do
......@@ -27,9 +27,9 @@ describe MigrateEpicMentionsToDb, :migration, :sidekiq do
join = described_class::JOIN
conditions = described_class::QUERY_CONDITIONS
expect(migration).to be_scheduled_delayed_migration(2.minutes, 'Epic', join, conditions, false, 1, 1)
expect(migration).to be_scheduled_delayed_migration(4.minutes, 'Epic', join, conditions, false, 2, 2)
expect(migration).to be_scheduled_delayed_migration(6.minutes, 'Epic', join, conditions, false, 3, 3)
expect(migration).to be_scheduled_delayed_migration(2.minutes, 'Epic', join, conditions, false, epic1.id, epic1.id)
expect(migration).to be_scheduled_delayed_migration(4.minutes, 'Epic', join, conditions, false, epic2.id, epic2.id)
expect(migration).to be_scheduled_delayed_migration(6.minutes, 'Epic', join, conditions, false, epic3.id, epic3.id)
expect(BackgroundMigrationWorker.jobs.size).to eq 3
end
end
......
......@@ -9,16 +9,15 @@ describe MigrateEpicNotesMentionsToDb, :migration, :sidekiq do
let(:epics) { table(:epics) }
let(:notes) { table(:notes) }
let(:user) { users.create!(name: 'root', email: 'root@example.com', username: 'root', projects_limit: 0) }
let(:group) { namespaces.create!(name: 'group1', path: 'group1', owner_id: user.id, type: 'Group') }
let(:epic) { epics.create!(iid: 1, title: "title", title_html: 'title', description: 'epic description', group_id: group.id, author_id: user.id) }
let!(:note1) { notes.create!(note: 'note1 for @root to check', noteable_id: epic.id, noteable_type: 'Epic') }
let!(:note2) { notes.create!(note: 'note2 for @root to check', noteable_id: epic.id, noteable_type: 'Epic', system: true) }
let!(:note3) { notes.create!(note: 'note3 for @root to check', noteable_id: epic.id, noteable_type: 'Epic') }
before do
stub_const("#{described_class.name}::BATCH_SIZE", 1)
users.create!(id: 1, name: 'root', email: 'root@example.com', username: 'root', projects_limit: 0)
namespaces.create!(id: 1, name: 'group1', path: 'group1', owner_id: 1)
epics.create!(id: 1, iid: 1, title: "title", title_html: 'title', description: 'epic description', group_id: 1, author_id: 1)
notes.create!(note: 'note1 for @root to check', id: 1, noteable_id: 1, noteable_type: 'Epic')
notes.create!(note: 'note2 for @root to check', id: 2, noteable_id: 1, noteable_type: 'Epic', system: true)
notes.create!(note: 'note3 for @root to check', id: 3, noteable_id: 1, noteable_type: 'Epic')
end
it 'schedules epic mentions migrations' do
......@@ -30,9 +29,9 @@ describe MigrateEpicNotesMentionsToDb, :migration, :sidekiq do
join = described_class::JOIN
conditions = described_class::QUERY_CONDITIONS
expect(migration).to be_scheduled_delayed_migration(2.minutes, 'Epic', join, conditions, true, 1, 1)
expect(migration).to be_scheduled_delayed_migration(4.minutes, 'Epic', join, conditions, true, 2, 2)
expect(migration).to be_scheduled_delayed_migration(6.minutes, 'Epic', join, conditions, true, 3, 3)
expect(migration).to be_scheduled_delayed_migration(2.minutes, 'Epic', join, conditions, true, note1.id, note1.id)
expect(migration).to be_scheduled_delayed_migration(4.minutes, 'Epic', join, conditions, true, note2.id, note2.id)
expect(migration).to be_scheduled_delayed_migration(6.minutes, 'Epic', join, conditions, true, note3.id, note3.id)
expect(BackgroundMigrationWorker.jobs.size).to eq 3
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment