Commit e0ef9dc8 authored by Valery Sizov's avatar Valery Sizov

BB importer: Milestone importer

parent ffa35233
...@@ -27,6 +27,10 @@ module Bitbucket ...@@ -27,6 +27,10 @@ module Bitbucket
raw['title'] raw['title']
end end
def milestone
raw.dig('milestone', 'name')
end
def created_at def created_at
raw['created_on'] raw['created_on']
end end
......
...@@ -67,6 +67,7 @@ module Gitlab ...@@ -67,6 +67,7 @@ module Gitlab
description += issue.description description += issue.description
label_name = issue.kind label_name = issue.kind
milestone = issue.milestone ? project.milestones.find_or_create_by(title: issue.milestone) : nil
issue = project.issues.create!( issue = project.issues.create!(
iid: issue.iid, iid: issue.iid,
...@@ -74,6 +75,7 @@ module Gitlab ...@@ -74,6 +75,7 @@ module Gitlab
description: description, description: description,
state: issue.state, state: issue.state,
author_id: gitlab_user_id(project, issue.author), author_id: gitlab_user_id(project, issue.author),
milestone: milestone,
created_at: issue.created_at, created_at: issue.created_at,
updated_at: issue.updated_at updated_at: issue.updated_at
) )
......
...@@ -9,6 +9,12 @@ describe Bitbucket::Representation::Issue do ...@@ -9,6 +9,12 @@ describe Bitbucket::Representation::Issue do
it { expect(described_class.new('kind' => 'bug').kind).to eq('bug') } it { expect(described_class.new('kind' => 'bug').kind).to eq('bug') }
end end
describe '#milestone' do
it { expect(described_class.new({ 'milestone' => { 'name' => '1.0' } }).milestone).to eq('1.0') }
it { expect(described_class.new({}).milestone).to be_nil }
end
describe '#author' do describe '#author' do
it { expect(described_class.new({ 'reporter' => { 'username' => 'Ben' } }).author).to eq('Ben') } it { expect(described_class.new({ 'reporter' => { 'username' => 'Ben' } }).author).to eq('Ben') }
it { expect(described_class.new({}).author).to be_nil } it { expect(described_class.new({}).author).to be_nil }
......
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