Commit d2c9e8ab authored by Douwe Maan's avatar Douwe Maan

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
parents 4be505bf 6d5fd7d9
...@@ -95,6 +95,7 @@ v 8.9.6 ...@@ -95,6 +95,7 @@ v 8.9.6
- Fix commit avatar alignment in compare view. !5128 - Fix commit avatar alignment in compare view. !5128
- Fix broken migration in MySQL. !5005 - Fix broken migration in MySQL. !5005
- Overwrite Host and X-Forwarded-Host headers in NGINX !5213 - Overwrite Host and X-Forwarded-Host headers in NGINX !5213
- Keeps issue number when importing from Gitlab.com
v 8.9.6 (unreleased) v 8.9.6 (unreleased)
- Fix importing of events under notes for GitLab projects - Fix importing of events under notes for GitLab projects
......
...@@ -35,6 +35,7 @@ module Gitlab ...@@ -35,6 +35,7 @@ module Gitlab
end end
project.issues.create!( project.issues.create!(
iid: issue["iid"],
description: body, description: body,
title: issue["title"], title: issue["title"],
state: issue["state"], state: issue["state"],
......
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment