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
d9101085
Commit
d9101085
authored
Jan 20, 2021
by
Dmitry Gruzd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ActiveRecord::Records flaky spec
parent
c7627b8c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
27 deletions
+11
-27
ee/spec/lib/gem_extensions/elasticsearch/model/adapter/active_record/records_spec.rb
...elasticsearch/model/adapter/active_record/records_spec.rb
+11
-27
No files found.
ee/spec/lib/gem_extensions/elasticsearch/model/adapter/active_record/records_spec.rb
View file @
d9101085
...
...
@@ -3,39 +3,23 @@
require
'spec_helper'
RSpec
.
describe
Elasticsearch
::
Model
::
Adapter
::
ActiveRecord
::
Records
,
:elastic
do
before
do
stub_ee_application_setting
(
elasticsearch_indexing:
true
)
end
describe
'#records'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:search_options
)
{
{
options:
{
current_user:
user
,
project_ids: :any
}
}
}
before
do
stub_ee_application_setting
(
elasticsearch_indexing:
true
)
@middle_relevant
=
create
(
:issue
,
title:
'Sorting could improve'
,
# Some keywords in title
description:
'I think you could make it better'
)
@least_relevant
=
create
(
:issue
,
title:
'I love GitLab'
,
# No keywords in title
description:
'There is so much to love! For example, you could not possibly make sorting any better'
)
let
(
:search_options
)
{
{
options:
{
current_user:
user
,
project_ids: :any
,
order_by:
'created_at'
,
sort:
'desc'
}
}
}
let
(
:results
)
{
Issue
.
elastic_search
(
'*'
,
**
search_options
).
records
.
to_a
}
@most_relevant
=
create
(
:issue
,
title:
'Make sorting better'
,
# All keywords in title
description:
'This issue is here to make the sorting better'
)
let!
(
:new_issue
)
{
create
(
:issue
)
}
let!
(
:recent_issue
)
{
create
(
:issue
,
created_at:
1
.
hour
.
ago
)
}
let!
(
:old_issue
)
{
create
(
:issue
,
created_at:
7
.
days
.
ago
)
}
it
'returns results in the same sorted order as they come back from Elasticsearch'
do
ensure_elasticsearch_index!
end
it
'returns results in the same sorted order as they come back from Elasticsearch'
do
expect
(
Issue
.
elastic_search
(
'make sorting better'
,
**
search_options
).
records
.
to_a
).
to
eq
([
@most_relevant
,
@middle_relevant
,
@least_relevant
])
expect
(
results
).
to
eq
([
new_issue
,
recent_issue
,
old_issue
])
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