Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
e357d495
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e357d495
编写于
4月 29, 2020
作者:
G
GitLab Bot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add latest changes from gitlab-org/gitlab@master
上级
2f0a7423
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
350 addition
and
155 deletion
+350
-155
app/assets/javascripts/boards/models/list.js
app/assets/javascripts/boards/models/list.js
+2
-30
app/assets/javascripts/boards/stores/boards_store.js
app/assets/javascripts/boards/stores/boards_store.js
+31
-0
app/assets/javascripts/monitoring/components/charts/heatmap.vue
...sets/javascripts/monitoring/components/charts/heatmap.vue
+1
-1
app/controllers/search_controller.rb
app/controllers/search_controller.rb
+0
-11
app/models/snippet.rb
app/models/snippet.rb
+0
-11
app/services/search/snippet_service.rb
app/services/search/snippet_service.rb
+1
-1
changelogs/unreleased/214773-metrics-dashboadr-heatmap-styles.yml
...gs/unreleased/214773-metrics-dashboadr-heatmap-styles.yml
+5
-0
changelogs/unreleased/Remove-getIssues-function-logic-from-list-js.yml
...released/Remove-getIssues-function-logic-from-list-js.yml
+5
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+46
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+189
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+12
-0
lib/gitlab/snippet_search_results.rb
lib/gitlab/snippet_search_results.rb
+2
-28
locale/gitlab.pot
locale/gitlab.pot
+1
-1
spec/controllers/search_controller_spec.rb
spec/controllers/search_controller_spec.rb
+0
-8
spec/frontend/boards/boards_store_spec.js
spec/frontend/boards/boards_store_spec.js
+16
-0
spec/lib/gitlab/snippet_search_results_spec.rb
spec/lib/gitlab/snippet_search_results_spec.rb
+4
-21
spec/models/snippet_spec.rb
spec/models/snippet_spec.rb
+0
-16
spec/services/search/snippet_service_spec.rb
spec/services/search/snippet_service_spec.rb
+29
-21
spec/services/search_service_spec.rb
spec/services/search_service_spec.rb
+6
-6
未找到文件。
app/assets/javascripts/boards/models/list.js
浏览文件 @
e357d495
/* eslint-disable no-underscore-dangle, class-methods-use-this, consistent-return
, no-shadow
*/
/* eslint-disable no-underscore-dangle, class-methods-use-this, consistent-return */
import
ListIssue
from
'
ee_else_ce/boards/models/issue
'
;
import
{
__
}
from
'
~/locale
'
;
import
ListLabel
from
'
./label
'
;
import
ListAssignee
from
'
./assignee
'
;
import
{
urlParamsToObject
}
from
'
~/lib/utils/common_utils
'
;
import
flash
from
'
~/flash
'
;
import
boardsStore
from
'
../stores/boards_store
'
;
import
ListMilestone
from
'
./milestone
'
;
...
...
@@ -113,34 +112,7 @@ class List {
}
getIssues
(
emptyIssues
=
true
)
{
const
data
=
{
...
urlParamsToObject
(
boardsStore
.
filter
.
path
),
page
:
this
.
page
,
};
if
(
this
.
label
&&
data
.
label_name
)
{
data
.
label_name
=
data
.
label_name
.
filter
(
label
=>
label
!==
this
.
label
.
title
);
}
if
(
emptyIssues
)
{
this
.
loading
=
true
;
}
return
boardsStore
.
getIssuesForList
(
this
.
id
,
data
)
.
then
(
res
=>
res
.
data
)
.
then
(
data
=>
{
this
.
loading
=
false
;
this
.
issuesSize
=
data
.
size
;
if
(
emptyIssues
)
{
this
.
issues
=
[];
}
this
.
createIssues
(
data
.
issues
);
return
data
;
});
return
boardsStore
.
getListIssues
(
this
,
emptyIssues
);
}
newIssue
(
issue
)
{
...
...
app/assets/javascripts/boards/stores/boards_store.js
浏览文件 @
e357d495
...
...
@@ -7,6 +7,7 @@ import Vue from 'vue';
import
Cookies
from
'
js-cookie
'
;
import
BoardsStoreEE
from
'
ee_else_ce/boards/stores/boards_store_ee
'
;
import
{
urlParamsToObject
,
getUrlParamsArray
,
parseBoolean
,
convertObjectPropsToCamelCase
,
...
...
@@ -535,6 +536,36 @@ const boardsStore = {
});
},
getListIssues
(
list
,
emptyIssues
=
true
)
{
const
data
=
{
...
urlParamsToObject
(
this
.
filter
.
path
),
page
:
list
.
page
,
};
if
(
list
.
label
&&
data
.
label_name
)
{
data
.
label_name
=
data
.
label_name
.
filter
(
label
=>
label
!==
list
.
label
.
title
);
}
if
(
emptyIssues
)
{
list
.
loading
=
true
;
}
return
this
.
getIssuesForList
(
list
.
id
,
data
)
.
then
(
res
=>
res
.
data
)
.
then
(
data
=>
{
list
.
loading
=
false
;
list
.
issuesSize
=
data
.
size
;
if
(
emptyIssues
)
{
list
.
issues
=
[];
}
list
.
createIssues
(
data
.
issues
);
return
data
;
});
},
getIssuesForList
(
id
,
filter
=
{})
{
const
data
=
{
id
};
Object
.
keys
(
filter
).
forEach
(
key
=>
{
...
...
app/assets/javascripts/monitoring/components/charts/heatmap.vue
浏览文件 @
e357d495
...
...
@@ -63,7 +63,7 @@ export default {
};
</
script
>
<
template
>
<div
v-gl-resize-observer-directive=
"onResize"
class=
"col-12 col-lg-6"
>
<div
v-gl-resize-observer-directive=
"onResize"
>
<gl-heatmap
ref=
"heatmapChart"
v-bind=
"$attrs"
...
...
app/controllers/search_controller.rb
浏览文件 @
e357d495
...
...
@@ -5,7 +5,6 @@ class SearchController < ApplicationController
include
SearchHelper
include
RendersCommits
before_action
:override_snippet_scope
,
only: :show
around_action
:allow_gitaly_ref_name_caching
skip_before_action
:authenticate_user!
...
...
@@ -104,14 +103,4 @@ class SearchController < ApplicationController
Gitlab
::
UsageDataCounters
::
SearchCounter
.
increment_navbar_searches_count
end
# Disallow web snippet_blobs search as we migrate snippet
# from database-backed storage to git repository-based,
# and searching across multiple git repositories is not feasible.
#
# TODO: after 13.0 refactor this into Search::SnippetService
# See https://gitlab.com/gitlab-org/gitlab/issues/208882
def
override_snippet_scope
params
[
:scope
]
=
'snippet_titles'
if
params
[
:snippets
]
==
'true'
end
end
app/models/snippet.rb
浏览文件 @
e357d495
...
...
@@ -341,17 +341,6 @@ class Snippet < ApplicationRecord
fuzzy_search
(
query
,
[
:title
,
:description
,
:file_name
])
end
# Searches for snippets with matching content.
#
# This method uses ILIKE on PostgreSQL and LIKE on MySQL.
#
# query - The search query as a String.
#
# Returns an ActiveRecord::Relation.
def
search_code
(
query
)
fuzzy_search
(
query
,
[
:content
])
end
def
parent_class
::
Project
end
...
...
app/services/search/snippet_service.rb
浏览文件 @
e357d495
...
...
@@ -7,7 +7,7 @@ module Search
end
def
scope
@scope
||=
%w[snippet_titles]
.
delete
(
params
[
:scope
])
{
'snippet_blobs'
}
@scope
||=
'snippet_titles'
end
end
end
...
...
changelogs/unreleased/214773-metrics-dashboadr-heatmap-styles.yml
0 → 100644
浏览文件 @
e357d495
---
title
:
Stretch heatmap metrics full column size
merge_request
:
30524
author
:
type
:
fixed
changelogs/unreleased/Remove-getIssues-function-logic-from-list-js.yml
0 → 100644
浏览文件 @
e357d495
---
title
:
removes store logic from issue board models
merge_request
:
21400
author
:
nuwe1
type
:
other
doc/api/graphql/reference/gitlab_schema.graphql
浏览文件 @
e357d495
...
...
@@ -38,6 +38,51 @@ type AddAwardEmojiPayload {
errors
:
[
String
!]!
}
"""
Autogenerated input type of AddProjectsToSecurityDashboard
"""
input
AddProjectsToSecurityDashboardInput
{
"""
A
unique
identifier
for
the
client
performing
the
mutation
.
"""
clientMutationId
:
String
"""
IDs
of
projects
to
be
added
to
Instance
Security
Dashboard
"""
projectIds
:
[
ID
!]!
}
"""
Autogenerated return type of AddProjectsToSecurityDashboard
"""
type
AddProjectsToSecurityDashboardPayload
{
"""
IDs
of
projects
that
were
added
to
the
Instance
Security
Dashboard
"""
addedProjectIds
:
[
ID
!]
"""
A
unique
identifier
for
the
client
performing
the
mutation
.
"""
clientMutationId
:
String
"""
IDs
of
projects
that
are
already
added
to
the
Instance
Security
Dashboard
"""
duplicatedProjectIds
:
[
ID
!]
"""
Reasons
why
the
mutation
failed
.
"""
errors
:
[
String
!]!
"""
IDs
of
projects
that
were
not
added
to
the
Instance
Security
Dashboard
"""
invalidProjectIds
:
[
ID
!]
}
"""
Autogenerated input type of AdminSidekiqQueuesDeleteJobs
"""
...
...
@@ -5898,6 +5943,7 @@ enum MoveType {
type
Mutation
{
addAwardEmoji
(
input
:
AddAwardEmojiInput
!):
AddAwardEmojiPayload
addProjectsToSecurityDashboard
(
input
:
AddProjectsToSecurityDashboardInput
!):
AddProjectsToSecurityDashboardPayload
adminSidekiqQueuesDeleteJobs
(
input
:
AdminSidekiqQueuesDeleteJobsInput
!):
AdminSidekiqQueuesDeleteJobsPayload
boardListUpdateLimitMetrics
(
input
:
BoardListUpdateLimitMetricsInput
!):
BoardListUpdateLimitMetricsPayload
createDiffNote
(
input
:
CreateDiffNoteInput
!):
CreateDiffNotePayload
...
...
doc/api/graphql/reference/gitlab_schema.json
浏览文件 @
e357d495
...
...
@@ -125,6 +125,168 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "AddProjectsToSecurityDashboardInput",
"description": "Autogenerated input type of AddProjectsToSecurityDashboard",
"fields": null,
"inputFields": [
{
"name": "projectIds",
"description": "IDs of projects to be added to Instance Security Dashboard",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
}
},
"defaultValue": null
},
{
"name": "clientMutationId",
"description": "A unique identifier for the client performing the mutation.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "AddProjectsToSecurityDashboardPayload",
"description": "Autogenerated return type of AddProjectsToSecurityDashboard",
"fields": [
{
"name": "addedProjectIds",
"description": "IDs of projects that were added to the Instance Security Dashboard",
"args": [
],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "clientMutationId",
"description": "A unique identifier for the client performing the mutation.",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "duplicatedProjectIds",
"description": "IDs of projects that are already added to the Instance Security Dashboard",
"args": [
],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "errors",
"description": "Reasons why the mutation failed.",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "invalidProjectIds",
"description": "IDs of projects that were not added to the Instance Security Dashboard",
"args": [
],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "AdminSidekiqQueuesDeleteJobsInput",
...
...
@@ -16820,6 +16982,33 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "addProjectsToSecurityDashboard",
"description": null,
"args": [
{
"name": "input",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "INPUT_OBJECT",
"name": "AddProjectsToSecurityDashboardInput",
"ofType": null
}
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
"name": "AddProjectsToSecurityDashboardPayload",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "adminSidekiqQueuesDeleteJobs",
"description": null,
...
...
doc/api/graphql/reference/index.md
浏览文件 @
e357d495
...
...
@@ -26,6 +26,18 @@ Autogenerated return type of AddAwardEmoji
|
`clientMutationId`
| String | A unique identifier for the client performing the mutation. |
|
`errors`
| String! => Array | Reasons why the mutation failed. |
## AddProjectsToSecurityDashboardPayload
Autogenerated return type of AddProjectsToSecurityDashboard
| Name | Type | Description |
| --- | ---- | ---------- |
|
`addedProjectIds`
| ID! => Array | IDs of projects that were added to the Instance Security Dashboard |
|
`clientMutationId`
| String | A unique identifier for the client performing the mutation. |
|
`duplicatedProjectIds`
| ID! => Array | IDs of projects that are already added to the Instance Security Dashboard |
|
`errors`
| String! => Array | Reasons why the mutation failed. |
|
`invalidProjectIds`
| ID! => Array | IDs of projects that were not added to the Instance Security Dashboard |
## AdminSidekiqQueuesDeleteJobsPayload
Autogenerated return type of AdminSidekiqQueuesDeleteJobs
...
...
lib/gitlab/snippet_search_results.rb
浏览文件 @
e357d495
...
...
@@ -12,35 +12,17 @@ module Gitlab
end
def
objects
(
scope
,
page
=
nil
)
case
scope
when
'snippet_titles'
paginated_objects
(
snippet_titles
,
page
)
when
'snippet_blobs'
paginated_objects
(
snippet_blobs
,
page
)
else
super
(
scope
,
nil
,
false
)
end
paginated_objects
(
snippet_titles
,
page
)
end
def
formatted_count
(
scope
)
case
scope
when
'snippet_titles'
formatted_limited_count
(
limited_snippet_titles_count
)
when
'snippet_blobs'
formatted_limited_count
(
limited_snippet_blobs_count
)
else
super
end
formatted_limited_count
(
limited_snippet_titles_count
)
end
def
limited_snippet_titles_count
@limited_snippet_titles_count
||=
limited_count
(
snippet_titles
)
end
def
limited_snippet_blobs_count
@limited_snippet_blobs_count
||=
limited_count
(
snippet_blobs
)
end
private
# rubocop: disable CodeReuse/ActiveRecord
...
...
@@ -56,14 +38,6 @@ module Gitlab
snippets
.
search
(
query
)
end
def
snippet_blobs
snippets
.
search_code
(
query
)
end
def
default_scope
'snippet_blobs'
end
def
paginated_objects
(
relation
,
page
)
relation
.
page
(
page
).
per
(
per_page
)
end
...
...
locale/gitlab.pot
浏览文件 @
e357d495
...
...
@@ -15337,7 +15337,7 @@ msgstr ""
msgid "Prevent users from changing their profile name"
msgstr ""
msgid "Prevent users from modifing merge request approvers list"
msgid "Prevent users from modif
y
ing merge request approvers list"
msgstr ""
msgid "Prevent users from performing write operations on GitLab while performing maintenance."
...
...
spec/controllers/search_controller_spec.rb
浏览文件 @
e357d495
...
...
@@ -140,14 +140,6 @@ describe SearchController do
end
end
context
'snippet search'
do
it
'forces title search'
do
get
:show
,
params:
{
scope:
'snippet_blobs'
,
snippets:
'true'
,
search:
'foo'
}
expect
(
assigns
[
:scope
]).
to
eq
(
'snippet_titles'
)
end
end
it
'finds issue comments'
do
project
=
create
(
:project
,
:public
)
note
=
create
(
:note_on_issue
,
project:
project
)
...
...
spec/frontend/boards/boards_store_spec.js
浏览文件 @
e357d495
...
...
@@ -214,6 +214,22 @@ describe('boardsStore', () => {
});
});
describe
(
'
getListIssues
'
,
()
=>
{
let
list
;
beforeEach
(()
=>
{
list
=
new
List
(
listObj
);
setupDefaultResponses
();
});
it
(
'
makes a request to get issues
'
,
()
=>
{
const
expectedResponse
=
expect
.
objectContaining
({
issues
:
[
createTestIssue
()]
});
expect
(
list
.
issues
).
toEqual
([]);
return
expect
(
boardsStore
.
getListIssues
(
list
,
true
)).
resolves
.
toEqual
(
expectedResponse
);
});
});
describe
(
'
getIssuesForList
'
,
()
=>
{
const
id
=
'
TOO-MUCH
'
;
const
url
=
`
${
endpoints
.
listsEndpoint
}
/
${
id
}
/issues?id=
${
id
}
`
;
...
...
spec/lib/gitlab/snippet_search_results_spec.rb
浏览文件 @
e357d495
...
...
@@ -5,7 +5,7 @@ require 'spec_helper'
describe
Gitlab
::
SnippetSearchResults
do
include
SearchHelpers
let
!
(
:snippet
)
{
create
(
:snippet
,
content:
'foo'
,
file_name:
'foo'
)
}
let
_it_be
(
:snippet
)
{
create
(
:snippet
,
content:
'foo'
,
file_name:
'foo'
)
}
let
(
:results
)
{
described_class
.
new
(
snippet
.
author
,
'foo'
)
}
describe
'#snippet_titles_count'
do
...
...
@@ -14,27 +14,10 @@ describe Gitlab::SnippetSearchResults do
end
end
describe
'#snippet_blobs_count'
do
it
'returns the amount of matched snippet blobs'
do
expect
(
results
.
limited_snippet_blobs_count
).
to
eq
(
1
)
end
end
describe
'#formatted_count'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:scope
,
:count_method
,
:expected
)
do
'snippet_titles'
|
:limited_snippet_titles_count
|
max_limited_count
'snippet_blobs'
|
:limited_snippet_blobs_count
|
max_limited_count
'projects'
|
:limited_projects_count
|
max_limited_count
'unknown'
|
nil
|
nil
end
with_them
do
it
'returns the expected formatted count'
do
expect
(
results
).
to
receive
(
count_method
).
and_return
(
1234
)
if
count_method
expect
(
results
.
formatted_count
(
scope
)).
to
eq
(
expected
)
end
it
'returns the expected formatted count'
do
expect
(
results
).
to
receive
(
:limited_snippet_titles_count
).
and_return
(
1234
)
expect
(
results
.
formatted_count
(
'snippet_titles'
)).
to
eq
(
max_limited_count
)
end
end
end
spec/models/snippet_spec.rb
浏览文件 @
e357d495
...
...
@@ -180,22 +180,6 @@ describe Snippet do
end
end
describe
'.search_code'
do
let
(
:snippet
)
{
create
(
:snippet
,
content:
'class Foo; end'
)
}
it
'returns snippets with matching content'
do
expect
(
described_class
.
search_code
(
snippet
.
content
)).
to
eq
([
snippet
])
end
it
'returns snippets with partially matching content'
do
expect
(
described_class
.
search_code
(
'class'
)).
to
eq
([
snippet
])
end
it
'returns snippets with matching content regardless of the casing'
do
expect
(
described_class
.
search_code
(
'FOO'
)).
to
eq
([
snippet
])
end
end
describe
'when default snippet visibility set to internal'
do
using
RSpec
::
Parameterized
::
TableSyntax
...
...
spec/services/search/snippet_service_spec.rb
浏览文件 @
e357d495
...
...
@@ -3,59 +3,67 @@
require
'spec_helper'
describe
Search
::
SnippetService
do
let
(
:author
)
{
create
(
:author
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
_it_be
(
:author
)
{
create
(
:author
)
}
let
_it_be
(
:project
)
{
create
(
:project
,
:public
)
}
let
!
(
:public_snippet
)
{
create
(
:snippet
,
:public
,
content:
'password: XXX
'
)
}
let
!
(
:internal_snippet
)
{
create
(
:snippet
,
:internal
,
content:
'password: XXX
'
)
}
let
!
(
:private_snippet
)
{
create
(
:snippet
,
:private
,
content:
'password: XXX
'
,
author:
author
)
}
let
_it_be
(
:public_snippet
)
{
create
(
:snippet
,
:public
,
title:
'Foo Bar Title
'
)
}
let
_it_be
(
:internal_snippet
)
{
create
(
:snippet
,
:internal
,
title:
'Foo Bar Title
'
)
}
let
_it_be
(
:private_snippet
)
{
create
(
:snippet
,
:private
,
title:
'Foo Bar Title
'
,
author:
author
)
}
let!
(
:project_public_snippet
)
{
create
(
:snippet
,
:public
,
project:
project
,
content:
'password: XXX'
)
}
let!
(
:project_internal_snippet
)
{
create
(
:snippet
,
:internal
,
project:
project
,
content:
'password: XXX'
)
}
let!
(
:project_private_snippet
)
{
create
(
:snippet
,
:private
,
project:
project
,
content:
'password: XXX'
)
}
let_it_be
(
:project_public_snippet
)
{
create
(
:snippet
,
:public
,
project:
project
,
title:
'Foo Bar Title'
)
}
let_it_be
(
:project_internal_snippet
)
{
create
(
:snippet
,
:internal
,
project:
project
,
title:
'Foo Bar Title'
)
}
let_it_be
(
:project_private_snippet
)
{
create
(
:snippet
,
:private
,
project:
project
,
title:
'Foo Bar Title'
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
describe
'#execute'
do
context
'unauthenticated'
do
it
'returns public snippets only'
do
search
=
described_class
.
new
(
nil
,
search:
'
password
'
)
search
=
described_class
.
new
(
nil
,
search:
'
bar
'
)
results
=
search
.
execute
expect
(
results
.
objects
(
'snippet_
blob
s'
)).
to
match_array
[
public_snippet
,
project_public_snippet
]
expect
(
results
.
objects
(
'snippet_
title
s'
)).
to
match_array
[
public_snippet
,
project_public_snippet
]
end
end
context
'authenticated'
do
it
'returns only public & internal snippets for regular users'
do
user
=
create
(
:user
)
search
=
described_class
.
new
(
user
,
search:
'password'
)
search
=
described_class
.
new
(
user
,
search:
'bar'
)
results
=
search
.
execute
expect
(
results
.
objects
(
'snippet_
blob
s'
)).
to
match_array
[
public_snippet
,
internal_snippet
,
project_public_snippet
,
project_internal_snippet
]
expect
(
results
.
objects
(
'snippet_
title
s'
)).
to
match_array
[
public_snippet
,
internal_snippet
,
project_public_snippet
,
project_internal_snippet
]
end
it
'returns public, internal snippets and project private snippets for project members'
do
member
=
create
(
:user
)
project
.
add_developer
(
member
)
search
=
described_class
.
new
(
member
,
search:
'password'
)
project
.
add_developer
(
user
)
search
=
described_class
.
new
(
user
,
search:
'bar'
)
results
=
search
.
execute
expect
(
results
.
objects
(
'snippet_
blob
s'
)).
to
match_array
[
public_snippet
,
internal_snippet
,
project_public_snippet
,
project_internal_snippet
,
project_private_snippet
]
expect
(
results
.
objects
(
'snippet_
title
s'
)).
to
match_array
[
public_snippet
,
internal_snippet
,
project_public_snippet
,
project_internal_snippet
,
project_private_snippet
]
end
it
'returns public, internal and private snippets where user is the author'
do
search
=
described_class
.
new
(
author
,
search:
'
password
'
)
search
=
described_class
.
new
(
author
,
search:
'
bar
'
)
results
=
search
.
execute
expect
(
results
.
objects
(
'snippet_
blob
s'
)).
to
match_array
[
public_snippet
,
internal_snippet
,
private_snippet
,
project_public_snippet
,
project_internal_snippet
]
expect
(
results
.
objects
(
'snippet_
title
s'
)).
to
match_array
[
public_snippet
,
internal_snippet
,
private_snippet
,
project_public_snippet
,
project_internal_snippet
]
end
it
'returns all snippets when user is admin'
do
admin
=
create
(
:admin
)
search
=
described_class
.
new
(
admin
,
search:
'
password
'
)
search
=
described_class
.
new
(
admin
,
search:
'
bar
'
)
results
=
search
.
execute
expect
(
results
.
objects
(
'snippet_
blob
s'
)).
to
match_array
[
public_snippet
,
internal_snippet
,
private_snippet
,
project_public_snippet
,
project_internal_snippet
,
project_private_snippet
]
expect
(
results
.
objects
(
'snippet_
title
s'
)).
to
match_array
[
public_snippet
,
internal_snippet
,
private_snippet
,
project_public_snippet
,
project_internal_snippet
,
project_private_snippet
]
end
end
end
describe
'#scope'
do
it
'always scopes to snippet_titles'
do
search
=
described_class
.
new
(
user
,
search:
'bar'
)
expect
(
search
.
scope
).
to
eq
'snippet_titles'
end
end
end
spec/services/search_service_spec.rb
浏览文件 @
e357d495
...
...
@@ -151,7 +151,7 @@ describe SearchService do
it
'returns the default scope'
do
scope
=
described_class
.
new
(
user
,
snippets:
'true'
,
scope:
'projects'
).
scope
expect
(
scope
).
to
eq
'snippet_
blob
s'
expect
(
scope
).
to
eq
'snippet_
title
s'
end
end
...
...
@@ -159,7 +159,7 @@ describe SearchService do
it
'returns the default scope'
do
scope
=
described_class
.
new
(
user
,
snippets:
'true'
).
scope
expect
(
scope
).
to
eq
'snippet_
blob
s'
expect
(
scope
).
to
eq
'snippet_
title
s'
end
end
end
...
...
@@ -222,7 +222,7 @@ describe SearchService do
search_results
=
described_class
.
new
(
user
,
snippets:
'true'
,
search:
snippet
.
content
).
search_results
search:
snippet
.
title
).
search_results
expect
(
search_results
).
to
be_a
Gitlab
::
SnippetSearchResults
end
...
...
@@ -270,7 +270,7 @@ describe SearchService do
search_objects
=
described_class
.
new
(
user
,
snippets:
'true'
,
search:
snippet
.
content
).
search_objects
search:
snippet
.
title
).
search_objects
expect
(
search_objects
.
first
).
to
eq
snippet
end
...
...
@@ -383,7 +383,7 @@ describe SearchService do
let
(
:readable
)
{
create
(
:project_snippet
,
project:
accessible_project
)
}
let
(
:unreadable
)
{
create
(
:project_snippet
,
project:
inaccessible_project
)
}
let
(
:unredacted_results
)
{
ar_relation
(
ProjectSnippet
,
readable
,
unreadable
)
}
let
(
:scope
)
{
'snippet_
blob
s'
}
let
(
:scope
)
{
'snippet_
title
s'
}
it
'redacts the inaccessible snippet'
do
expect
(
result
).
to
contain_exactly
(
readable
)
...
...
@@ -394,7 +394,7 @@ describe SearchService do
let
(
:readable
)
{
create
(
:personal_snippet
,
:private
,
author:
user
)
}
let
(
:unreadable
)
{
create
(
:personal_snippet
,
:private
)
}
let
(
:unredacted_results
)
{
ar_relation
(
PersonalSnippet
,
readable
,
unreadable
)
}
let
(
:scope
)
{
'snippet_
blob
s'
}
let
(
:scope
)
{
'snippet_
title
s'
}
it
'redacts the inaccessible snippet'
do
expect
(
result
).
to
contain_exactly
(
readable
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录