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
c174fadc
Commit
c174fadc
authored
Mar 15, 2018
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move EE-only elasticsearch specs in spec/requests/api/search_spec.rb
parent
5a7a3f42
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
117 additions
and
98 deletions
+117
-98
ee/spec/requests/api/search_spec.rb
ee/spec/requests/api/search_spec.rb
+115
-0
spec/requests/api/search_spec.rb
spec/requests/api/search_spec.rb
+2
-98
No files found.
ee/spec/requests/api/search_spec.rb
0 → 100644
View file @
c174fadc
require
'spec_helper'
describe
API
::
Search
do
set
(
:user
)
{
create
(
:user
)
}
set
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
name:
'awesome project'
,
group:
group
)
}
let
(
:repo_project
)
{
create
(
:project
,
:public
,
:repository
,
group:
group
)
}
shared_examples
'response is correct'
do
|
schema
:,
size:
1
|
it
{
expect
(
response
).
to
have_gitlab_http_status
(
200
)
}
it
{
expect
(
response
).
to
match_response_schema
(
schema
)
}
it
{
expect
(
response
).
to
include_limited_pagination_headers
}
it
{
expect
(
json_response
.
size
).
to
eq
(
size
)
}
end
shared_examples
'elasticsearch disabled'
do
it
'returns 400 error for wiki_blobs scope'
do
get
api
(
endpoint
,
user
),
scope:
'wiki_blobs'
,
search:
'awesome'
expect
(
response
).
to
have_gitlab_http_status
(
400
)
end
it
'returns 400 error for blobs scope'
do
get
api
(
endpoint
,
user
),
scope:
'blobs'
,
search:
'monitors'
expect
(
response
).
to
have_gitlab_http_status
(
400
)
end
it
'returns 400 error for commits scope'
do
get
api
(
endpoint
,
user
),
scope:
'commits'
,
search:
'folder'
expect
(
response
).
to
have_gitlab_http_status
(
400
)
end
end
shared_examples
'elasticsearch enabled'
do
before
do
stub_ee_application_setting
(
elasticsearch_search:
true
,
elasticsearch_indexing:
true
)
Gitlab
::
Elastic
::
Helper
.
create_empty_index
end
after
do
Gitlab
::
Elastic
::
Helper
.
delete_index
stub_ee_application_setting
(
elasticsearch_search:
false
,
elasticsearch_indexing:
false
)
end
context
'for wiki_blobs scope'
do
before
do
wiki
=
create
(
:project_wiki
,
project:
project
)
create
(
:wiki_page
,
wiki:
wiki
,
attrs:
{
title:
'home'
,
content:
"Awesome page"
})
project
.
wiki
.
index_blobs
Gitlab
::
Elastic
::
Helper
.
refresh_index
get
api
(
endpoint
,
user
),
scope:
'wiki_blobs'
,
search:
'awesome'
end
it_behaves_like
'response is correct'
,
schema:
'public_api/v4/blobs'
end
context
'for commits scope'
do
before
do
repo_project
.
repository
.
index_commits
Gitlab
::
Elastic
::
Helper
.
refresh_index
get
api
(
endpoint
,
user
),
scope:
'commits'
,
search:
'folder'
end
it_behaves_like
'response is correct'
,
schema:
'public_api/v4/commits_details'
,
size:
2
end
context
'for blobs scope'
do
before
do
repo_project
.
repository
.
index_blobs
Gitlab
::
Elastic
::
Helper
.
refresh_index
get
api
(
endpoint
,
user
),
scope:
'blobs'
,
search:
'monitors'
end
it_behaves_like
'response is correct'
,
schema:
'public_api/v4/blobs'
end
end
describe
'GET /search'
do
context
'with correct params'
do
context
'when elasticsearch is disabled'
do
it_behaves_like
'elasticsearch disabled'
do
let
(
:endpoint
)
{
'/search'
}
end
end
context
'when elasticsearch is enabled'
do
it_behaves_like
'elasticsearch enabled'
do
let
(
:endpoint
)
{
'/search'
}
end
end
end
end
describe
"GET /groups/:id/-/search"
do
context
'with correct params'
do
context
'when elasticsearch is disabled'
do
it_behaves_like
'elasticsearch disabled'
do
let
(
:endpoint
)
{
"/groups/
#{
group
.
id
}
/-/search"
}
end
end
context
'when elasticsearch is enabled'
do
it_behaves_like
'elasticsearch enabled'
do
let
(
:endpoint
)
{
"/groups/
#{
group
.
id
}
/-/search"
}
end
end
end
end
end
spec/requests/api/search_spec.rb
View file @
c174fadc
...
@@ -3,8 +3,8 @@ require 'spec_helper'
...
@@ -3,8 +3,8 @@ require 'spec_helper'
describe
API
::
Search
do
describe
API
::
Search
do
set
(
:user
)
{
create
(
:user
)
}
set
(
:user
)
{
create
(
:user
)
}
set
(
:group
)
{
create
(
:group
)
}
set
(
:group
)
{
create
(
:group
)
}
l
et
(
:project
)
{
create
(
:project
,
:public
,
name:
'awesome project'
,
group:
group
)
}
s
et
(
:project
)
{
create
(
:project
,
:public
,
name:
'awesome project'
,
group:
group
)
}
l
et
(
:repo_project
)
{
create
(
:project
,
:public
,
:repository
,
group:
group
)
}
s
et
(
:repo_project
)
{
create
(
:project
,
:public
,
:repository
,
group:
group
)
}
shared_examples
'response is correct'
do
|
schema
:,
size:
1
|
shared_examples
'response is correct'
do
|
schema
:,
size:
1
|
it
{
expect
(
response
).
to
have_gitlab_http_status
(
200
)
}
it
{
expect
(
response
).
to
have_gitlab_http_status
(
200
)
}
...
@@ -13,74 +13,6 @@ describe API::Search do
...
@@ -13,74 +13,6 @@ describe API::Search do
it
{
expect
(
json_response
.
size
).
to
eq
(
size
)
}
it
{
expect
(
json_response
.
size
).
to
eq
(
size
)
}
end
end
shared_examples
'elasticsearch disabled'
do
it
'returns 400 error for wiki_blobs scope'
do
get
api
(
endpoint
,
user
),
scope:
'wiki_blobs'
,
search:
'awesome'
expect
(
response
).
to
have_gitlab_http_status
(
400
)
end
it
'returns 400 error for blobs scope'
do
get
api
(
endpoint
,
user
),
scope:
'blobs'
,
search:
'monitors'
expect
(
response
).
to
have_gitlab_http_status
(
400
)
end
it
'returns 400 error for commits scope'
do
get
api
(
endpoint
,
user
),
scope:
'commits'
,
search:
'folder'
expect
(
response
).
to
have_gitlab_http_status
(
400
)
end
end
shared_examples
'elasticsearch enabled'
do
before
do
stub_ee_application_setting
(
elasticsearch_search:
true
,
elasticsearch_indexing:
true
)
Gitlab
::
Elastic
::
Helper
.
create_empty_index
end
after
do
Gitlab
::
Elastic
::
Helper
.
delete_index
stub_ee_application_setting
(
elasticsearch_search:
false
,
elasticsearch_indexing:
false
)
end
context
'for wiki_blobs scope'
do
before
do
wiki
=
create
(
:project_wiki
,
project:
project
)
create
(
:wiki_page
,
wiki:
wiki
,
attrs:
{
title:
'home'
,
content:
"Awesome page"
})
project
.
wiki
.
index_blobs
Gitlab
::
Elastic
::
Helper
.
refresh_index
get
api
(
endpoint
,
user
),
scope:
'wiki_blobs'
,
search:
'awesome'
end
it_behaves_like
'response is correct'
,
schema:
'public_api/v4/blobs'
end
context
'for commits scope'
do
before
do
repo_project
.
repository
.
index_commits
Gitlab
::
Elastic
::
Helper
.
refresh_index
get
api
(
endpoint
,
user
),
scope:
'commits'
,
search:
'folder'
end
it_behaves_like
'response is correct'
,
schema:
'public_api/v4/commits_details'
,
size:
2
end
context
'for blobs scope'
do
before
do
repo_project
.
repository
.
index_blobs
Gitlab
::
Elastic
::
Helper
.
refresh_index
get
api
(
endpoint
,
user
),
scope:
'blobs'
,
search:
'monitors'
end
it_behaves_like
'response is correct'
,
schema:
'public_api/v4/blobs'
end
end
describe
'GET /search'
do
describe
'GET /search'
do
context
'when user is not authenticated'
do
context
'when user is not authenticated'
do
it
'returns 401 error'
do
it
'returns 401 error'
do
...
@@ -109,8 +41,6 @@ describe API::Search do
...
@@ -109,8 +41,6 @@ describe API::Search do
context
'with correct params'
do
context
'with correct params'
do
context
'for projects scope'
do
context
'for projects scope'
do
before
do
before
do
project
get
api
(
'/search'
,
user
),
scope:
'projects'
,
search:
'awesome'
get
api
(
'/search'
,
user
),
scope:
'projects'
,
search:
'awesome'
end
end
...
@@ -166,18 +96,6 @@ describe API::Search do
...
@@ -166,18 +96,6 @@ describe API::Search do
it_behaves_like
'response is correct'
,
schema:
'public_api/v4/snippets'
it_behaves_like
'response is correct'
,
schema:
'public_api/v4/snippets'
end
end
context
'when elasticsearch is disabled'
do
it_behaves_like
'elasticsearch disabled'
do
let
(
:endpoint
)
{
'/search'
}
end
end
context
'when elasticsearch is enabled'
do
it_behaves_like
'elasticsearch enabled'
do
let
(
:endpoint
)
{
'/search'
}
end
end
end
end
end
end
...
@@ -227,8 +145,6 @@ describe API::Search do
...
@@ -227,8 +145,6 @@ describe API::Search do
context
'with correct params'
do
context
'with correct params'
do
context
'for projects scope'
do
context
'for projects scope'
do
before
do
before
do
project
get
api
(
"/groups/
#{
group
.
id
}
/-/search"
,
user
),
scope:
'projects'
,
search:
'awesome'
get
api
(
"/groups/
#{
group
.
id
}
/-/search"
,
user
),
scope:
'projects'
,
search:
'awesome'
end
end
...
@@ -276,18 +192,6 @@ describe API::Search do
...
@@ -276,18 +192,6 @@ describe API::Search do
it_behaves_like
'response is correct'
,
schema:
'public_api/v4/milestones'
it_behaves_like
'response is correct'
,
schema:
'public_api/v4/milestones'
end
end
context
'when elasticsearch is disabled'
do
it_behaves_like
'elasticsearch disabled'
do
let
(
:endpoint
)
{
"/groups/
#{
group
.
id
}
/-/search"
}
end
end
context
'when elasticsearch is enabled'
do
it_behaves_like
'elasticsearch enabled'
do
let
(
:endpoint
)
{
"/groups/
#{
group
.
id
}
/-/search"
}
end
end
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