2020-11-24 15:15:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe MergeRequestReviewer do
|
2022-01-26 12:08:38 +05:30
|
|
|
let(:reviewer) { create(:user) }
|
2020-11-24 15:15:51 +05:30
|
|
|
let(:merge_request) { create(:merge_request) }
|
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
subject { merge_request.merge_request_reviewers.build(reviewer: reviewer) }
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
it_behaves_like 'having unique enum values'
|
|
|
|
|
|
|
|
it_behaves_like 'having reviewer state'
|
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
describe 'syncs to assignee state' do
|
|
|
|
before do
|
|
|
|
assignee = merge_request.merge_request_assignees.build(assignee: reviewer)
|
|
|
|
assignee.update!(state: :reviewed)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to have_attributes(state: 'reviewed') }
|
|
|
|
end
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
describe 'associations' do
|
|
|
|
it { is_expected.to belong_to(:merge_request).class_name('MergeRequest') }
|
2021-02-22 17:27:13 +05:30
|
|
|
it { is_expected.to belong_to(:reviewer).class_name('User').inverse_of(:merge_request_reviewers) }
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
2022-05-07 20:08:51 +05:30
|
|
|
|
|
|
|
describe '#attention_requested_by' do
|
|
|
|
let(:current_user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
subject.update!(updated_state_by: current_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'attention requested' do
|
|
|
|
it { expect(subject.attention_requested_by).to eq(current_user) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'attention requested' do
|
|
|
|
before do
|
|
|
|
subject.update!(state: :reviewed)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(subject.attention_requested_by).to eq(nil) }
|
|
|
|
end
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|