From e4bce5234031690d2b48e54a58bcc88343586dc6 Mon Sep 17 00:00:00 2001 From: Suraj Tripathi Date: Thu, 19 Oct 2023 15:09:47 +0530 Subject: [PATCH 1/2] Added new setting allow_project_creation_for_guest_and_below - Adds validation and updates spec Changelog: changed --- app/models/application_setting.rb | 2 +- ...creation_for_guest_and_below_to_application_settings.rb | 7 +++++++ db/schema_migrations/20231019093412 | 1 + db/structure.sql | 1 + spec/models/application_setting_spec.rb | 2 ++ 5 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20231019093412_add_allow_project_creation_for_guest_and_below_to_application_settings.rb create mode 100644 db/schema_migrations/20231019093412 diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 5aa7abed22ce50..ec4fbdec73a32f 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -488,7 +488,7 @@ def self.kroki_formats_attributes validates :invisible_captcha_enabled, inclusion: { in: [true, false], message: N_('must be a boolean value') } - validates :invitation_flow_enforcement, :can_create_group, :user_defaults_to_private_profile, + validates :invitation_flow_enforcement, :can_create_group, :allow_project_creation_for_guest_and_below, :user_defaults_to_private_profile, allow_nil: false, inclusion: { in: [true, false], message: N_('must be a boolean value') } diff --git a/db/migrate/20231019093412_add_allow_project_creation_for_guest_and_below_to_application_settings.rb b/db/migrate/20231019093412_add_allow_project_creation_for_guest_and_below_to_application_settings.rb new file mode 100644 index 00000000000000..099a7b21098598 --- /dev/null +++ b/db/migrate/20231019093412_add_allow_project_creation_for_guest_and_below_to_application_settings.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddAllowProjectCreationForGuestAndBelowToApplicationSettings < Gitlab::Database::Migration[2.1] + def change + add_column(:application_settings, :allow_project_creation_for_guest_and_below, :boolean, default: true, null: false) + end +end diff --git a/db/schema_migrations/20231019093412 b/db/schema_migrations/20231019093412 new file mode 100644 index 00000000000000..46f11999fee05e --- /dev/null +++ b/db/schema_migrations/20231019093412 @@ -0,0 +1 @@ +e286fdc6c49c8fb21e99bc6399ed2610f2c755dc2dc8486b79916e032695d02a \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 8582b819febac1..e6ba10056c4093 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -12120,6 +12120,7 @@ CREATE TABLE application_settings ( math_rendering_limits_enabled boolean DEFAULT true NOT NULL, service_access_tokens_expiration_enforced boolean DEFAULT true NOT NULL, enable_artifact_external_redirect_warning_page boolean DEFAULT true NOT NULL, + allow_project_creation_for_guest_and_below boolean DEFAULT true NOT NULL, CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)), CONSTRAINT app_settings_container_registry_pre_import_tags_rate_positive CHECK ((container_registry_pre_import_tags_rate >= (0)::numeric)), CONSTRAINT app_settings_dep_proxy_ttl_policies_worker_capacity_positive CHECK ((dependency_proxy_ttl_group_policy_worker_capacity >= 0)), diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index 59701f52f28c7f..f2f79311fdf8df 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -162,6 +162,8 @@ it { is_expected.to validate_inclusion_of(:user_defaults_to_private_profile).in_array([true, false]) } + it { is_expected.to validate_inclusion_of(:allow_project_creation_for_guest_and_below).in_array([true, false]) } + it { is_expected.to validate_inclusion_of(:deny_all_requests_except_allowed).in_array([true, false]) } it 'ensures max_pages_size is an integer greater than 0 (or equal to 0 to indicate unlimited/maximum)' do -- GitLab From 3ec8905f52fc8b7f83e20a5bcb778e0eeadc004e Mon Sep 17 00:00:00 2001 From: Suraj Tripathi Date: Wed, 8 Nov 2023 15:18:59 +0530 Subject: [PATCH 2/2] Bumped the migration version and updated template to include milestone --- ...t_creation_for_guest_and_below_to_application_settings.rb} | 4 +++- db/schema_migrations/20231019093412 | 1 - db/schema_migrations/20231108093031 | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) rename db/migrate/{20231019093412_add_allow_project_creation_for_guest_and_below_to_application_settings.rb => 20231108093031_add_allow_project_creation_for_guest_and_below_to_application_settings.rb} (80%) delete mode 100644 db/schema_migrations/20231019093412 create mode 100644 db/schema_migrations/20231108093031 diff --git a/db/migrate/20231019093412_add_allow_project_creation_for_guest_and_below_to_application_settings.rb b/db/migrate/20231108093031_add_allow_project_creation_for_guest_and_below_to_application_settings.rb similarity index 80% rename from db/migrate/20231019093412_add_allow_project_creation_for_guest_and_below_to_application_settings.rb rename to db/migrate/20231108093031_add_allow_project_creation_for_guest_and_below_to_application_settings.rb index 099a7b21098598..06e0a7fc000205 100644 --- a/db/migrate/20231019093412_add_allow_project_creation_for_guest_and_below_to_application_settings.rb +++ b/db/migrate/20231108093031_add_allow_project_creation_for_guest_and_below_to_application_settings.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true -class AddAllowProjectCreationForGuestAndBelowToApplicationSettings < Gitlab::Database::Migration[2.1] +class AddAllowProjectCreationForGuestAndBelowToApplicationSettings < Gitlab::Database::Migration[2.2] + milestone '16.6' + def change add_column(:application_settings, :allow_project_creation_for_guest_and_below, :boolean, default: true, null: false) end diff --git a/db/schema_migrations/20231019093412 b/db/schema_migrations/20231019093412 deleted file mode 100644 index 46f11999fee05e..00000000000000 --- a/db/schema_migrations/20231019093412 +++ /dev/null @@ -1 +0,0 @@ -e286fdc6c49c8fb21e99bc6399ed2610f2c755dc2dc8486b79916e032695d02a \ No newline at end of file diff --git a/db/schema_migrations/20231108093031 b/db/schema_migrations/20231108093031 new file mode 100644 index 00000000000000..d532e469d821de --- /dev/null +++ b/db/schema_migrations/20231108093031 @@ -0,0 +1 @@ +fea17e6126f21671a8836dea252e2bd655179aeb6c746b6bbecaed0580dd255a \ No newline at end of file -- GitLab