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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
7362fd6f
Commit
7362fd6f
authored
Feb 17, 2017
by
mhasbini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a :iids param to IssuableFinder
parent
827a56a4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
27 deletions
+23
-27
app/finders/issuable_finder.rb
app/finders/issuable_finder.rb
+6
-9
app/finders/issues_finder.rb
app/finders/issues_finder.rb
+0
-4
app/finders/merge_requests_finder.rb
app/finders/merge_requests_finder.rb
+0
-10
changelogs/unreleased/26379-iid-param.yml
changelogs/unreleased/26379-iid-param.yml
+4
-0
lib/api/v3/issues.rb
lib/api/v3/issues.rb
+2
-1
spec/finders/issues_finder_spec.rb
spec/finders/issues_finder_spec.rb
+3
-3
spec/finders/merge_requests_finder_spec.rb
spec/finders/merge_requests_finder_spec.rb
+8
-0
No files found.
app/finders/issuable_finder.rb
View file @
7362fd6f
...
...
@@ -16,6 +16,7 @@
# label_name: string
# sort: string
# non_archived: boolean
# iids: integer[]
#
class
IssuableFinder
NONE
=
'0'
...
...
@@ -40,6 +41,7 @@ class IssuableFinder
items
=
by_label
(
items
)
items
=
by_due_date
(
items
)
items
=
by_non_archived
(
items
)
items
=
by_iids
(
items
)
sort
(
items
)
end
...
...
@@ -266,16 +268,11 @@ class IssuableFinder
end
def
by_search
(
items
)
if
search
items
=
if
search
=~
iid_pattern
items
.
where
(
iid:
$~
[
:iid
])
else
items
.
full_search
(
search
)
end
end
search
?
items
.
full_search
(
search
)
:
items
end
items
def
by_iids
(
items
)
params
[
:iids
].
present?
?
items
.
where
(
iid:
params
[
:iids
])
:
items
end
def
sort
(
items
)
...
...
app/finders/issues_finder.rb
View file @
7362fd6f
...
...
@@ -26,10 +26,6 @@ class IssuesFinder < IssuableFinder
IssuesFinder
.
not_restricted_by_confidentiality
(
current_user
)
end
def
iid_pattern
@iid_pattern
||=
%r{
\A
#{
Regexp
.
escape
(
Issue
.
reference_prefix
)
}
(?<iid>
\d
+)
\z
}
end
def
self
.
not_restricted_by_confidentiality
(
user
)
return
Issue
.
where
(
'issues.confidential IS NULL OR issues.confidential IS FALSE'
)
if
user
.
blank?
...
...
app/finders/merge_requests_finder.rb
View file @
7362fd6f
...
...
@@ -20,14 +20,4 @@ class MergeRequestsFinder < IssuableFinder
def
klass
MergeRequest
end
private
def
iid_pattern
@iid_pattern
||=
%r{
\A
[
#{
Regexp
.
escape
(
MergeRequest
.
reference_prefix
)
}
#{
Regexp
.
escape
(
Issue
.
reference_prefix
)
}
](?<iid>
\d
+)
\z
}x
end
end
changelogs/unreleased/26379-iid-param.yml
0 → 100644
View file @
7362fd6f
---
title
:
add :iids param to IssuableFinder (resolve technical dept)
merge_request
:
9222
author
:
mhasbini
lib/api/v3/issues.rb
View file @
7362fd6f
...
...
@@ -16,7 +16,8 @@ module API
labels
=
args
.
delete
(
:labels
)
args
[
:label_name
]
=
labels
if
match_all_labels
args
[
:search
]
=
"
#{
Issue
.
reference_prefix
}#{
args
.
delete
(
:iid
)
}
"
if
args
.
key?
(
:iid
)
# IssuesFinder expects iids
args
[
:iids
]
=
args
.
delete
(
:iid
)
if
args
.
key?
(
:iid
)
issues
=
IssuesFinder
.
new
(
current_user
,
args
).
execute
.
inc_notes_with_associations
...
...
spec/finders/issues_finder_spec.rb
View file @
7362fd6f
...
...
@@ -136,10 +136,10 @@ describe IssuesFinder do
end
end
context
'filtering by issue
iid
'
do
let
(
:params
)
{
{
search:
issue3
.
to_reference
}
}
context
'filtering by issue
s iids
'
do
let
(
:params
)
{
{
iids:
issue3
.
iid
}
}
it
'returns issue
with iid
match'
do
it
'returns issue
s with iids
match'
do
expect
(
issues
).
to
contain_exactly
(
issue3
)
end
end
...
...
spec/finders/merge_requests_finder_spec.rb
View file @
7362fd6f
...
...
@@ -38,5 +38,13 @@ describe MergeRequestsFinder do
merge_requests
=
MergeRequestsFinder
.
new
(
user
,
params
).
execute
expect
(
merge_requests
.
size
).
to
eq
(
3
)
end
it
'filters by iid'
do
params
=
{
project_id:
project1
.
id
,
iids:
merge_request1
.
iid
}
merge_requests
=
MergeRequestsFinder
.
new
(
user
,
params
).
execute
expect
(
merge_requests
).
to
contain_exactly
(
merge_request1
)
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