summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-03-01 21:27:17 +0000
committerStan Hu <stanhu@gmail.com>2019-03-01 21:27:17 +0000
commit4dbf7d66a4f2478861aaee134017d9d74d64d955 (patch)
treeab721ca910fc4bd7d134b07c558649a47d7ee644
parentbc4ee49ecb1e562543cd196e51eac9a61c016de3 (diff)
parent9c498b10ee07388d36df468d9286631ff98c00b1 (diff)
downloadgitlab-ce-4dbf7d66a4f2478861aaee134017d9d74d64d955.tar.gz
Merge branch '57612-github-importer-ignores-milestone-due_date' into 'master'
Resolve "Github importer ignores Milestone due_date" Closes #57612 See merge request gitlab-org/gitlab-ce!25182
-rw-r--r--changelogs/unreleased/57612-github-importer-ignores-milestone-due_date.yml5
-rw-r--r--lib/gitlab/github_import/importer/milestones_importer.rb1
-rw-r--r--spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb24
3 files changed, 30 insertions, 0 deletions
diff --git a/changelogs/unreleased/57612-github-importer-ignores-milestone-due_date.yml b/changelogs/unreleased/57612-github-importer-ignores-milestone-due_date.yml
new file mode 100644
index 00000000000..0d5cd057ade
--- /dev/null
+++ b/changelogs/unreleased/57612-github-importer-ignores-milestone-due_date.yml
@@ -0,0 +1,5 @@
+---
+title: Capture due date when importing milestones from Github
+merge_request: 25182
+author: dstanley
+type: changed
diff --git a/lib/gitlab/github_import/importer/milestones_importer.rb b/lib/gitlab/github_import/importer/milestones_importer.rb
index 87cf2c8b598..71ff7465d9b 100644
--- a/lib/gitlab/github_import/importer/milestones_importer.rb
+++ b/lib/gitlab/github_import/importer/milestones_importer.rb
@@ -42,6 +42,7 @@ module Gitlab
description: milestone.description,
project_id: project.id,
state: state_for(milestone),
+ due_date: milestone.due_on&.to_date,
created_at: milestone.created_at,
updated_at: milestone.updated_at
}
diff --git a/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb b/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb
index b1cac3b6e46..120a07ff2b3 100644
--- a/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb
@@ -4,6 +4,7 @@ describe Gitlab::GithubImport::Importer::MilestonesImporter, :clean_gitlab_redis
let(:project) { create(:project, import_source: 'foo/bar') }
let(:client) { double(:client) }
let(:importer) { described_class.new(project, client) }
+ let(:due_on) { Time.new(2017, 2, 1, 12, 00) }
let(:created_at) { Time.new(2017, 1, 1, 12, 00) }
let(:updated_at) { Time.new(2017, 1, 1, 12, 15) }
@@ -14,6 +15,20 @@ describe Gitlab::GithubImport::Importer::MilestonesImporter, :clean_gitlab_redis
title: '1.0',
description: 'The first release',
state: 'open',
+ due_on: due_on,
+ created_at: created_at,
+ updated_at: updated_at
+ )
+ end
+
+ let(:milestone2) do
+ double(
+ :milestone,
+ number: 1,
+ title: '1.0',
+ description: 'The first release',
+ state: 'open',
+ due_on: nil,
created_at: created_at,
updated_at: updated_at
)
@@ -72,6 +87,7 @@ describe Gitlab::GithubImport::Importer::MilestonesImporter, :clean_gitlab_redis
describe '#build' do
let(:milestone_hash) { importer.build(milestone) }
+ let(:milestone_hash2) { importer.build(milestone2) }
it 'returns the attributes of the milestone as a Hash' do
expect(milestone_hash).to be_an_instance_of(Hash)
@@ -98,6 +114,14 @@ describe Gitlab::GithubImport::Importer::MilestonesImporter, :clean_gitlab_redis
expect(milestone_hash[:state]).to eq(:active)
end
+ it 'includes the due date' do
+ expect(milestone_hash[:due_date]).to eq(due_on.to_date)
+ end
+
+ it 'responds correctly to no due date value' do
+ expect(milestone_hash2[:due_date]).to be nil
+ end
+
it 'includes the created timestamp' do
expect(milestone_hash[:created_at]).to eq(created_at)
end