summaryrefslogtreecommitdiff
path: root/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_mr_spec.rb
blob: d656ea4dea59fea6cd5dc9755f1f312bff73aa14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# frozen_string_literal: true

require_relative 'gitlab_project_migration_common'

module QA
  RSpec.describe 'Manage' do
    describe 'Gitlab migration' do
      include_context 'with gitlab project migration'

      context 'with merge request' do
        let!(:source_project_with_readme) { true }

        let!(:other_user) do
          Resource::User
            .fabricate_via_api! { |usr| usr.api_client = admin_api_client }
            .tap do |usr|
              usr.set_public_email
              source_project.add_member(usr, Resource::Members::AccessLevel::MAINTAINER)
            end
        end

        let!(:source_mr) do
          Resource::MergeRequest.fabricate_via_api! do |mr|
            mr.project = source_project
            mr.api_client = Runtime::API::Client.new(user: other_user)
          end
        end

        let!(:source_comment) { source_mr.add_comment('This is a test comment!') }

        let(:imported_mrs) { imported_project.merge_requests }
        let(:imported_mr_comments) { imported_mr.comments.map { |note| note.except(:id, :noteable_id) } }
        let(:source_mr_comments) { source_mr.comments.map { |note| note.except(:id, :noteable_id) } }

        let(:imported_mr) do
          Resource::MergeRequest.init do |mr|
            mr.project = imported_project
            mr.iid = imported_mrs.first[:iid]
            mr.api_client = api_client
          end
        end

        after do
          other_user.remove_via_api!
        end

        it(
          'successfully imports merge request',
          testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348478'
        ) do
          expect_import_finished
          expect(imported_mrs.count).to eq(1)

          aggregate_failures do
            expect(imported_mr).to eq(source_mr.reload!)

            expect(imported_mr_comments).to eq(source_mr_comments)
          end
        end
      end
    end
  end
end