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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
f0df45fb
Commit
f0df45fb
authored
Jan 29, 2018
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix MR revert check when no merged_at is present
parent
f8dd398a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
16 deletions
+26
-16
app/models/merge_request.rb
app/models/merge_request.rb
+6
-6
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+20
-10
No files found.
app/models/merge_request.rb
View file @
f0df45fb
...
...
@@ -989,13 +989,13 @@ class MergeRequest < ActiveRecord::Base
merged_at
=
metrics
&
.
merged_at
notes_association
=
notes_with_associations
# It is not guaranteed that Note#created_at will be strictly later than
# MergeRequestMetric#merged_at. Nanoseconds on MySQL may break this
# comparison, as will a HA environment if clocks are not *precisely*
# synchronized. Add a minute's leeway to compensate for both possibilities
cutoff
=
merged_at
-
1
.
minute
if
merged_at
# It is not guaranteed that Note#created_at will be strictly later than
# MergeRequestMetric#merged_at. Nanoseconds on MySQL may break this
# comparison, as will a HA environment if clocks are not *precisely*
# synchronized. Add a minute's leeway to compensate for both possibilities
cutoff
=
merged_at
-
1
.
minute
notes_association
=
notes_association
.
where
(
'created_at >= ?'
,
cutoff
)
end
...
...
spec/models/merge_request_spec.rb
View file @
f0df45fb
...
...
@@ -1064,16 +1064,6 @@ describe MergeRequest do
end
describe
'#can_be_reverted?'
do
context
'when there is no merged_at for the MR'
do
before
do
subject
.
metrics
.
update!
(
merged_at:
nil
)
end
it
'returns false'
do
expect
(
subject
.
can_be_reverted?
(
nil
)).
to
be_falsey
end
end
context
'when there is no merge_commit for the MR'
do
before
do
subject
.
metrics
.
update!
(
merged_at:
Time
.
now
.
utc
)
...
...
@@ -1097,6 +1087,16 @@ describe MergeRequest do
end
end
context
'when there is no merged_at for the MR'
do
before
do
subject
.
metrics
.
update!
(
merged_at:
nil
)
end
it
'returns true'
do
expect
(
subject
.
can_be_reverted?
(
nil
)).
to
be_truthy
end
end
context
'when there is a revert commit'
do
let
(
:current_user
)
{
subject
.
author
}
let
(
:branch
)
{
subject
.
target_branch
}
...
...
@@ -1127,6 +1127,16 @@ describe MergeRequest do
end
end
context
'when there is no merged_at for the MR'
do
before
do
subject
.
metrics
.
update!
(
merged_at:
nil
)
end
it
'returns false'
do
expect
(
subject
.
can_be_reverted?
(
current_user
)).
to
be_falsey
end
end
context
'when the revert commit is mentioned in a note just before the MR was merged'
do
before
do
subject
.
notes
.
last
.
update!
(
created_at:
subject
.
metrics
.
merged_at
-
30
.
seconds
)
...
...
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