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
02717c38
Commit
02717c38
authored
Aug 16, 2016
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ES] Rspec for code that used delete-by-query plugin
parent
2dfb8722
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
2 deletions
+85
-2
.gitlab-ci.yml
.gitlab-ci.yml
+2
-2
spec/support/webmock.rb
spec/support/webmock.rb
+1
-0
spec/workers/elastic_indexer_worker_spec.rb
spec/workers/elastic_indexer_worker_spec.rb
+82
-0
No files found.
.gitlab-ci.yml
View file @
02717c38
...
...
@@ -10,7 +10,7 @@ variables:
MYSQL_ALLOW_EMPTY_PASSWORD
:
"
1"
# retry tests only in CI environment
RSPEC_RETRY_RETRY_COUNT
:
"
3"
ELASTIC_HOST
:
"
elasticsearch
"
ELASTIC_HOST
:
"
registry.gitlab.com__gitlab-org__test-elastic-image
"
RAILS_ENV
:
"
test"
SIMPLECOV
:
"
true"
USE_DB
:
"
true"
...
...
@@ -71,7 +71,7 @@ update-knapsack:
services
:
-
mysql:latest
-
redis:alpine
-
elasticsearch:latest
-
registry.gitlab.com/gitlab-org/test-elastic-image
.rspec-knapsack
:
&rspec-knapsack
stage
:
test
...
...
spec/support/webmock.rb
View file @
02717c38
...
...
@@ -2,3 +2,4 @@ require 'webmock'
require
'webmock/rspec'
WebMock
.
disable_net_connect!
(
allow_localhost:
true
,
allow:
'elasticsearch'
)
WebMock
.
disable_net_connect!
(
allow_localhost:
true
,
allow:
'registry.gitlab.com__gitlab-org__test-elastic-image'
)
spec/workers/elastic_indexer_worker_spec.rb
View file @
02717c38
...
...
@@ -121,5 +121,87 @@ describe ElasticIndexerWorker, elastic: true do
end
.
to
change
{
Elasticsearch
::
Model
.
search
(
'new'
).
records
.
size
}.
by
(
1
)
end
end
describe
'Delete'
do
it
'deletes a project with all nested objects'
do
project
=
create
:project
subject
.
perform
(
"index"
,
"Project"
,
project
.
id
)
issue
=
create
:issue
,
project:
project
subject
.
perform
(
"index"
,
"Issue"
,
issue
.
id
)
milestone
=
create
:milestone
,
project:
project
subject
.
perform
(
"index"
,
"Milestone"
,
milestone
.
id
)
note
=
create
:note
,
project:
project
subject
.
perform
(
"index"
,
"Note"
,
note
.
id
)
merge_request
=
create
:merge_request
,
target_project:
project
,
source_project:
project
subject
.
perform
(
"index"
,
"MergeRequest"
,
merge_request
.
id
)
ElasticCommitIndexerWorker
.
new
.
perform
(
project
.
id
)
Gitlab
::
Elastic
::
Helper
.
refresh_index
## All database objects + data from repository. The absolute value does not matter
expect
(
Elasticsearch
::
Model
.
search
(
'*'
).
total_count
).
to
be
>
40
subject
.
perform
(
"delete"
,
"Project"
,
project
.
id
)
Gitlab
::
Elastic
::
Helper
.
refresh_index
expect
(
Elasticsearch
::
Model
.
search
(
'*'
).
total_count
).
to
be
(
0
)
end
it
'deletes an issue'
do
issue
=
create
:issue
subject
.
perform
(
"index"
,
"Issue"
,
issue
.
id
)
Gitlab
::
Elastic
::
Helper
.
refresh_index
issue
.
destroy
expect
do
subject
.
perform
(
"delete"
,
"Issue"
,
issue
.
id
,
"project_id"
=>
issue
.
project_id
)
Gitlab
::
Elastic
::
Helper
.
refresh_index
end
.
to
change
{
Elasticsearch
::
Model
.
search
(
'*'
).
total_count
}.
by
(
-
1
)
end
it
'deletes a note'
do
note
=
create
:note
subject
.
perform
(
"index"
,
"Note"
,
note
.
id
)
Gitlab
::
Elastic
::
Helper
.
refresh_index
note
.
destroy
expect
do
subject
.
perform
(
"delete"
,
"Note"
,
note
.
id
,
"project_id"
=>
note
.
project_id
)
Gitlab
::
Elastic
::
Helper
.
refresh_index
end
.
to
change
{
Elasticsearch
::
Model
.
search
(
'*'
).
total_count
}.
by
(
-
1
)
end
it
'deletes a milestone'
do
milestone
=
create
:milestone
subject
.
perform
(
"index"
,
"Milestone"
,
milestone
.
id
)
Gitlab
::
Elastic
::
Helper
.
refresh_index
milestone
.
destroy
expect
do
subject
.
perform
(
"delete"
,
"Milestone"
,
milestone
.
id
,
"project_id"
=>
milestone
.
project_id
)
Gitlab
::
Elastic
::
Helper
.
refresh_index
end
.
to
change
{
Elasticsearch
::
Model
.
search
(
'*'
).
total_count
}.
by
(
-
1
)
end
it
'deletes a merge request'
do
merge_request
=
create
:merge_request
subject
.
perform
(
"index"
,
"MergeRequest"
,
merge_request
.
id
)
Gitlab
::
Elastic
::
Helper
.
refresh_index
merge_request
.
destroy
expect
do
subject
.
perform
(
"delete"
,
"MergeRequest"
,
merge_request
.
id
,
"project_id"
=>
merge_request
.
target_project_id
)
Gitlab
::
Elastic
::
Helper
.
refresh_index
end
.
to
change
{
Elasticsearch
::
Model
.
search
(
'*'
).
total_count
}.
by
(
-
1
)
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