Skip to content

Remove usage of Current.organization

What does this MR do and why?

As part of Cells project, we are working on adding support for Organizations. One of the implications is that Groups should be assigned an Organization.

In this MR, we started to use Current.organization which will be set by future Cells router. However, Current is set in Rack Middleware and usage should be limited to request layer (controllers)

In order to keep the MR's relatively small, the changes are split up across 4 MR's. 3 of them got merged, this is the final one.

MR Description
!149109 (merged) Pass organization explicitly for manually creation of groups
!150829 (merged) Pass organization explicitly for group creation related to import
!150996 (merged) Remaining code paths
This MR Remove usage of Current.organization from Groups::CreateService (final MR)

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.

How to set up and validate locally

We can verify that a new group is created in the correct organization. We don't have a UI yet so we use rails console (gdk rails c)

Rails console:

  • Create a new organization: name = "New Organization #{SecureRandom.alphanumeric(8)}";Organizations::Organization.create(name: name, path: name.parameterize)
  • Make root owner: Organizations::OrganizationUser.create(user: User.find(1), organization: Organizations::Organization.last, access_level: :owner)
  • Create new group in this organization: groupname = "New Group #{SecureRandom.alphanumeric(8)}";Groups::CreateService.new(current_user, name: group, organization_id: Organizations::Organization.last, path: group.parameterize).execute
  • Check that the organization of the new group equals to the new organization: Group.last.organization

Related to #443338 (closed)

Edited by Rutger Wessels

Merge request reports