Commit 11cf2cd3 authored by Phil Hughes's avatar Phil Hughes

Adds DB column for merge request assignee state

This extra column will allow us to support the attention
request feature.
Also added a service to allow for this state column to be updated.

Changelog: added
parent 6fc25516
# 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 }
end
end
# frozen_string_literal: true
class MergeRequestAssignee < ApplicationRecord
include MergeRequestReviewerState
belongs_to :merge_request, touch: true
belongs_to :assignee, class_name: "User", foreign_key: :user_id, inverse_of: :merge_request_assignees
......
# frozen_string_literal: true
class MergeRequestReviewer < ApplicationRecord
enum state: {
unreviewed: 0,
reviewed: 1
}
validates :state,
presence: true,
inclusion: { in: MergeRequestReviewer.states.keys }
include MergeRequestReviewerState
belongs_to :merge_request
belongs_to :reviewer, class_name: 'User', foreign_key: :user_id, inverse_of: :merge_request_reviewers
......
# frozen_string_literal: true
class AddStateToMergeRequestAssignees < Gitlab::Database::Migration[1.0]
REVIEW_DEFAULT_STATE = 0
def change
add_column :merge_request_assignees, :state, :smallint, default: REVIEW_DEFAULT_STATE, null: false
end
end
713efc9673bc6cda8eff4e433c3c85f0cc4b8b8ca7b5cc4308e57a6d0b0040a0
\ No newline at end of file
......@@ -15699,7 +15699,8 @@ CREATE TABLE merge_request_assignees (
id bigint NOT NULL,
user_id integer NOT NULL,
merge_request_id integer NOT NULL,
created_at timestamp with time zone
created_at timestamp with time zone,
state smallint DEFAULT 0 NOT NULL
);
CREATE SEQUENCE merge_request_assignees_id_seq
......@@ -16158,6 +16158,7 @@ State of a review of a GitLab merge request.
| Value | Description |
| ----- | ----------- |
| <a id="mergerequestreviewstateattention_required"></a>`ATTENTION_REQUIRED` | The merge request is attention_required. |
| <a id="mergerequestreviewstatereviewed"></a>`REVIEWED` | The merge request is reviewed. |
| <a id="mergerequestreviewstateunreviewed"></a>`UNREVIEWED` | The merge request is unreviewed. |
......
......@@ -12,6 +12,10 @@ RSpec.describe GitlabSchema.types['MergeRequestReviewState'] do
'UNREVIEWED' => have_attributes(
description: 'The merge request is unreviewed.',
value: 'unreviewed'
),
'ATTENTION_REQUIRED' => have_attributes(
description: 'The merge request is attention_required.',
value: 'attention_required'
)
)
end
......
......@@ -37,4 +37,6 @@ RSpec.describe MergeRequestAssignee do
end
end
end
it_behaves_like 'having unique enum values'
end
......@@ -7,6 +7,8 @@ RSpec.describe MergeRequestReviewer do
subject { merge_request.merge_request_reviewers.build(reviewer: create(:user)) }
it_behaves_like 'having unique enum values'
describe 'associations' do
it { is_expected.to belong_to(:merge_request).class_name('MergeRequest') }
it { is_expected.to belong_to(:reviewer).class_name('User').inverse_of(:merge_request_reviewers) }
......
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