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
bee3f430
Commit
bee3f430
authored
Jun 02, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add feature_availability_check flag on IssuableFinder
parent
c09539cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
app/finders/issuable_finder.rb
app/finders/issuable_finder.rb
+20
-2
spec/finders/issues_finder_spec.rb
spec/finders/issues_finder_spec.rb
+12
-0
No files found.
app/finders/issuable_finder.rb
View file @
bee3f430
...
...
@@ -16,6 +16,7 @@
# label_name: string
# sort: string
# non_archived: boolean
# feature_availability_check: boolean (default: true)
# iids: integer[]
#
class
IssuableFinder
...
...
@@ -25,11 +26,15 @@ class IssuableFinder
ARRAY_PARAMS
=
{
label_name:
[],
iids:
[]
}.
freeze
VALID_PARAMS
=
(
SCALAR_PARAMS
+
[
ARRAY_PARAMS
]).
freeze
DEFAULT_PARAMS
=
{
feature_availability_check:
true
}.
freeze
attr_accessor
:current_user
,
:params
def
initialize
(
current_user
,
params
=
{})
@current_user
=
current_user
@params
=
param
s
@params
=
DEFAULT_PARAMS
.
merge
(
params
).
with_indifferent_acces
s
end
def
execute
...
...
@@ -126,7 +131,20 @@ class IssuableFinder
ProjectsFinder
.
new
(
current_user:
current_user
,
project_ids_relation:
item_project_ids
(
items
)).
execute
end
@projects
=
projects
.
with_feature_available_for_user
(
klass
,
current_user
).
reorder
(
nil
)
# Querying through feature availability for an user is expensive
# (i.e. https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1719#note_31406525),
# and there are cases which a project level access check should be enough.
# In any case, `feature_availability_check` param should be kept with `true`
# by default.
#
projects
=
if
params
[
:feature_availability_check
]
projects
.
with_feature_available_for_user
(
klass
,
current_user
)
else
projects
end
@projects
=
projects
.
reorder
(
nil
)
end
def
search
...
...
spec/finders/issues_finder_spec.rb
View file @
bee3f430
...
...
@@ -288,6 +288,18 @@ describe IssuesFinder do
expect
(
issues
.
count
).
to
eq
0
end
it
'returns disabled issues if feature_availability_check param set to false'
do
[
project1
,
project2
].
each
do
|
project
|
project
.
project_feature
.
update!
(
issues_access_level:
ProjectFeature
::
DISABLED
)
end
issues
=
described_class
.
new
(
search_user
,
params
.
reverse_merge
(
scope:
scope
,
state:
'opened'
,
feature_availability_check:
false
))
.
execute
expect
(
issues
.
count
).
to
eq
3
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