debian-mirror-gitlab/app/models/concerns/merge_request_reviewer_state.rb

28 lines
554 B
Ruby
Raw Normal View History

2021-12-11 22:18:48 +05:30
# frozen_string_literal: true
module MergeRequestReviewerState
extend ActiveSupport::Concern
included do
enum state: {
unreviewed: 0,
reviewed: 1,
attention_requested: 2
}
validates :state,
presence: true,
inclusion: { in: self.states.keys }
2022-05-07 20:08:51 +05:30
belongs_to :updated_state_by, class_name: 'User', foreign_key: :updated_state_by_user_id
2021-12-11 22:18:48 +05:30
after_initialize :set_state, unless: :persisted?
2022-05-07 20:08:51 +05:30
def attention_requested_by
return unless attention_requested?
updated_state_by
end
2021-12-11 22:18:48 +05:30
end
end