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
b4c09c03
Commit
b4c09c03
authored
May 07, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
184d252b
5925b5bb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
11 deletions
+37
-11
config/initializers/config_initializers_active_record_locking.rb
...initializers/config_initializers_active_record_locking.rb
+5
-1
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+16
-5
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+16
-5
No files found.
config/initializers/config_initializers_active_record_locking.rb
View file @
b4c09c03
# frozen_string_literal: true
# ensure ActiveRecord's version has been required already
require
'active_record/locking/optimistic'
# rubocop:disable Lint/RescueException
module
ActiveRecord
module
Locking
...
...
@@ -16,7 +20,7 @@ module ActiveRecord
self
[
locking_column
]
+=
1
# Patched because when `lock_version` is read as `0`, it may actually be `NULL` in the DB.
possible_previous_lock_value
=
previous_lock_value
==
0
?
[
nil
,
0
]
:
previous_lock_value
possible_previous_lock_value
=
previous_lock_value
.
to_i
==
0
?
[
nil
,
0
]
:
previous_lock_value
affected_rows
=
self
.
class
.
unscoped
.
_update_record
(
arel_attributes_with_values
(
attribute_names
),
...
...
spec/models/issue_spec.rb
View file @
b4c09c03
...
...
@@ -56,16 +56,27 @@ describe Issue do
end
describe
'locking'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:lock_version
)
do
[
[
0
],
[
"0"
]
]
end
with_them
do
it
'works when an issue has a NULL lock_version'
do
issue
=
create
(
:issue
)
described_class
.
where
(
id:
issue
.
id
).
update_all
(
'lock_version = NULL'
)
issue
.
update!
(
lock_version:
0
,
title:
'locking test'
)
issue
.
update!
(
lock_version:
lock_version
,
title:
'locking test'
)
expect
(
issue
.
reload
.
title
).
to
eq
(
'locking test'
)
end
end
end
describe
'#order_by_position_and_priority'
do
let
(
:project
)
{
create
:project
}
...
...
spec/models/merge_request_spec.rb
View file @
b4c09c03
...
...
@@ -32,16 +32,27 @@ describe MergeRequest do
end
describe
'locking'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:lock_version
)
do
[
[
0
],
[
"0"
]
]
end
with_them
do
it
'works when a merge request has a NULL lock_version'
do
merge_request
=
create
(
:merge_request
)
described_class
.
where
(
id:
merge_request
.
id
).
update_all
(
'lock_version = NULL'
)
merge_request
.
update!
(
lock_version:
0
,
title:
'locking test'
)
merge_request
.
update!
(
lock_version:
lock_version
,
title:
'locking test'
)
expect
(
merge_request
.
reload
.
title
).
to
eq
(
'locking test'
)
end
end
end
describe
'#squash_in_progress?'
do
let
(
:repo_path
)
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