Commit b1a8fb0c authored by Adam Hegyi's avatar Adam Hegyi

Merge branch '205597-start-code-review-on-assign-part-2' into 'master'

Resolve "Start code review on assigning a MR to someone other than the author"

Closes #205597

See merge request gitlab-org/gitlab!26891
parents 057e8d5a 977a5e85
......@@ -7,7 +7,7 @@ module EE
class_methods do
def review_time_field
@review_time_field ||= Arel.sql("LEAST(merge_request_metrics.first_comment_at, merge_request_metrics.first_approved_at)")
@review_time_field ||= Arel.sql("LEAST(merge_request_metrics.first_comment_at, merge_request_metrics.first_approved_at, merge_request_metrics.first_reassigned_at)")
end
end
......@@ -18,7 +18,7 @@ module EE
end
def review_start_at
[first_comment_at, first_approved_at].compact.min
[first_comment_at, first_approved_at, first_reassigned_at].compact.min
end
def review_end_at
......
---
title: Consider MR reassign as code review start
merge_request: 26891
author:
type: changed
......@@ -4,11 +4,12 @@ require 'spec_helper'
describe MergeRequest::Metrics do
describe '#review_start_at' do
it 'is the earliest date from first_comment_at or first_approved_at' do
subject.first_approved_at = 1.day.ago
subject.first_comment_at = 1.hour.ago
it 'is the earliest date from first_comment_at, first_approved_at or first_reassigned_at' do
subject.first_approved_at = 1.hour.ago
subject.first_comment_at = 1.day.ago
subject.first_reassigned_at = 1.week.ago
expect(subject.review_start_at).to be_like_time(1.day.ago)
expect(subject.review_start_at).to be_like_time(1.week.ago)
end
context 'when all review start candidates are nil' do
......@@ -20,6 +21,7 @@ describe MergeRequest::Metrics do
context 'when one of review start candidates is nil' do
it 'is earliest date from non-nil values' do
subject.first_approved_at = 1.day.ago
subject.first_reassigned_at = 1.hour.ago
expect(subject.review_start_at).to be_like_time(1.day.ago)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment