diff --git a/CHANGELOG b/CHANGELOG index b0d86e4acad730196e7edabababd43f5f2cb6492..23f2cd1d1c8f4f77391d0169f0ca8ea44df88890 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 3f76ec979778e142e8cc6bc12a45e90a144c34f9..e6d31ea04c031d5c9897b90b32865a58032dc921 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 0000000000000000000000000000000000000000..d3f1deb383765b221f5f5faaeb60a23d1d5d052e --- /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