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
571a889d
Commit
571a889d
authored
Aug 03, 2021
by
Mehmet Emin INAC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add regression test for leaking scope of each_batch
parent
1ddc8297
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
spec/models/concerns/each_batch_spec.rb
spec/models/concerns/each_batch_spec.rb
+13
-0
No files found.
spec/models/concerns/each_batch_spec.rb
View file @
571a889d
...
...
@@ -9,6 +9,8 @@ RSpec.describe EachBatch do
include
EachBatch
self
.
table_name
=
'users'
scope
:never_signed_in
,
->
{
where
(
sign_in_count:
0
)
}
end
end
...
...
@@ -72,5 +74,16 @@ RSpec.describe EachBatch do
expect
(
ids
).
to
eq
(
ids
.
sort
.
reverse
)
end
describe
'current scope'
do
let
(
:entry
)
{
create
(
:user
,
sign_in_count:
1
)
}
let
(
:ids_with_new_relation
)
{
model
.
where
(
id:
entry
.
id
).
pluck
(
:id
)
}
it
'does not leak current scope to block being executed'
do
model
.
never_signed_in
.
each_batch
(
of:
5
)
do
|
relation
|
expect
(
ids_with_new_relation
).
to
include
(
entry
.
id
)
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