User belongs to organization
This branch is almost ready. The only thing missing is a feature test connected with user registration in the organization. Additional some cleanup maybe will be done if I will spot additional elements related to this PR.
Why this MR is submitted if it is not ready
Because it is huge and most probably will require some time to review all changes. Please take a look and after that, we can meet F2F to discuss any problems spotted in this MR (it is too big to have an initial review process using commenting system IMHO, especially in the case when we are sitting close to each other).
Motivation and the main design decisions
We want many organizations in MEE. Each organization will have separate space to define pipelines, own user management, specific list of capabilities (e.g. PDP, file browsing) turned on. Here the only separation of user management is done, capabilities turning on/off, belonging of organization-specific models will be done in the next MRs.
To make it happened new model Membership
was introduced. It is a joining table between User
and Organization
. Inside this model user roles, the account status in the organization scope is defined.
Now all tests suit should be executed in the scope of the organization (this lead to the situation that this MR is so big). To make it simpler for all tests some defaults were defined:
- default
organization
(by default all specs are executed in this organization scope if not stated otherwise) -
user
,admin
(mee admin and default organization admin),supervisor
,stranger
-
user
,admin
andsupervisor
belongs to defaultorganization
with appropriated membership rights
All these defaults are created before all tests and are removed after test suit is finished (take a look at spec/support/seed_db.rb
and spec/support/subdomains
for details). This has plusses (you don't need to create users and organizations, everything is done once) and minuses (you need to be careful to not pollute defaults for next tests if you need to modify default you should create a new organization/user).