Skip to content

Draft: Check if organization_id is set for Namespace objects

Rutger Wessels requested to merge 411832-namespace-org-validation into master

What does this MR do and why?

Add a validation for organization_id to Namespace model

If we would use validates: :organization, presence: true, we would need to instantiate an Organization record for all specs that need a Namespace. That would slow down the specs. We can avoid that by validating the presence of the organization_id.

The organization_id is now defaulting to 1 on the database level. This validation will therefore always be true for new and existing records. Only if organization_id is explicitly set to nil, the Namespace will be invalid.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Related to #411832

Merge request reports