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
89a63467
Commit
89a63467
authored
Mar 07, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'more_es_specs' into 'master'
More ES specs See merge request !239
parents
38204052
b0ddc20e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
24 deletions
+118
-24
spec/lib/gitlab/elastic/search_results_spec.rb
spec/lib/gitlab/elastic/search_results_spec.rb
+118
-24
No files found.
spec/lib/gitlab/elastic/search_results_spec.rb
View file @
89a63467
...
...
@@ -3,14 +3,10 @@ require 'spec_helper'
describe
Gitlab
::
Elastic
::
SearchResults
,
lib:
true
do
before
do
allow
(
Gitlab
.
config
.
elasticsearch
).
to
receive
(
:enabled
).
and_return
(
true
)
Issue
.
__elasticsearch__
.
create_index!
MergeRequest
.
__elasticsearch__
.
create_index!
end
after
do
allow
(
Gitlab
.
config
.
elasticsearch
).
to
receive
(
:enabled
).
and_return
(
false
)
Issue
.
__elasticsearch__
.
delete_index!
MergeRequest
.
__elasticsearch__
.
delete_index!
end
let
(
:project_1
)
{
create
(
:project
)
}
...
...
@@ -18,21 +14,43 @@ describe Gitlab::Elastic::SearchResults, lib: true do
let
(
:limit_project_ids
)
{
[
project_1
.
id
]
}
describe
'issues'
do
let!
(
:issue_1
)
{
create
(
:issue
,
project:
project_1
,
title:
'Hello world, here I am!'
,
iid:
1
)
}
let!
(
:issue_2
)
{
create
(
:issue
,
project:
project_1
,
title:
'Issue 2'
,
description:
'Hello world, here I am!'
,
iid:
2
)
}
let!
(
:issue_3
)
{
create
(
:issue
,
project:
project_2
,
title:
'Issue 3'
,
iid:
2
)
}
before
do
Issue
.
__elasticsearch__
.
create_index!
@issue_1
=
create
(
:issue
,
project:
project_1
,
title:
'Hello world, here I am!'
,
iid:
1
)
@issue_2
=
create
(
:issue
,
project:
project_1
,
title:
'Issue 2'
,
description:
'Hello world, here I am!'
,
iid:
2
)
@issue_3
=
create
(
:issue
,
project:
project_2
,
title:
'Issue 3'
,
iid:
2
)
Issue
.
__elasticsearch__
.
refresh_index!
end
after
do
Issue
.
__elasticsearch__
.
delete_index!
end
it
'should list issues that title or description contain the query'
do
results
=
described_class
.
new
(
limit_project_ids
,
'hello world'
)
issues
=
results
.
objects
(
'issues'
)
expect
(
issues
).
to
include
issue_1
expect
(
issues
).
to
include
issue_2
expect
(
issues
).
not_to
include
issue_3
expect
(
issues
).
to
include
@
issue_1
expect
(
issues
).
to
include
@
issue_2
expect
(
issues
).
not_to
include
@
issue_3
expect
(
results
.
issues_count
).
to
eq
2
end
...
...
@@ -47,9 +65,9 @@ describe Gitlab::Elastic::SearchResults, lib: true do
results
=
described_class
.
new
(
limit_project_ids
,
'#2'
)
issues
=
results
.
objects
(
'issues'
)
expect
(
issues
).
not_to
include
issue_1
expect
(
issues
).
to
include
issue_2
expect
(
issues
).
not_to
include
issue_3
expect
(
issues
).
not_to
include
@
issue_1
expect
(
issues
).
to
include
@
issue_2
expect
(
issues
).
not_to
include
@
issue_3
expect
(
results
.
issues_count
).
to
eq
1
end
...
...
@@ -62,21 +80,47 @@ describe Gitlab::Elastic::SearchResults, lib: true do
end
describe
'merge requests'
do
let!
(
:merge_request_1
)
{
create
(
:merge_request
,
source_project:
project_1
,
target_project:
project_1
,
title:
'Hello world, here I am!'
,
iid:
1
)
}
let!
(
:merge_request_2
)
{
create
(
:merge_request
,
:conflict
,
source_project:
project_1
,
target_project:
project_1
,
title:
'Merge Request 2'
,
description:
'Hello world, here I am!'
,
iid:
2
)
}
let!
(
:merge_request_3
)
{
create
(
:merge_request
,
source_project:
project_2
,
target_project:
project_2
,
title:
'Merge Request 3'
,
iid:
2
)
}
before
do
MergeRequest
.
__elasticsearch__
.
create_index!
@merge_request_1
=
create
(
:merge_request
,
source_project:
project_1
,
target_project:
project_1
,
title:
'Hello world, here I am!'
,
iid:
1
)
@merge_request_2
=
create
(
:merge_request
,
:conflict
,
source_project:
project_1
,
target_project:
project_1
,
title:
'Merge Request 2'
,
description:
'Hello world, here I am!'
,
iid:
2
)
@merge_request_3
=
create
(
:merge_request
,
source_project:
project_2
,
target_project:
project_2
,
title:
'Merge Request 3'
,
iid:
2
)
MergeRequest
.
__elasticsearch__
.
refresh_index!
end
after
do
MergeRequest
.
__elasticsearch__
.
delete_index!
end
it
'should list merge requests that title or description contain the query'
do
results
=
described_class
.
new
(
limit_project_ids
,
'hello world'
)
merge_requests
=
results
.
objects
(
'merge_requests'
)
expect
(
merge_requests
).
to
include
merge_request_1
expect
(
merge_requests
).
to
include
merge_request_2
expect
(
merge_requests
).
not_to
include
merge_request_3
expect
(
merge_requests
).
to
include
@
merge_request_1
expect
(
merge_requests
).
to
include
@
merge_request_2
expect
(
merge_requests
).
not_to
include
@
merge_request_3
expect
(
results
.
merge_requests_count
).
to
eq
2
end
...
...
@@ -91,9 +135,9 @@ describe Gitlab::Elastic::SearchResults, lib: true do
results
=
described_class
.
new
(
limit_project_ids
,
'#2'
)
merge_requests
=
results
.
objects
(
'merge_requests'
)
expect
(
merge_requests
).
not_to
include
merge_request_1
expect
(
merge_requests
).
to
include
merge_request_2
expect
(
merge_requests
).
not_to
include
merge_request_3
expect
(
merge_requests
).
not_to
include
@
merge_request_1
expect
(
merge_requests
).
to
include
@
merge_request_2
expect
(
merge_requests
).
not_to
include
@
merge_request_3
expect
(
results
.
merge_requests_count
).
to
eq
1
end
...
...
@@ -104,4 +148,54 @@ describe Gitlab::Elastic::SearchResults, lib: true do
expect
(
results
.
merge_requests_count
).
to
eq
0
end
end
describe
'project scoping'
do
before
do
[
Project
,
MergeRequest
,
Issue
,
Milestone
].
each
do
|
model
|
model
.
__elasticsearch__
.
create_index!
end
end
after
do
[
Project
,
MergeRequest
,
Issue
,
Milestone
].
each
do
|
model
|
model
.
__elasticsearch__
.
delete_index!
end
end
it
"returns items for project"
do
project
=
create
:project
,
name:
"term"
# Create issue
create
:issue
,
title:
'bla-bla term'
,
project:
project
create
:issue
,
description:
'bla-bla term'
,
project:
project
create
:issue
,
project:
project
# The issue I have no access to
create
:issue
,
title:
'bla-bla term'
# Create Merge Request
create
:merge_request
,
title:
'bla-bla term'
,
source_project:
project
create
:merge_request
,
description:
'term in description'
,
source_project:
project
,
target_branch:
"feature2"
create
:merge_request
,
source_project:
project
,
target_branch:
"feature3"
# The merge request you have no access to
create
:merge_request
,
title:
'also with term'
create
:milestone
,
title:
'bla-bla term'
,
project:
project
create
:milestone
,
description:
'bla-bla term'
,
project:
project
create
:milestone
,
project:
project
# The Milestone you have no access to
create
:milestone
,
title:
'bla-bla term'
[
Project
,
MergeRequest
,
Issue
,
Milestone
].
each
do
|
model
|
model
.
__elasticsearch__
.
refresh_index!
end
result
=
Gitlab
::
Elastic
::
SearchResults
.
new
([
project
.
id
],
'term'
)
expect
(
result
.
issues_count
).
to
eq
(
2
)
expect
(
result
.
merge_requests_count
).
to
eq
(
2
)
expect
(
result
.
milestones_count
).
to
eq
(
2
)
expect
(
result
.
projects_count
).
to
eq
(
1
)
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