Parameterize current organization specs

What does this MR do and why?

Prior to making changes for #548320 (closed), this code change refactors and improves the test suite for organization detection logic in GitLab. The main changes are:

Code Structure: Makes all methods private except organization. I could not find any place where we use the individual methods, yet they were public and we were testing their behavior. Unless we intend to use them, it's easier if we make them private and test the overall organization functionality. We can always make them public later if we decide we need them.

Test Improvements: The tests were completely rewritten to be more comprehensive and organized. Instead of having separate test cases scattered throughout the file, the new approach uses a table-driven testing pattern that systematically tests all possible combinations of parameters and user states in one place.

Better Coverage: The new tests cover many more scenarios, including:

  • Valid parameters with and without users
  • Invalid or empty parameters with and without users
  • How the system prioritizes parameters over user data
  • When the system falls back to default organization
  • Performance optimizations to avoid unnecessary database queries

Cleaner Organization: The old tests had repetitive code and were harder to follow. The new structure makes it much easier to see exactly what scenarios are being tested and what the expected behavior should be in each case.

The functionality itself hasn't changed - this is purely about making the tests more thorough, easier to understand, and better organized while ensuring the organization detection logic works correctly in all situations.

References

Pre-work for Set current Organization by session (#548320 - closed)

Screenshots or screen recordings

Before After

How to set up and validate locally

MR acceptance checklist

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

Edited by Drew Blessing

Merge request reports

Loading