Commit 461be6e4 authored by Patrick Bajao's avatar Patrick Bajao

Merge branch 'ph/343325/requiresAttentionAPI' into 'master'

Adds DB column for merge request assignee state

See merge request gitlab-org/gitlab!72677
parents ba780005 11cf2cd3
# 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 # frozen_string_literal: true
class MergeRequestAssignee < ApplicationRecord class MergeRequestAssignee < ApplicationRecord
include MergeRequestReviewerState
belongs_to :merge_request, touch: true belongs_to :merge_request, touch: true
belongs_to :assignee, class_name: "User", foreign_key: :user_id, inverse_of: :merge_request_assignees belongs_to :assignee, class_name: "User", foreign_key: :user_id, inverse_of: :merge_request_assignees
......
# frozen_string_literal: true # frozen_string_literal: true
class MergeRequestReviewer < ApplicationRecord class MergeRequestReviewer < ApplicationRecord
enum state: { include MergeRequestReviewerState
unreviewed: 0,
reviewed: 1
}
validates :state,
presence: true,
inclusion: { in: MergeRequestReviewer.states.keys }
belongs_to :merge_request belongs_to :merge_request
belongs_to :reviewer, class_name: 'User', foreign_key: :user_id, inverse_of: :merge_request_reviewers 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
...@@ -15706,7 +15706,8 @@ CREATE TABLE merge_request_assignees ( ...@@ -15706,7 +15706,8 @@ CREATE TABLE merge_request_assignees (
id bigint NOT NULL, id bigint NOT NULL,
user_id integer NOT NULL, user_id integer NOT NULL,
merge_request_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 CREATE SEQUENCE merge_request_assignees_id_seq
...@@ -16187,6 +16187,7 @@ State of a review of a GitLab merge request. ...@@ -16187,6 +16187,7 @@ State of a review of a GitLab merge request.
| Value | Description | | 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="mergerequestreviewstatereviewed"></a>`REVIEWED` | The merge request is reviewed. |
| <a id="mergerequestreviewstateunreviewed"></a>`UNREVIEWED` | The merge request is unreviewed. | | <a id="mergerequestreviewstateunreviewed"></a>`UNREVIEWED` | The merge request is unreviewed. |
......
...@@ -12,6 +12,10 @@ RSpec.describe GitlabSchema.types['MergeRequestReviewState'] do ...@@ -12,6 +12,10 @@ RSpec.describe GitlabSchema.types['MergeRequestReviewState'] do
'UNREVIEWED' => have_attributes( 'UNREVIEWED' => have_attributes(
description: 'The merge request is unreviewed.', description: 'The merge request is unreviewed.',
value: 'unreviewed' value: 'unreviewed'
),
'ATTENTION_REQUIRED' => have_attributes(
description: 'The merge request is attention_required.',
value: 'attention_required'
) )
) )
end end
......
...@@ -37,4 +37,6 @@ RSpec.describe MergeRequestAssignee do ...@@ -37,4 +37,6 @@ RSpec.describe MergeRequestAssignee do
end end
end end
end end
it_behaves_like 'having unique enum values'
end end
...@@ -7,6 +7,8 @@ RSpec.describe MergeRequestReviewer do ...@@ -7,6 +7,8 @@ RSpec.describe MergeRequestReviewer do
subject { merge_request.merge_request_reviewers.build(reviewer: create(:user)) } subject { merge_request.merge_request_reviewers.build(reviewer: create(:user)) }
it_behaves_like 'having unique enum values'
describe 'associations' do describe 'associations' do
it { is_expected.to belong_to(:merge_request).class_name('MergeRequest') } 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) } 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