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
c3b489bd
Commit
c3b489bd
authored
Mar 18, 2018
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for concurrent insert situation.
parent
e7393191
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
spec/models/internal_id_spec.rb
spec/models/internal_id_spec.rb
+13
-0
No files found.
spec/models/internal_id_spec.rb
View file @
c3b489bd
...
...
@@ -38,6 +38,19 @@ describe InternalId do
expect
(
subject
).
to
eq
(
project
.
issues
.
size
+
1
)
end
end
context
'with concurrent inserts on table'
do
it
'looks up the record if it was created concurrently'
do
args
=
{
**
scope
,
usage:
described_class
.
usages
[
usage
.
to_s
]
}
record
=
double
expect
(
described_class
).
to
receive
(
:find_by
).
with
(
args
).
and_return
(
nil
)
# first call, record not present
expect
(
described_class
).
to
receive
(
:find_by
).
with
(
args
).
and_return
(
record
)
# second call, record was created by another process
expect
(
described_class
).
to
receive
(
:create!
).
and_raise
(
ActiveRecord
::
RecordNotUnique
,
'record not unique'
)
expect
(
record
).
to
receive
(
:increment_and_save!
)
subject
end
end
end
it
'generates a strictly monotone, gapless sequence'
do
...
...
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