diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-07-13 18:05:57 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-07-13 18:05:57 +0000 |
commit | d2c9e8ab6e696f9b2dd3abcddd7cb526e8057a14 (patch) | |
tree | 211a29d09b441463a4a794e162a56830be0892cf | |
parent | 4be505bfd177755103d74ca4874086853a32449a (diff) | |
parent | 6d5fd7d9b71b975be937671f2ca4dd7b3b57f8b2 (diff) | |
download | gitlab-ce-d2c9e8ab6e696f9b2dd3abcddd7cb526e8057a14.tar.gz |
Merge branch 'gl-importer-keeps-issue-number' into 'master'
Keeps issue number when importing from Gitlab.com
## What does this MR do?
Keeps issue number when importing from `Gitlab.com`
## Are there points in the code the reviewer needs to double check?
No.
## Why was this MR needed?
With these changes we doesn't loose the issue references when importing from `GitLab.com`.
## What are the relevant issue numbers?
Closes #15235
/cc @cpm @jweerdt
See merge request !5193
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | lib/gitlab/gitlab_import/importer.rb | 1 | ||||
-rw-r--r-- | spec/lib/gitlab/gitlab_import/importer_spec.rb | 53 |
3 files changed, 55 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG index b0d86e4acad..23f2cd1d1c8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -95,6 +95,7 @@ v 8.9.6 - Fix commit avatar alignment in compare view. !5128 - Fix broken migration in MySQL. !5005 - Overwrite Host and X-Forwarded-Host headers in NGINX !5213 + - Keeps issue number when importing from Gitlab.com v 8.9.6 (unreleased) - Fix importing of events under notes for GitLab projects diff --git a/lib/gitlab/gitlab_import/importer.rb b/lib/gitlab/gitlab_import/importer.rb index 3f76ec97977..e6d31ea04c0 100644 --- a/lib/gitlab/gitlab_import/importer.rb +++ b/lib/gitlab/gitlab_import/importer.rb @@ -35,6 +35,7 @@ module Gitlab end project.issues.create!( + iid: issue["iid"], description: body, title: issue["title"], state: issue["state"], diff --git a/spec/lib/gitlab/gitlab_import/importer_spec.rb b/spec/lib/gitlab/gitlab_import/importer_spec.rb new file mode 100644 index 00000000000..d3f1deb3837 --- /dev/null +++ b/spec/lib/gitlab/gitlab_import/importer_spec.rb @@ -0,0 +1,53 @@ +require 'spec_helper' + +describe Gitlab::GitlabImport::Importer, lib: true do + include ImportSpecHelper + + describe '#execute' do + before do + stub_omniauth_provider('gitlab') + stub_request('issues', [ + { + 'id' => 2579857, + 'iid' => 3, + 'title' => 'Issue', + 'description' => 'Lorem ipsum', + 'state' => 'opened', + 'author' => { + 'id' => 283999, + 'name' => 'John Doe' + } + } + ]) + stub_request('issues/2579857/notes', []) + end + + it 'persists issues' do + project = create(:empty_project, import_source: 'asd/vim') + project.build_import_data(credentials: { password: 'password' }) + + subject = described_class.new(project) + subject.execute + + expected_attributes = { + iid: 3, + title: 'Issue', + description: "*Created by: John Doe*\n\nLorem ipsum", + state: 'opened', + author_id: project.creator_id + } + + expect(project.issues.first).to have_attributes(expected_attributes) + end + + def stub_request(path, body) + url = "https://gitlab.com/api/v3/projects/asd%2Fvim/#{path}?page=1&per_page=100" + + WebMock.stub_request(:get, url). + to_return( + headers: { 'Content-Type' => 'application/json' }, + body: body + ) + end + end +end |