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
395aacef
Commit
395aacef
authored
Apr 19, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix searching notes and snippets as an auditor
parent
3fa4d8ab
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
7 deletions
+30
-7
app/models/concerns/elastic/notes_search.rb
app/models/concerns/elastic/notes_search.rb
+1
-1
app/models/concerns/elastic/snippets_search.rb
app/models/concerns/elastic/snippets_search.rb
+1
-1
changelogs/unreleased-ee/2206-fix-note-and-snippet-search-as-auditor.yml
...leased-ee/2206-fix-note-and-snippet-search-as-auditor.yml
+4
-0
spec/factories/users.rb
spec/factories/users.rb
+1
-0
spec/models/concerns/elastic/note_spec.rb
spec/models/concerns/elastic/note_spec.rb
+16
-0
spec/models/concerns/elastic/snippet_spec.rb
spec/models/concerns/elastic/snippet_spec.rb
+7
-5
No files found.
app/models/concerns/elastic/notes_search.rb
View file @
395aacef
...
...
@@ -72,7 +72,7 @@ module Elastic
end
def
self
.
confidentiality_filter
(
query_hash
,
current_user
)
return
query_hash
if
current_user
&&
current_user
.
admin?
return
query_hash
if
current_user
&&
current_user
.
admin
_or_auditor
?
filter
=
{
bool:
{
...
...
app/models/concerns/elastic/snippets_search.rb
View file @
395aacef
...
...
@@ -73,7 +73,7 @@ module Elastic
end
def
self
.
filter
(
query_hash
,
user
)
return
query_hash
if
user
&&
user
.
admin?
return
query_hash
if
user
&&
user
.
admin
_or_auditor
?
filter
=
if
user
{
...
...
changelogs/unreleased-ee/2206-fix-note-and-snippet-search-as-auditor.yml
0 → 100644
View file @
395aacef
---
title
:
Fix searching notes and snippets as an auditor
merge_request
:
1674
author
:
spec/factories/users.rb
View file @
395aacef
...
...
@@ -66,6 +66,7 @@ FactoryGirl.define do
end
factory
:admin
,
traits:
[
:admin
]
factory
:auditor
,
traits:
[
:auditor
]
factory
:external_user
,
traits:
[
:external
]
end
end
spec/models/concerns/elastic/note_spec.rb
View file @
395aacef
...
...
@@ -101,6 +101,22 @@ describe Note, elastic: true do
expect
(
Note
.
elastic_search
(
'term'
,
options:
options
).
total_count
).
to
eq
(
1
)
end
[
:admin
,
:auditor
].
each
do
|
user_type
|
it
"finds note for
#{
user_type
}
"
do
superuser
=
create
(
user_type
)
issue
=
create
(
:issue
,
:confidential
,
author:
create
(
:user
))
Sidekiq
::
Testing
.
inline!
do
create_notes_for
(
issue
,
'bla-bla term'
)
Gitlab
::
Elastic
::
Helper
.
refresh_index
end
options
=
{
project_ids:
[
issue
.
project
.
id
],
current_user:
superuser
}
expect
(
Note
.
elastic_search
(
'term'
,
options:
options
).
total_count
).
to
eq
(
1
)
end
end
it
"return notes with matching content for project members"
do
user
=
create
:user
issue
=
create
:issue
,
:confidential
,
author:
user
...
...
spec/models/concerns/elastic/snippet_spec.rb
View file @
395aacef
...
...
@@ -60,13 +60,15 @@ describe Snippet, elastic: true do
expect
(
result
.
records
).
to
match_array
[
public_snippet
,
internal_snippet
,
private_snippet
]
end
it
'returns all snippets for admins'
do
admin
=
create
(
:admin
)
[
:admin
,
:auditor
].
each
do
|
user_type
|
it
"returns all snippets for
#{
user_type
}
"
do
superuser
=
create
(
user_type
)
result
=
described_class
.
elastic_search_code
(
'password'
,
options:
{
user:
admin
})
result
=
described_class
.
elastic_search_code
(
'password'
,
options:
{
user:
superuser
})
expect
(
result
.
total_count
).
to
eq
(
6
)
expect
(
result
.
records
).
to
match_array
[
public_snippet
,
internal_snippet
,
private_snippet
,
project_public_snippet
,
project_internal_snippet
,
project_private_snippet
]
expect
(
result
.
total_count
).
to
eq
(
6
)
expect
(
result
.
records
).
to
match_array
[
public_snippet
,
internal_snippet
,
private_snippet
,
project_public_snippet
,
project_internal_snippet
,
project_private_snippet
]
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