2022-08-04 05:10:47 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe MergeRequest::ApprovalRemovalSettings do
|
|
|
|
describe 'validations' do
|
2022-08-17 05:11:44 -04:00
|
|
|
let(:reset_approvals_on_push) {}
|
|
|
|
let(:selective_code_owner_removals) {}
|
2022-08-04 05:10:47 -04:00
|
|
|
|
|
|
|
subject { described_class.new(project, reset_approvals_on_push, selective_code_owner_removals) }
|
|
|
|
|
|
|
|
context 'when enabling selective_code_owner_removals and reset_approvals_on_push is disabled' do
|
|
|
|
let(:project) { create(:project, reset_approvals_on_push: false) }
|
|
|
|
let(:selective_code_owner_removals) { true }
|
|
|
|
|
|
|
|
it { is_expected.to be_valid }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when enabling selective_code_owner_removals and reset_approvals_on_push is enabled' do
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:selective_code_owner_removals) { true }
|
|
|
|
|
|
|
|
it { is_expected.not_to be_valid }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when enabling reset_approvals_on_push and selective_code_owner_removals is disabled' do
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:reset_approvals_on_push) { true }
|
|
|
|
|
|
|
|
it { is_expected.to be_valid }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when enabling reset_approvals_on_push and selective_code_owner_removals is enabled' do
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:reset_approvals_on_push) { true }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.project_setting.update!(selective_code_owner_removals: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.not_to be_valid }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when enabling reset_approvals_on_push and selective_code_owner_removals' do
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:reset_approvals_on_push) { true }
|
|
|
|
let(:selective_code_owner_removals) { true }
|
|
|
|
|
|
|
|
it { is_expected.not_to be_valid }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|