diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 12:09:17 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 12:09:17 +0000 |
commit | cd52759ee33051b8ad7b88b02ba7954e4fad7018 (patch) | |
tree | f1096c68e457aef7f5201acd16e4a751ff538026 /spec/migrations | |
parent | 18f7828977b74bf6e5153594a098ef90e773b3b7 (diff) | |
download | gitlab-ce-cd52759ee33051b8ad7b88b02ba7954e4fad7018.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/migrate_merge_request_mentions_to_db_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/migrations/migrate_merge_request_mentions_to_db_spec.rb b/spec/migrations/migrate_merge_request_mentions_to_db_spec.rb new file mode 100644 index 00000000000..aef8fd6490b --- /dev/null +++ b/spec/migrations/migrate_merge_request_mentions_to_db_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20200211155539_migrate_merge_request_mentions_to_db') + +describe MigrateMergeRequestMentionsToDb, :migration do + let(:users) { table(:users) } + let(:projects) { table(:projects) } + let(:namespaces) { table(:namespaces) } + let(:merge_requests) { table(:merge_requests) } + let(:merge_request_user_mentions) { table(:merge_request_user_mentions) } + + 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(:project) { projects.create!(name: 'gitlab1', path: 'gitlab1', namespace_id: group.id, visibility_level: 0) } + + # migrateable resources + let(:common_args) { { source_branch: 'master', source_project_id: project.id, target_project_id: project.id, author_id: user.id, description: 'mr description with @root mention' } } + let!(:resource1) { merge_requests.create!(common_args.merge(title: "title 1", state_id: 1, target_branch: 'feature1')) } + let!(:resource2) { merge_requests.create!(common_args.merge(title: "title 2", state_id: 1, target_branch: 'feature2')) } + let!(:resource3) { merge_requests.create!(common_args.merge(title: "title 3", state_id: 1, target_branch: 'feature3')) } + + # non-migrateable resources + # this merge request is already migrated, as it has a record in the merge_request_user_mentions table + let!(:resource4) { merge_requests.create!(common_args.merge(title: "title 3", state_id: 1, target_branch: 'feature3')) } + let!(:user_mention) { merge_request_user_mentions.create!(merge_request_id: resource4.id, mentioned_users_ids: [1]) } + + let!(:resource5) { merge_requests.create!(common_args.merge(title: "title 3", description: 'description with no mention', state_id: 1, target_branch: 'feature3')) } + + it_behaves_like 'schedules resource mentions migration', MergeRequest, false +end |