Commit 672fc080 authored by Mark Lapierre's avatar Mark Lapierre Committed by Nikola Milojevic

Allow nil for remaining ci cd settings

The remaining methods delegated to ci_cd_settings also caused error
500 when the CI CD settings are deleted but the project still exists.
This allows them to return nil instead of raising an error.

Changelog: fixed
parent 12009142
......@@ -424,14 +424,14 @@ class Project < ApplicationRecord
delegate :members, to: :team, prefix: true
delegate :add_user, :add_users, to: :team
delegate :add_guest, :add_reporter, :add_developer, :add_maintainer, :add_role, to: :team
delegate :group_runners_enabled, :group_runners_enabled=, :group_runners_enabled?, to: :ci_cd_settings
delegate :group_runners_enabled, :group_runners_enabled=, :group_runners_enabled?, to: :ci_cd_settings, allow_nil: true
delegate :root_ancestor, to: :namespace, allow_nil: true
delegate :last_pipeline, to: :commit, allow_nil: true
delegate :external_dashboard_url, to: :metrics_setting, allow_nil: true, prefix: true
delegate :dashboard_timezone, to: :metrics_setting, allow_nil: true, prefix: true
delegate :default_git_depth, :default_git_depth=, to: :ci_cd_settings, prefix: :ci, allow_nil: true
delegate :forward_deployment_enabled, :forward_deployment_enabled=, :forward_deployment_enabled?, to: :ci_cd_settings, prefix: :ci, allow_nil: true
delegate :job_token_scope_enabled, :job_token_scope_enabled=, :job_token_scope_enabled?, to: :ci_cd_settings, prefix: :ci
delegate :job_token_scope_enabled, :job_token_scope_enabled=, :job_token_scope_enabled?, to: :ci_cd_settings, prefix: :ci, allow_nil: true
delegate :keep_latest_artifact, :keep_latest_artifact=, :keep_latest_artifact?, :keep_latest_artifacts_available?, to: :ci_cd_settings, allow_nil: true
delegate :restrict_user_defined_variables, :restrict_user_defined_variables=, :restrict_user_defined_variables?,
to: :ci_cd_settings, allow_nil: true
......
......@@ -657,6 +657,12 @@ 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 }
context 'when read_container_registry_access_level is disabled' do
before do
......
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