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
caf30864
Commit
caf30864
authored
Feb 24, 2021
by
Dmitry Gruzd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search: Log search.scope for the default scope
parent
83fe4a7c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
14 deletions
+25
-14
app/controllers/search_controller.rb
app/controllers/search_controller.rb
+1
-1
changelogs/unreleased/247636-fix-logging-search-scope.yml
changelogs/unreleased/247636-fix-logging-search-scope.yml
+5
-0
spec/controllers/search_controller_spec.rb
spec/controllers/search_controller_spec.rb
+19
-13
No files found.
app/controllers/search_controller.rb
View file @
caf30864
...
...
@@ -125,7 +125,7 @@ class SearchController < ApplicationController
payload
[
:metadata
]
||=
{}
payload
[
:metadata
][
'meta.search.group_id'
]
=
params
[
:group_id
]
payload
[
:metadata
][
'meta.search.project_id'
]
=
params
[
:project_id
]
payload
[
:metadata
][
'meta.search.scope'
]
=
params
[
:scope
]
payload
[
:metadata
][
'meta.search.scope'
]
=
params
[
:scope
]
||
@scope
payload
[
:metadata
][
'meta.search.filters.confidential'
]
=
params
[
:confidential
]
payload
[
:metadata
][
'meta.search.filters.state'
]
=
params
[
:state
]
payload
[
:metadata
][
'meta.search.force_search_results'
]
=
params
[
:force_search_results
]
...
...
changelogs/unreleased/247636-fix-logging-search-scope.yml
0 → 100644
View file @
caf30864
---
title
:
'
Search:
Log
search.scope
for
the
default
scope'
merge_request
:
54684
author
:
type
:
fixed
spec/controllers/search_controller_spec.rb
View file @
caf30864
...
...
@@ -261,23 +261,29 @@ RSpec.describe SearchController do
describe
'#append_info_to_payload'
do
it
'appends search metadata for logging'
do
last_payload
=
nil
original_append_info_to_payload
=
controller
.
method
(
:append_info_to_
payload
)
expect
(
controller
).
to
receive
(
:append_info_to_payload
).
and_wrap_original
do
|
method
,
payload
|
method
.
call
(
payload
)
expect
(
controller
).
to
receive
(
:append_info_to_payload
)
do
|
payload
|
original_append_info_to_payload
.
call
(
payload
)
last_payload
=
payload
expect
(
payload
[
:metadata
][
'meta.search.group_id'
]).
to
eq
(
'123'
)
expect
(
payload
[
:metadata
][
'meta.search.project_id'
]).
to
eq
(
'456'
)
expect
(
payload
[
:metadata
]).
not_to
have_key
(
'meta.search.search'
)
expect
(
payload
[
:metadata
][
'meta.search.scope'
]).
to
eq
(
'issues'
)
expect
(
payload
[
:metadata
][
'meta.search.force_search_results'
]).
to
eq
(
'true'
)
expect
(
payload
[
:metadata
][
'meta.search.filters.confidential'
]).
to
eq
(
'true'
)
expect
(
payload
[
:metadata
][
'meta.search.filters.state'
]).
to
eq
(
'true'
)
end
get
:show
,
params:
{
scope:
'issues'
,
search:
'hello world'
,
group_id:
'123'
,
project_id:
'456'
,
confidential:
true
,
state:
true
,
force_search_results:
true
}
end
it
'appends the default scope in meta.search.scope'
do
expect
(
controller
).
to
receive
(
:append_info_to_payload
).
and_wrap_original
do
|
method
,
payload
|
method
.
call
(
payload
)
expect
(
payload
[
:metadata
][
'meta.search.scope'
]).
to
eq
(
'projects'
)
end
expect
(
last_payload
[
:metadata
][
'meta.search.group_id'
]).
to
eq
(
'123'
)
expect
(
last_payload
[
:metadata
][
'meta.search.project_id'
]).
to
eq
(
'456'
)
expect
(
last_payload
[
:metadata
]).
not_to
have_key
(
'meta.search.search'
)
expect
(
last_payload
[
:metadata
][
'meta.search.scope'
]).
to
eq
(
'issues'
)
expect
(
last_payload
[
:metadata
][
'meta.search.force_search_results'
]).
to
eq
(
'true'
)
expect
(
last_payload
[
:metadata
][
'meta.search.filters.confidential'
]).
to
eq
(
'true'
)
expect
(
last_payload
[
:metadata
][
'meta.search.filters.state'
]).
to
eq
(
'true'
)
get
:show
,
params:
{
search:
'hello world'
,
group_id:
'123'
,
project_id:
'456'
}
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