Skip to content
Snippets Groups Projects
Commit 75f3d3ef authored by Rutger Wessels's avatar Rutger Wessels
Browse files

Remove default value for organization_id

The feature flag has been enabled globally
and can be removed

Changelog: changed
parent 6352bc50
No related branches found
No related tags found
3 merge requests!181325Fix ambiguous `created_at` in project.rb,!179611Draft: Rebase CR approach for zoekt assignments,!177080Remove require_organization Feature Flag
......@@ -120,7 +120,7 @@ class Namespace < ApplicationRecord
has_many :bot_users, through: :bot_user_details, source: :user
validates :owner, presence: true, if: ->(n) { n.owner_required? }
validates :organization, presence: true, if: :require_organization?
validates :organization, presence: true
validates :name,
presence: true,
length: { maximum: 255 }
......@@ -161,13 +161,7 @@ class Namespace < ApplicationRecord
validate :nesting_level_allowed, unless: -> { project_namespace? }
validate :changing_shared_runners_enabled_is_allowed, unless: -> { project_namespace? }
validate :changing_allow_descendants_override_disabled_shared_runners_is_allowed, unless: -> { project_namespace? }
validate :parent_organization_match, if: :require_organization?
attribute :organization_id, :integer, default: -> do
return if Feature.enabled?(:require_organization, Feature.current_request)
Organizations::Organization::DEFAULT_ORGANIZATION_ID
end
validate :parent_organization_match
delegate :name, to: :owner, allow_nil: true, prefix: true
delegate :avatar_url, to: :owner, allow_nil: true
......@@ -772,12 +766,6 @@ def pipeline_variables_default_role
private
def require_organization?
return false unless Feature.enabled?(:require_organization, Feature.current_request)
Gitlab::SafeRequestStore.fetch(:require_organization) { true } # rubocop:disable Style/RedundantFetchBlock -- This fetch has a different interface
end
def parent_organization_match
return unless parent
return if parent.organization_id == organization_id
......
---
name: require_organization
feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/411832
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/155732
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/470839
milestone: '17.3'
group: group::tenant scale
type: gitlab_com_derisk
default_enabled: false
......@@ -284,54 +284,6 @@
end
end
describe 'default values' do
context 'organzation_id' do
context 'when FF require_organization is enabled' do
context 'and organization is set' do
let(:created_namespace) { build(:group) }
it 'is valid' do
expect(created_namespace).to be_valid
end
end
context 'and organization is not set' do
let(:created_namespace) { build(:group) }
before do
created_namespace.organization_id = nil
end
it 'is invalid' do
expect(created_namespace).to be_invalid
end
end
end
context 'when FF require_organization is disabled' do
before do
stub_feature_flags(require_organization: false)
end
context 'and database has a default value' do
before do
described_class.connection.execute("ALTER TABLE namespaces ALTER COLUMN organization_id SET DEFAULT 100")
described_class.reset_column_information
end
after do
described_class.connection.execute("ALTER TABLE namespaces ALTER COLUMN organization_id SET DEFAULT 1")
described_class.reset_column_information
end
it 'uses value from model' do
expect(described_class.new.organization_id).to eq(Organizations::Organization::DEFAULT_ORGANIZATION_ID)
end
end
end
end
end
describe "ReferencePatternValidation" do
subject { described_class.reference_pattern }
......@@ -803,26 +755,6 @@
it { is_expected.to include_module(Namespaces::Traversal::LinearScopes) }
end
context 'when feature flag require_organization is disabled', :request_store do
before do
stub_feature_flags(require_organization: false)
end
it 'does not require organization' do
namespace.organization = nil
expect(namespace.valid?).to eq(true)
end
end
context 'when feature flag require_organization is enabled', :request_store do
it 'does require organization' do
namespace.organization = nil
expect(namespace.valid?).to eq(false)
end
end
describe '#traversal_ids' do
let(:namespace) { build(:group) }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment