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
3fd3e8c1
Commit
3fd3e8c1
authored
Jul 06, 2020
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Maps the standard sort values to Jira sort values
for use in JqlBuilderService
parent
c75c0662
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
app/finders/projects/integrations/jira/issues_finder.rb
app/finders/projects/integrations/jira/issues_finder.rb
+10
-0
spec/finders/projects/integrations/jira/issues_finder_spec.rb
.../finders/projects/integrations/jira/issues_finder_spec.rb
+24
-0
No files found.
app/finders/projects/integrations/jira/issues_finder.rb
View file @
3fd3e8c1
...
@@ -14,6 +14,7 @@ module Projects
...
@@ -14,6 +14,7 @@ module Projects
@jira_service
=
project
.
jira_service
@jira_service
=
project
.
jira_service
@page
=
params
[
:page
].
presence
||
1
@page
=
params
[
:page
].
presence
||
1
@params
=
params
@params
=
params
@params
=
@params
.
reverse_merge
(
map_sort_values
(
@params
.
delete
(
:sort
)))
end
end
def
execute
def
execute
...
@@ -44,6 +45,15 @@ module Projects
...
@@ -44,6 +45,15 @@ module Projects
end
end
end
end
# rubocop: enable CodeReuse/ServiceClass
# rubocop: enable CodeReuse/ServiceClass
def
map_sort_values
(
sort
)
case
sort
when
'created_date'
{
sort:
'created'
,
sort_direction:
'DESC'
}
else
{
sort:
::
Jira
::
JqlBuilderService
::
DEFAULT_SORT
,
sort_direction:
::
Jira
::
JqlBuilderService
::
DEFAULT_SORT_DIRECTION
}
end
end
end
end
end
end
end
end
...
...
spec/finders/projects/integrations/jira/issues_finder_spec.rb
View file @
3fd3e8c1
...
@@ -75,6 +75,30 @@ RSpec.describe Projects::Integrations::Jira::IssuesFinder do
...
@@ -75,6 +75,30 @@ RSpec.describe Projects::Integrations::Jira::IssuesFinder do
expect
(
service
.
total_count
).
to
eq
375
expect
(
service
.
total_count
).
to
eq
375
expect
(
issues
.
map
(
&
:key
)).
to
eq
(
%w[TEST-1 TEST-2]
)
expect
(
issues
.
map
(
&
:key
)).
to
eq
(
%w[TEST-1 TEST-2]
)
end
end
context
'when sort by created_date'
do
let
(
:params
)
{
{
sort:
'created_date'
}
}
it
'maps sort correctly'
do
expect
(
::
Jira
::
JqlBuilderService
).
to
receive
(
:new
)
.
with
(
jira_service
.
project_key
,
{
sort:
'created'
,
sort_direction:
'DESC'
})
.
and_call_original
subject
end
end
context
'when sort by unknown_sort'
do
let
(
:params
)
{
{
sort:
'unknown_sort'
}
}
it
'maps sort to default'
do
expect
(
::
Jira
::
JqlBuilderService
).
to
receive
(
:new
)
.
with
(
jira_service
.
project_key
,
{
sort:
'created'
,
sort_direction:
'DESC'
})
.
and_call_original
subject
end
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