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
56a54c62
Commit
56a54c62
authored
Feb 21, 2019
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add confidential_only scop to issue model
parent
73e3a1cd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
9 deletions
+13
-9
app/finders/issues_finder.rb
app/finders/issues_finder.rb
+3
-9
app/models/issue.rb
app/models/issue.rb
+1
-0
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+9
-0
No files found.
app/finders/issues_finder.rb
View file @
56a54c62
...
@@ -73,17 +73,11 @@ class IssuesFinder < IssuableFinder
...
@@ -73,17 +73,11 @@ class IssuesFinder < IssuableFinder
by_confidential
(
issues
)
by_confidential
(
issues
)
end
end
# rubocop: disable CodeReuse/ActiveRecord
def
by_confidential
(
items
)
def
by_confidential
(
items
)
if
params
[
:confidential
]
==
'yes'
return
items
unless
params
[
:confidential
].
present?
items
.
where
(
'issues.confidential = TRUE'
)
elsif
params
[
:confidential
]
==
'no'
params
[
:confidential
]
==
'yes'
?
items
.
confidential_only
:
items
.
public_only
items
.
where
.
not
(
'issues.confidential = TRUE'
)
else
items
end
end
end
# rubocop: enable CodeReuse/ActiveRecord
def
by_due_date
(
items
)
def
by_due_date
(
items
)
if
due_date?
if
due_date?
...
...
app/models/issue.rb
View file @
56a54c62
...
@@ -66,6 +66,7 @@ class Issue < ActiveRecord::Base
...
@@ -66,6 +66,7 @@ class Issue < ActiveRecord::Base
scope
:preload_associations
,
->
{
preload
(
:labels
,
project: :namespace
)
}
scope
:preload_associations
,
->
{
preload
(
:labels
,
project: :namespace
)
}
scope
:public_only
,
->
{
where
(
confidential:
false
)
}
scope
:public_only
,
->
{
where
(
confidential:
false
)
}
scope
:confidential_only
,
->
{
where
(
confidential:
true
)
}
after_save
:expire_etag_cache
after_save
:expire_etag_cache
after_save
:ensure_metrics
,
unless: :imported?
after_save
:ensure_metrics
,
unless: :imported?
...
...
spec/models/issue_spec.rb
View file @
56a54c62
...
@@ -765,6 +765,15 @@ describe Issue do
...
@@ -765,6 +765,15 @@ describe Issue do
end
end
end
end
describe
'.confidential_only'
do
it
'only returns confidential_only issues'
do
create
(
:issue
)
confidential_issue
=
create
(
:issue
,
confidential:
true
)
expect
(
described_class
.
confidential_only
).
to
eq
([
confidential_issue
])
end
end
it_behaves_like
'throttled touch'
do
it_behaves_like
'throttled touch'
do
subject
{
create
(
:issue
,
updated_at:
1
.
hour
.
ago
)
}
subject
{
create
(
:issue
,
updated_at:
1
.
hour
.
ago
)
}
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