diff options
Diffstat (limited to 'spec/lib/gitlab/github_import')
-rw-r--r-- | spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb | 38 | ||||
-rw-r--r-- | spec/lib/gitlab/github_import/representation/pull_request_spec.rb | 2 |
2 files changed, 37 insertions, 3 deletions
diff --git a/spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb b/spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb index 0f21b8843b6..15e59718dce 100644 --- a/spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb +++ b/spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb @@ -89,7 +89,7 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi description: 'This is my pull request', source_project_id: project.id, target_project_id: project.id, - source_branch: 'alice:feature', + source_branch: 'github/fork/alice/feature', target_branch: 'master', state: :merged, milestone_id: milestone.id, @@ -134,7 +134,7 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi description: "*Created by: alice*\n\nThis is my pull request", source_project_id: project.id, target_project_id: project.id, - source_branch: 'alice:feature', + source_branch: 'github/fork/alice/feature', target_branch: 'master', state: :merged, milestone_id: milestone.id, @@ -259,6 +259,40 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi .and_return(user.id) end + it 'does not create the source branch if merge request is merged' do + mr, exists = importer.create_merge_request + + importer.insert_git_data(mr, exists) + + expect(project.repository.branch_exists?(mr.source_branch)).to be_falsey + expect(project.repository.branch_exists?(mr.target_branch)).to be_truthy + end + + it 'creates the source branch if merge request is open' do + mr, exists = importer.create_merge_request + mr.state = 'opened' + mr.save + + importer.insert_git_data(mr, exists) + + expect(project.repository.branch_exists?(mr.source_branch)).to be_truthy + expect(project.repository.branch_exists?(mr.target_branch)).to be_truthy + end + + it 'ignores Git errors when creating a branch' do + mr, exists = importer.create_merge_request + mr.state = 'opened' + mr.save + + expect(project.repository).to receive(:add_branch).and_raise(Gitlab::Git::CommandError) + expect(Gitlab::Sentry).to receive(:track_acceptable_exception).and_call_original + + importer.insert_git_data(mr, exists) + + expect(project.repository.branch_exists?(mr.source_branch)).to be_falsey + expect(project.repository.branch_exists?(mr.target_branch)).to be_truthy + end + it 'creates the merge request diffs' do mr, exists = importer.create_merge_request diff --git a/spec/lib/gitlab/github_import/representation/pull_request_spec.rb b/spec/lib/gitlab/github_import/representation/pull_request_spec.rb index 33f6ff0ae6a..d478e5ae899 100644 --- a/spec/lib/gitlab/github_import/representation/pull_request_spec.rb +++ b/spec/lib/gitlab/github_import/representation/pull_request_spec.rb @@ -238,7 +238,7 @@ describe Gitlab::GithubImport::Representation::PullRequest do target_repository_id: 2 ) - expect(pr.formatted_source_branch).to eq('foo:branch') + expect(pr.formatted_source_branch).to eq('github/fork/foo/branch') end end |