2021-10-25 09:12:21 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module MergeRequestReviewerState
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
enum state: {
|
|
|
|
unreviewed: 0,
|
|
|
|
reviewed: 1,
|
|
|
|
attention_required: 2
|
|
|
|
}
|
|
|
|
|
|
|
|
validates :state,
|
|
|
|
presence: true,
|
|
|
|
inclusion: { in: self.states.keys }
|
2021-11-03 06:10:20 +00:00
|
|
|
|
|
|
|
after_initialize :set_state, unless: :persisted?
|
|
|
|
|
|
|
|
def set_state
|
|
|
|
if Feature.enabled?(:mr_attention_requests, self.merge_request&.project, default_enabled: :yaml)
|
|
|
|
self.state = :attention_required
|
|
|
|
end
|
|
|
|
end
|
2021-10-25 09:12:21 +00:00
|
|
|
end
|
|
|
|
end
|