2020-08-30 20:10:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe MergeRequestReviewer do
|
2021-12-02 04:10:59 -05:00
|
|
|
let(:reviewer) { create(:user) }
|
2020-08-30 20:10:37 -04:00
|
|
|
let(:merge_request) { create(:merge_request) }
|
|
|
|
|
2021-12-02 04:10:59 -05:00
|
|
|
subject { merge_request.merge_request_reviewers.build(reviewer: reviewer) }
|
2020-08-30 20:10:37 -04:00
|
|
|
|
2021-10-25 05:12:21 -04:00
|
|
|
it_behaves_like 'having unique enum values'
|
|
|
|
|
2021-11-03 02:10:20 -04:00
|
|
|
it_behaves_like 'having reviewer state'
|
|
|
|
|
2021-12-02 04:10:59 -05:00
|
|
|
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-08-30 20:10:37 -04:00
|
|
|
describe 'associations' do
|
|
|
|
it { is_expected.to belong_to(:merge_request).class_name('MergeRequest') }
|
2020-11-23 13:09:14 -05:00
|
|
|
it { is_expected.to belong_to(:reviewer).class_name('User').inverse_of(:merge_request_reviewers) }
|
2020-08-30 20:10:37 -04:00
|
|
|
end
|
|
|
|
end
|