Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3f9a3565
Commit
3f9a3565
authored
May 04, 2020
by
Jarka Košanová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix assigning issues to users for Jira import
parent
0138ae8a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
app/workers/gitlab/jira_import/import_issue_worker.rb
app/workers/gitlab/jira_import/import_issue_worker.rb
+10
-0
spec/workers/gitlab/jira_import/import_issue_worker_spec.rb
spec/workers/gitlab/jira_import/import_issue_worker_spec.rb
+21
-1
No files found.
app/workers/gitlab/jira_import/import_issue_worker.rb
View file @
3f9a3565
...
@@ -29,9 +29,11 @@ module Gitlab
...
@@ -29,9 +29,11 @@ module Gitlab
def
create_issue
(
issue_attributes
,
project_id
)
def
create_issue
(
issue_attributes
,
project_id
)
label_ids
=
issue_attributes
.
delete
(
'label_ids'
)
label_ids
=
issue_attributes
.
delete
(
'label_ids'
)
assignee_ids
=
issue_attributes
.
delete
(
'assignee_ids'
)
issue_id
=
insert_and_return_id
(
issue_attributes
,
Issue
)
issue_id
=
insert_and_return_id
(
issue_attributes
,
Issue
)
label_issue
(
project_id
,
issue_id
,
label_ids
)
label_issue
(
project_id
,
issue_id
,
label_ids
)
assign_issue
(
project_id
,
issue_id
,
assignee_ids
)
issue_id
issue_id
end
end
...
@@ -49,6 +51,14 @@ module Gitlab
...
@@ -49,6 +51,14 @@ module Gitlab
Gitlab
::
Database
.
bulk_insert
(
LabelLink
.
table_name
,
label_link_attrs
)
Gitlab
::
Database
.
bulk_insert
(
LabelLink
.
table_name
,
label_link_attrs
)
end
end
def
assign_issue
(
project_id
,
issue_id
,
assignee_ids
)
return
if
assignee_ids
.
blank?
assignee_attrs
=
assignee_ids
.
map
{
|
user_id
|
{
issue_id:
issue_id
,
user_id:
user_id
}
}
Gitlab
::
Database
.
bulk_insert
(
IssueAssignee
.
table_name
,
assignee_attrs
)
end
def
build_label_attrs
(
issue_id
,
label_id
)
def
build_label_attrs
(
issue_id
,
label_id
)
time
=
Time
.
now
time
=
Time
.
now
{
{
...
...
spec/workers/gitlab/jira_import/import_issue_worker_spec.rb
View file @
3f9a3565
...
@@ -19,9 +19,12 @@ describe Gitlab::JiraImport::ImportIssueWorker do
...
@@ -19,9 +19,12 @@ describe Gitlab::JiraImport::ImportIssueWorker do
subject
{
described_class
.
new
}
subject
{
described_class
.
new
}
describe
'#perform'
,
:clean_gitlab_redis_cache
do
describe
'#perform'
,
:clean_gitlab_redis_cache
do
let
(
:assignee_ids
)
{
[
user
.
id
]
}
let
(
:issue_attrs
)
do
let
(
:issue_attrs
)
do
build
(
:issue
,
project_id:
project
.
id
,
title:
'jira issue'
)
build
(
:issue
,
project_id:
project
.
id
,
title:
'jira issue'
)
.
as_json
.
merge
(
'label_ids'
=>
[
jira_issue_label_1
.
id
,
jira_issue_label_2
.
id
]).
compact
.
as_json
.
merge
(
'label_ids'
=>
[
jira_issue_label_1
.
id
,
jira_issue_label_2
.
id
],
'assignee_ids'
=>
assignee_ids
).
compact
end
end
context
'when any exception raised while inserting to DB'
do
context
'when any exception raised while inserting to DB'
do
...
@@ -67,6 +70,23 @@ describe Gitlab::JiraImport::ImportIssueWorker do
...
@@ -67,6 +70,23 @@ describe Gitlab::JiraImport::ImportIssueWorker do
expect
(
issue
.
title
).
to
eq
(
'jira issue'
)
expect
(
issue
.
title
).
to
eq
(
'jira issue'
)
expect
(
issue
.
project
).
to
eq
(
project
)
expect
(
issue
.
project
).
to
eq
(
project
)
expect
(
issue
.
labels
).
to
match_array
([
label
,
jira_issue_label_1
,
jira_issue_label_2
])
expect
(
issue
.
labels
).
to
match_array
([
label
,
jira_issue_label_1
,
jira_issue_label_2
])
expect
(
issue
.
assignees
).
to
eq
([
user
])
end
context
'when assignee_ids is nil'
do
let
(
:assignee_ids
)
{
nil
}
it
'creates an issue without assignee'
do
expect
(
Issue
.
last
.
assignees
).
to
be_empty
end
end
context
'when assignee_ids is an empty array'
do
let
(
:assignee_ids
)
{
[]
}
it
'creates an issue without assignee'
do
expect
(
Issue
.
last
.
assignees
).
to
be_empty
end
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment