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
e24e5046
Commit
e24e5046
authored
Mar 21, 2020
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix match_id_and_lock_version scope
Fixes the scope so that it actually filters by id and lock version
parent
b15e631e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
app/models/commit_status.rb
app/models/commit_status.rb
+6
-3
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+13
-0
No files found.
app/models/commit_status.rb
View file @
e24e5046
...
...
@@ -62,13 +62,16 @@ class CommitStatus < ApplicationRecord
preload
(
project: :namespace
)
end
scope
:match_id_and_lock_version
,
->
(
slice
)
do
scope
:match_id_and_lock_version
,
->
(
items
)
do
# it expects that items are an array of attributes to match
# each hash needs to have `id` and `lock_version`
slice
.
inject
(
self
)
do
|
relation
,
item
|
match
=
CommitStatus
.
unscoped
.
where
(
item
.
slice
(
:id
,
:lock_version
))
or_conditions
=
items
.
inject
(
none
)
do
|
relation
,
item
|
match
=
CommitStatus
.
default_scoped
.
where
(
item
.
slice
(
:id
,
:lock_version
))
relation
.
or
(
match
)
end
merge
(
or_conditions
)
end
# We use `CommitStatusEnums.failure_reasons` here so that EE can more easily
...
...
spec/models/commit_status_spec.rb
View file @
e24e5046
...
...
@@ -449,6 +449,19 @@ describe CommitStatus do
end
end
describe
'.match_id_and_lock_version'
do
let
(
:status_1
)
{
create_status
(
lock_version:
1
)
}
let
(
:status_2
)
{
create_status
(
lock_version:
2
)
}
it
'returns statuses that match the given id and lock versions'
do
params
=
[
{
id:
status_1
.
id
,
lock_version:
1
},
{
id:
status_2
.
id
,
lock_version:
3
}
]
expect
(
described_class
.
match_id_and_lock_version
(
params
)).
to
contain_exactly
(
status_1
)
end
end
describe
'#before_sha'
do
subject
{
commit_status
.
before_sha
}
...
...
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