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
bb910c3b
Commit
bb910c3b
authored
Mar 22, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make CI build to use optimistic locking only on status change
parent
d70f9c85
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
0 deletions
+44
-0
app/models/commit_status.rb
app/models/commit_status.rb
+4
-0
changelogs/unreleased/make-ci-build-to-lock-on-status-change.yml
...ogs/unreleased/make-ci-build-to-lock-on-status-change.yml
+4
-0
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+36
-0
No files found.
app/models/commit_status.rb
View file @
bb910c3b
...
...
@@ -105,6 +105,10 @@ class CommitStatus < ActiveRecord::Base
end
end
def
locking_enabled?
status_changed?
end
def
before_sha
pipeline
.
before_sha
||
Gitlab
::
Git
::
BLANK_SHA
end
...
...
changelogs/unreleased/make-ci-build-to-lock-on-status-change.yml
0 → 100644
View file @
bb910c3b
---
title
:
Make CI build to use optimistic locking only on status change
merge_request
:
author
:
spec/models/commit_status_spec.rb
View file @
bb910c3b
...
...
@@ -297,4 +297,40 @@ describe CommitStatus, :models do
end
end
end
describe
'#locking_enabled?'
do
before
do
commit_status
.
lock_version
=
100
end
subject
{
commit_status
.
locking_enabled?
}
context
"when changing status"
do
before
do
commit_status
.
status
=
"running"
end
it
"lock"
do
is_expected
.
to
be
true
end
it
"raise exception when trying to update"
do
expect
{
commit_status
.
save
}.
to
raise_error
(
ActiveRecord
::
StaleObjectError
)
end
end
context
"when changing description"
do
before
do
commit_status
.
description
=
"test"
end
it
"do not lock"
do
is_expected
.
to
be
false
end
it
"save correctly"
do
expect
(
commit_status
.
save
).
to
be
true
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