Commit b30023ab authored by Mark Lapierre's avatar Mark Lapierre Committed by Nikola Milojevic

Change specs to check all ci_cd_settings delegates

Also adds the tests to EE as a shared example
parent 672fc080
......@@ -62,6 +62,8 @@ RSpec.describe Project do
it { is_expected.to have_many(:incident_management_oncall_rotations).through(:incident_management_oncall_schedules).source(:rotations) }
it { is_expected.to have_many(:incident_management_escalation_policies).class_name('IncidentManagement::EscalationPolicy') }
include_examples 'ci_cd_settings delegation'
describe '#jira_vulnerabilities_integration_enabled?' do
context 'when project lacks a jira_integration relation' do
it 'returns false' do
......
......@@ -657,12 +657,8 @@ RSpec.describe Project, factory_default: :keep do
it { is_expected.to delegate_method(:allow_editing_commit_messages?).to(:project_setting) }
it { is_expected.to delegate_method(:container_registry_enabled?).to(:project_feature) }
it { is_expected.to delegate_method(:container_registry_access_level).to(:project_feature) }
it { is_expected.to delegate_method(:default_git_depth).to(:ci_cd_settings).with_prefix(:ci).allow_nil }
it { is_expected.to delegate_method(:forward_deployment_enabled).to(:ci_cd_settings).with_prefix(:ci).allow_nil }
it { is_expected.to delegate_method(:job_token_scope_enabled).to(:ci_cd_settings).with_prefix(:ci).allow_nil }
it { is_expected.to delegate_method(:group_runners_enabled).to(:ci_cd_settings).allow_nil }
it { is_expected.to delegate_method(:keep_latest_artifact).to(:ci_cd_settings).allow_nil }
it { is_expected.to delegate_method(:restrict_user_defined_variables).to(:ci_cd_settings).allow_nil }
include_examples 'ci_cd_settings delegation'
context 'when read_container_registry_access_level is disabled' do
before do
......
# frozen_string_literal: true
RSpec.shared_examples 'ci_cd_settings delegation' do
context 'when ci_cd_settings is destroyed but project is not' do
it 'allows methods delegated to ci_cd_settings to be nil', :aggregate_failures do
project = create(:project)
attributes = project.ci_cd_settings.attributes.keys - %w(id project_id)
project.ci_cd_settings.destroy
project.reload
attributes.each do |attr|
method = project.respond_to?("ci_#{attr}") ? "ci_#{attr}" : attr
expect(project.send(method)).to be_nil, "#{attr} was not nil"
end
end
end
end
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