diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2019-08-01 22:15:34 +0200 |
---|---|---|
committer | Alexandru Croitor <acroitor@gitlab.com> | 2019-09-10 11:00:38 +0300 |
commit | 109fe4f1be58c90625ce358660d5927e8b9e6f0b (patch) | |
tree | 4aa8fdd4f87d26178e53d9cc345b08723ea155b2 | |
parent | 5c75af4bee0b9bafc9eb253fdc48a28b7c0765d5 (diff) | |
download | gitlab-ce-109fe4f1be58c90625ce358660d5927e8b9e6f0b.tar.gz |
Minor stylistic improvements
4 files changed, 13 insertions, 8 deletions
diff --git a/db/post_migrate/20190715193142_migrate_discussion_id_on_promoted_epics.rb b/db/post_migrate/20190715193142_migrate_discussion_id_on_promoted_epics.rb index efafcee4723..b351d10e7a7 100644 --- a/db/post_migrate/20190715193142_migrate_discussion_id_on_promoted_epics.rb +++ b/db/post_migrate/20190715193142_migrate_discussion_id_on_promoted_epics.rb @@ -6,8 +6,10 @@ class MigrateDiscussionIdOnPromotedEpics < ActiveRecord::Migration[5.2] include Gitlab::Database::MigrationHelpers + # We have ~5000 unique discussion_ids -> this migration will take about 12 + # minutes (5000/1000 * 2 minutes + 2 minutes initial delay) on gitlab.com. DOWNTIME = false - BATCH_SIZE = 1000 + BATCH_SIZE = 1_000 DELAY_INTERVAL = 2.minutes MIGRATION = 'FixPromotedEpicsDiscussionIds' diff --git a/lib/gitlab/background_migration/fix_promoted_epics_discussion_ids.rb b/lib/gitlab/background_migration/fix_promoted_epics_discussion_ids.rb index 77c317741e9..9c3bb7c889b 100644 --- a/lib/gitlab/background_migration/fix_promoted_epics_discussion_ids.rb +++ b/lib/gitlab/background_migration/fix_promoted_epics_discussion_ids.rb @@ -3,7 +3,7 @@ module Gitlab module BackgroundMigration # This migration updates discussion ids for epics that were promoted from issue so that the discussion id on epics - # is different from discussion id on issue, which was causing problems when repying to epic discussions as it would + # is different from discussion id on issue, which was causing problems when replying to epic discussions as it would # identify the discussion as related to an issue and complaint about missing project_id class FixPromotedEpicsDiscussionIds # notes model to iterate through the notes to be updated diff --git a/spec/lib/gitlab/background_migration/fix_promoted_epics_discussion_ids_spec.rb b/spec/lib/gitlab/background_migration/fix_promoted_epics_discussion_ids_spec.rb index de25ca192af..155704746b3 100644 --- a/spec/lib/gitlab/background_migration/fix_promoted_epics_discussion_ids_spec.rb +++ b/spec/lib/gitlab/background_migration/fix_promoted_epics_discussion_ids_spec.rb @@ -9,15 +9,18 @@ describe Gitlab::BackgroundMigration::FixPromotedEpicsDiscussionIds, :migration, 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(: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(:namespace) { namespaces.create!(name: 'gitlab', path: 'gitlab-org') } + 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') } def create_note(discussion_id) - notes.create(note: 'note comment', noteable_id: epic1.id, noteable_type: 'Epic', discussion_id: discussion_id) + notes.create!(note: 'note comment', + noteable_id: epic1.id, + noteable_type: 'Epic', + discussion_id: discussion_id) end def expect_valid_discussion_id(id) - expect(id).to match(/[0-9a-f]{40}/) + expect(id).to match(/\A\h{40}\z/) end describe '#perform with batch of discussion ids' do diff --git a/spec/migrations/migrate_discussion_id_on_promoted_epics_spec.rb b/spec/migrations/migrate_discussion_id_on_promoted_epics_spec.rb index 57c4bd16f2e..5375a53d9ef 100644 --- a/spec/migrations/migrate_discussion_id_on_promoted_epics_spec.rb +++ b/spec/migrations/migrate_discussion_id_on_promoted_epics_spec.rb @@ -16,7 +16,7 @@ describe MigrateDiscussionIdOnPromotedEpics, :migration, :sidekiq do let(:system_note_metadata) { table(:system_note_metadata) } let(:user) { users.create!(email: 'test@example.com', projects_limit: 100, username: 'test') } - let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') } + let(:namespace) { namespaces.create!(name: 'gitlab', path: 'gitlab-org') } def create_promotion_note(model, id) note = notes.create!(system: true, note: 'promoted from issue XXX', @@ -60,7 +60,7 @@ describe MigrateDiscussionIdOnPromotedEpics, :migration, :sidekiq do end it 'schedules only promoted epics' do - issue = issues.create(description: 'first', state: 'opened') + issue = issues.create!(description: 'first', state: 'opened') create_promotion_note(issue, 'id2') create_note(create_epic, 'id3') |