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
382ac490
Commit
382ac490
authored
Apr 29, 2020
by
Jarka Košanová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix parsing Jira get labels response
parent
78b68298
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
lib/gitlab/jira_import/labels_importer.rb
lib/gitlab/jira_import/labels_importer.rb
+1
-1
spec/lib/gitlab/jira_import/labels_importer_spec.rb
spec/lib/gitlab/jira_import/labels_importer_spec.rb
+12
-10
No files found.
lib/gitlab/jira_import/labels_importer.rb
View file @
382ac490
...
...
@@ -39,7 +39,7 @@ module Gitlab
def
process_jira_page
(
start_at
)
request
=
"/rest/api/2/label?maxResults=
#{
MAX_LABELS
}
&startAt=
#{
start_at
}
"
response
=
JSON
.
parse
(
client
.
get
(
request
)
)
response
=
client
.
get
(
request
)
return
true
if
response
[
'values'
].
blank?
return
true
unless
response
.
key?
(
'isLast'
)
...
...
spec/lib/gitlab/jira_import/labels_importer_spec.rb
View file @
382ac490
...
...
@@ -8,7 +8,9 @@ describe Gitlab::JiraImport::LabelsImporter do
let_it_be
(
:project
)
{
create
(
:project
,
group:
group
)
}
let_it_be
(
:jira_service
)
{
create
(
:jira_service
,
project:
project
)
}
subject
{
described_class
.
new
(
project
).
execute
}
let
(
:importer
)
{
described_class
.
new
(
project
)
}
subject
{
importer
.
execute
}
before
do
stub_feature_flags
(
jira_issue_import:
true
)
...
...
@@ -35,14 +37,13 @@ describe Gitlab::JiraImport::LabelsImporter do
let
(
:jira_labels_1
)
{
{
"maxResults"
=>
2
,
"startAt"
=>
0
,
"total"
=>
3
,
"isLast"
=>
false
,
"values"
=>
%w(backend bug)
}
}
let
(
:jira_labels_2
)
{
{
"maxResults"
=>
2
,
"startAt"
=>
2
,
"total"
=>
3
,
"isLast"
=>
true
,
"values"
=>
%w(feature)
}
}
context
'when labels are returned from jira'
do
before
do
WebMock
.
stub_request
(
:get
,
'https://jira.example.com/rest/api/2/label?maxResults=2&startAt=0'
)
.
to_return
(
body:
jira_labels_1
.
to_json
)
WebMock
.
stub_request
(
:get
,
'https://jira.example.com/rest/api/2/label?maxResults=2&startAt=2'
)
.
to_return
(
body:
jira_labels_2
.
to_json
)
client
=
double
expect
(
importer
).
to
receive
(
:client
).
twice
.
and_return
(
client
)
allow
(
client
).
to
receive
(
:get
).
twice
.
and_return
(
jira_labels_1
,
jira_labels_2
)
end
context
'when labels are returned from jira'
do
it
'caches import label'
do
expect
(
Gitlab
::
Cache
::
Import
::
Caching
.
read
(
Gitlab
::
JiraImport
.
import_label_cache_key
(
project
.
id
))).
to
be
nil
...
...
@@ -71,8 +72,9 @@ describe Gitlab::JiraImport::LabelsImporter do
let
(
:jira_labels
)
{
{
"maxResults"
=>
2
,
"startAt"
=>
0
,
"total"
=>
3
,
"values"
=>
[]
}
}
before
do
WebMock
.
stub_request
(
:get
,
'https://jira.example.com/rest/api/2/label?maxResults=2&startAt=0'
)
.
to_return
(
body:
jira_labels
.
to_json
)
client
=
double
expect
(
importer
).
to
receive
(
:client
).
and_return
(
client
)
allow
(
client
).
to
receive
(
:get
).
and_return
(
jira_labels
)
end
context
'when the labels field is empty'
do
...
...
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