diff --git a/app/models/namespace.rb b/app/models/namespace.rb index ea80b10efcba21df055caa4ea80460e43f66fc0b..415b559aae35394ad2bc6c91f51de0d0783138e4 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -358,15 +358,6 @@ def sum_project_statistics_column(column) coalesce.as(column.to_s) end - def with_disabled_organization_validation - current_value = Gitlab::SafeRequestStore[:require_organization] - Gitlab::SafeRequestStore[:require_organization] = false - - yield - ensure - Gitlab::SafeRequestStore[:require_organization] = current_value - end - def username_reserved?(username) without_project_namespaces.where(parent_id: nil).find_by_path_or_name(username).present? end diff --git a/ee/spec/controllers/groups/omniauth_callbacks_controller_spec.rb b/ee/spec/controllers/groups/omniauth_callbacks_controller_spec.rb index 0f2c39366c7fd9903077d714e3fb45434adb6c00..a833fc96663600caf1885b528e422dc4397eb97f 100644 --- a/ee/spec/controllers/groups/omniauth_callbacks_controller_spec.rb +++ b/ee/spec/controllers/groups/omniauth_callbacks_controller_spec.rb @@ -287,10 +287,6 @@ def stub_last_request_id(id) it "links the identity" do post provider, params: { group_id: group } - # This line should be removed if this file is removed from the exception file: - # spec/support/helpers/disable_namespace_organization_validation.yml - Gitlab::SafeRequestStore.clear! - expect(group).to be_member(user) end diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index de2096800ec6925996c1091530b2cea526ab2a3d..50d060f5f0a56d6aa43401960ab12487451a5d2a 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -756,32 +756,6 @@ expect(namespace.valid?).to eq(true) end - - describe '.with_disabled_organization_validation' do - it 'does not require organization' do - namespace.organization = nil - - Namespace.with_disabled_organization_validation do - expect(namespace.valid?).to eq(true) - end - end - - context 'with nested calls' do - it 'validation will not be re-enabled' do - result = [] - Namespace.with_disabled_organization_validation do - result << described_class.new.require_organization? - Namespace.with_disabled_organization_validation do - result << described_class.new.require_organization? - end - result << described_class.new.require_organization? - end - - expect(result.any?(true)).to be false - expect(described_class.new.require_organization?).to be false - end - end - end end context 'when feature flag require_organization is enabled', :request_store do @@ -790,32 +764,6 @@ expect(namespace.valid?).to eq(false) end - - describe '.with_disabled_organization_validation' do - it 'does not require organization' do - namespace.organization = nil - - Namespace.with_disabled_organization_validation do - expect(namespace.valid?).to eq(true) - end - end - - context 'with nested calls' do - it 'only last call will re-enable the validation' do - result = [] - Namespace.with_disabled_organization_validation do - result << described_class.new.require_organization? - Namespace.with_disabled_organization_validation do - result << described_class.new.require_organization? - end - result << described_class.new.require_organization? - end - - expect(result.any?(true)).to be false - expect(described_class.new.require_organization?).to be true - end - end - end end describe '#traversal_ids' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e86059d02437ce90c7a30faaa2947ce399175f54..c52ce37f08ab7fa18cd5dbc94441120e56d7de2f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -214,7 +214,6 @@ config.include UserWithNamespaceShim config.include OrphanFinalArtifactsCleanupHelpers, :orphan_final_artifacts_cleanup config.include ClickHouseHelpers, :click_house - config.include DisableNamespaceOrganizationValidationHelper config.include_context 'when rendered has no HTML escapes', type: :view diff --git a/spec/support/helpers/disable_namespace_organization_validation.yml b/spec/support/helpers/disable_namespace_organization_validation.yml deleted file mode 100644 index d1f8842262164e63c8830cbaa70b55ef4b38238d..0000000000000000000000000000000000000000 --- a/spec/support/helpers/disable_namespace_organization_validation.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -- ee/spec/controllers/ee/groups_controller_spec.rb -- ee/spec/controllers/ee/omniauth_callbacks_controller_spec.rb -- ee/spec/controllers/groups/omniauth_callbacks_controller_spec.rb -- ee/spec/controllers/ldap/omniauth_callbacks_controller_spec.rb -- ee/spec/features/groups_spec.rb -- ee/spec/lib/gitlab/auth/group_saml/user_spec.rb -- ee/spec/lib/gitlab/auth/saml/user_spec.rb -- ee/spec/services/ee/groups/create_service_spec.rb -- ee/spec/services/ee/users/create_service_spec.rb -- ee/spec/services/users/service_accounts/create_service_spec.rb -- ee/spec/services/epics/update_dates_service_spec.rb -- spec/controllers/admin/groups_controller_spec.rb -- spec/controllers/admin/users_controller_spec.rb -- spec/controllers/groups_controller_spec.rb -- spec/features/admin/admin_groups_spec.rb -- spec/features/dashboard/group_spec.rb -- spec/features/groups_spec.rb -- spec/frontend/fixtures/groups.rb -- spec/graphql/types/project_type_spec.rb -- spec/lib/gitlab/auth/atlassian/user_spec.rb -- spec/lib/gitlab/auth/ldap/user_spec.rb -- spec/lib/gitlab/auth/saml/user_spec.rb -- spec/models/hooks/system_hook_spec.rb -- spec/requests/api/groups_spec.rb -- spec/services/resource_access_tokens/create_service_spec.rb diff --git a/spec/support/helpers/disable_namespace_organization_validation_helper.rb b/spec/support/helpers/disable_namespace_organization_validation_helper.rb deleted file mode 100644 index 9e2ab50b3a6f3e44c304f5114d0a17c09c949de1..0000000000000000000000000000000000000000 --- a/spec/support/helpers/disable_namespace_organization_validation_helper.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -module DisableNamespaceOrganizationValidationHelper - extend ActiveSupport::Concern - - SPECS_FOR_CODE_TO_FIX = File.join(__dir__, 'disable_namespace_organization_validation.yml') - - class << self - include Gitlab::Utils::StrongMemoize - - def todo_list - YAML.load_file(SPECS_FOR_CODE_TO_FIX).filter_map { |path| full_path(path) } || [] - end - strong_memoize_attr :todo_list - - def full_path(path) - return unless File.exist?(path) - - Pathname.new(path).realpath.to_s - end - end - - included do |base| - spec_file = base.metadata[:absolute_file_path] - - if spec_file.in?(DisableNamespaceOrganizationValidationHelper.todo_list) - around do |example| - ::Gitlab::SafeRequestStore.ensure_request_store { example.run } - end - end - end -end