summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-04-18 14:08:35 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-04-18 20:07:05 -0300
commitf2fe4af19da9d477e9b0df6ec530d4bcc1ca2a5f (patch)
tree4fe20ab1b6c5458bae72d3fba68645fee702acef /spec
parent06ec511164b37cadbfdf069037745c108486162c (diff)
downloadgitlab-ce-f2fe4af19da9d477e9b0df6ec530d4bcc1ca2a5f.tar.gz
Set GitHub milestones to Issue/Merge Request that were imported
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/github_import/issue_formatter_spec.rb17
-rw-r--r--spec/lib/gitlab/github_import/pull_request_formatter_spec.rb18
2 files changed, 35 insertions, 0 deletions
diff --git a/spec/lib/gitlab/github_import/issue_formatter_spec.rb b/spec/lib/gitlab/github_import/issue_formatter_spec.rb
index 4f3d7f4405b..46899b529b2 100644
--- a/spec/lib/gitlab/github_import/issue_formatter_spec.rb
+++ b/spec/lib/gitlab/github_import/issue_formatter_spec.rb
@@ -32,6 +32,7 @@ describe Gitlab::GithubImport::IssueFormatter, lib: true do
expected = {
iid: 1347,
project: project,
+ milestone: nil,
title: 'Found a bug',
description: "*Created by: octocat*\n\nI'm having a problem with this.",
state: 'opened',
@@ -53,6 +54,7 @@ describe Gitlab::GithubImport::IssueFormatter, lib: true do
expected = {
iid: 1347,
project: project,
+ milestone: nil,
title: 'Found a bug',
description: "*Created by: octocat*\n\nI'm having a problem with this.",
state: 'closed',
@@ -80,6 +82,21 @@ describe Gitlab::GithubImport::IssueFormatter, lib: true do
end
end
+ context 'when it has a milestone' do
+ let(:milestone) { OpenStruct.new(number: 45) }
+ let(:raw_data) { OpenStruct.new(base_data.merge(milestone: milestone)) }
+
+ it 'returns nil when milestone does not exist' do
+ expect(issue.attributes.fetch(:milestone)).to be_nil
+ end
+
+ it 'returns milestone when it exists' do
+ milestone = create(:milestone, project: project, iid: 45)
+
+ expect(issue.attributes.fetch(:milestone)).to eq milestone
+ end
+ end
+
context 'when author is a GitLab user' do
let(:raw_data) { OpenStruct.new(base_data.merge(user: octocat)) }
diff --git a/spec/lib/gitlab/github_import/pull_request_formatter_spec.rb b/spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
index 11249e57ca8..590085718c7 100644
--- a/spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
+++ b/spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
@@ -43,6 +43,7 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
target_project: project,
target_branch: 'master',
state: 'opened',
+ milestone: nil,
author_id: project.creator_id,
assignee_id: nil,
created_at: created_at,
@@ -67,6 +68,7 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
target_project: project,
target_branch: 'master',
state: 'closed',
+ milestone: nil,
author_id: project.creator_id,
assignee_id: nil,
created_at: created_at,
@@ -91,6 +93,7 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
target_project: project,
target_branch: 'master',
state: 'merged',
+ milestone: nil,
author_id: project.creator_id,
assignee_id: nil,
created_at: created_at,
@@ -128,6 +131,21 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
expect(pull_request.attributes.fetch(:author_id)).to eq gl_user.id
end
end
+
+ context 'when it has a milestone' do
+ let(:milestone) { OpenStruct.new(number: 45) }
+ let(:raw_data) { OpenStruct.new(base_data.merge(milestone: milestone)) }
+
+ it 'returns nil when milestone does not exists' do
+ expect(pull_request.attributes.fetch(:milestone)).to be_nil
+ end
+
+ it 'returns milestone when is exists' do
+ milestone = create(:milestone, project: project, iid: 45)
+
+ expect(pull_request.attributes.fetch(:milestone)).to eq milestone
+ end
+ end
end
describe '#number' do