summaryrefslogtreecommitdiff
path: root/spec/models/project_team_spec.rb
Commit message (Collapse)AuthorAgeFilesLines
* Resolve "Rename the `Master` role to `Maintainer`" BackendMark Chao2018-07-111-54/+54
|
* Fix specMark Chao2018-06-061-2/+2
|
* Replace '.team << [user, role]' with 'add_role(user)' in specs36782-replace-team-user-role-with-add_role-user-in-specsblackst0ne2017-12-221-2/+2
|
* Change all `:empty_project` to `:project`rs-empty_project-defaultRobert Speicher2017-08-021-15/+15
|
* Ensure all project factories use `:repository` trait or `:empty_project`rs-empty_project-cleanupRobert Speicher2017-08-011-1/+1
|
* Remove superfluous lib: true, type: redis, service: true, models: true, ↵Rémy Coutable2017-07-271-1/+1
| | | | | | services: true, no_db: true, api: true Signed-off-by: Rémy Coutable <remy@rymai.me>
* Enable Style/DotPosition Rubocop :cop:Grzegorz Bizon2017-06-211-2/+2
|
* Correct RSpec/SingleLineHook cop offensesRobert Speicher2017-06-141-1/+3
|
* Use :request_store hooks on specsuse-request-store-helper-instead-actual-codeOswaldo Ferreira2017-06-091-10/+1
|
* Fix N+1 queries for non-members in comment threadsfix-n-plus-one-queries-for-user-accessSean McGivern2017-06-011-53/+98
| | | | | | | | When getting the max member access for a group of users, we stored the results in RequestStore. However, this will only return results for project members, so anyone who wasn't a member of the project would be checked once at the start, and then once for each comment they made. These queries are generally quite fast, but no query is faster!
* Use CTEs for nested groups and authorizationsYorick Peterse2017-05-171-7/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces the usage of Common Table Expressions (CTEs) to efficiently retrieve nested group hierarchies, without having to rely on the "routes" table (which is an _incredibly_ inefficient way of getting the data). This requires a patch to ActiveRecord (found in the added initializer) to work properly as ActiveRecord doesn't support WITH statements properly out of the box. Unfortunately MySQL provides no efficient way of getting nested groups. For example, the old routes setup could easily take 5-10 seconds depending on the amount of "routes" in a database. Providing vastly different logic for both MySQL and PostgreSQL will negatively impact the development process. Because of this the various nested groups related methods return empty relations when used in combination with MySQL. For project authorizations the logic is split up into two classes: * Gitlab::ProjectAuthorizations::WithNestedGroups * Gitlab::ProjectAuthorizations::WithoutNestedGroups Both classes get the fresh project authorizations (= as they should be in the "project_authorizations" table), including nested groups if PostgreSQL is used. The logic of these two classes is quite different apart from their public interface. This complicates development a bit, but unfortunately there is no way around this. This commit also introduces Gitlab::GroupHierarchy. This class can be used to get the ancestors and descendants of a base relation, or both by using a UNION. This in turn is used by methods such as: * Namespace#ancestors * Namespace#descendants * User#all_expanded_groups Again this class relies on CTEs and thus only works on PostgreSQL. The Namespace methods will return an empty relation when MySQL is used, while User#all_expanded_groups will return only the groups a user is a direct member of. Performance wise the impact is quite large. For example, on GitLab.com Namespace#descendants used to take around 580 ms to retrieve data for a particular user. Using CTEs we are able to reduce this down to roughly 1 millisecond, returning the exact same data. == On The Fly Refreshing Refreshing of authorizations on the fly (= when users.authorized_projects_populated was not set) is removed with this commit. This simplifies the code, and ensures any queries used for authorizations are not mutated because they are executed in a Rails scope (e.g. Project.visible_to_user). This commit includes a migration to schedule refreshing authorizations for all users, ensuring all of them have their authorizations in place. Said migration schedules users in batches of 5000, with 5 minutes between every batch to smear the load around a bit. == Spec Changes This commit also introduces some changes to various specs. For example, some specs for ProjectTeam assumed that creating a personal project would _not_ lead to the owner having access, which is incorrect. Because we also no longer refresh authorizations on the fly for new users some code had to be added to the "empty_project" factory. This chunk of code ensures that the owner's permissions are refreshed after creating the project, something that is normally done in Projects::CreateService.
* Use `:empty_project` where possible in model specsrs-empty_project-modelsRobert Speicher2017-01-261-5/+5
|
* Update ProjectTeam#fetch_members to use project authorizationsfix/drop-project-authorized-for-userAhmad Sherif2016-11-231-1/+1
|
* Update ProjectTeam#max_member_access_for_user_ids to use project authorizationsAhmad Sherif2016-11-231-6/+6
|
* Drop Project#authorized_for_user? in favor of ProjectTeam#member?Ahmad Sherif2016-11-231-0/+51
| | | | Closes #23938
* Add shortcuts for adding users to a project team with a specific rolers-project-team-helpersRobert Speicher2016-11-181-17/+17
| | | | | | | | | | This also updates _some_ specs to use these new methods, just to serve as an example for others going forward, but by no means is this exhaustive. Original implementations at !5992 and !6012. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/20944
* Make access request specs explicitly enable or disable access requests as ↵Nick Thomas2016-11-111-4/+4
| | | | required
* Fix specs that requires an access requestRémy Coutable2016-09-221-2/+2
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Fix a logic error in ProjectTeam#fetch_invited_membersRobert Speicher2016-09-201-0/+1
| | | | | | We were calling `.where` and `.send` on the relation, but never doing anything with the return value, resulting in proper access-level filtering never being of any consequence.
* Add specs for ProjectTeam#fetch_membersRobert Speicher2016-09-201-0/+61
|
* Only use RequestStore in ProjectTeam#max_member_access_for_user if it is activeStan Hu2016-08-011-40/+61
|
* Rubocop offensesStan Hu2016-07-261-8/+8
|
* Optimize the invited group link access level checkStan Hu2016-07-261-2/+12
|
* Optimize maximum user access level lookup in loading of notesStan Hu2016-07-261-8/+43
| | | | | | | | NotesHelper#note_editable? and ProjectTeam#human_max_access currently take about 16% of the load time of an issue page. This MR preloads the maximum access level of users for all notes in issues and merge requests with several queries instead of one per user and caches the result in RequestStore.
* UI and copywriting improvements13948-access-request-to-projects-and-groupsRémy Coutable2016-06-141-0/+22
| | | | | | | | | + Move 'Edit Project/Group' out of membership-related partial + Show the access request buttons only to logged-in users + Put the request access buttons out of in a more visible button + Improve the copy in the #remove_member_message helper Signed-off-by: Rémy Coutable <remy@rymai.me>
* Add request access for groupsRémy Coutable2016-06-141-56/+94
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Project members with guest role can't access confidential issuesDouglas Barbosa Alexandre2016-06-131-0/+6
|
* Bring shared project feature tests from EEDmitriy Zaporozhets2016-03-121-0/+44
| | | | Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
* Allow `ProjectTeam#human_max_access` to return "Owner"rs-show-owner-labelRobert Speicher2016-02-181-8/+18
|
* Tag model specsDouwe Maan2015-12-091-1/+1
|
* Wrong access level badge on MR commentsaccess_level_badge_bugValery Sizov2015-10-021-0/+12
|
* Add `Group#add_*` convenience methodsrs-group-convenience-methodsRobert Speicher2015-08-071-3/+3
| | | | Encapsulates the logic for `Gitlab::Access::WHATEVER` levels.
* Fix Style/TrailingBlankLines cop violationsRobert Speicher2015-06-221-1/+0
|
* Updated rspec to rspec 3.x syntaxJeroen van Baarsen2015-02-121-22/+22
| | | | Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
* Snippets: public/internal/privateValery Sizov2014-10-091-0/+4
|
* Fix permission issue with highest access level for groupDmitriy Zaporozhets2014-06-201-21/+51
| | | | | | | | If user was a member of both group and project and group access level was higher it was not respected and user got lowest project access level. Now it is fixed and user get highest access level Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
* Fixed the project team specsJeroen van Baarsen2014-06-081-8/+8
| | | | Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
* Improve performance of application for large teamsDmitriy Zaporozhets2014-06-041-7/+28
| | | | | | | This commit fixes a lot of sql queries to db for for groups and projects with big amount of members. Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
* remove tests for unexisting methodsDmitriy Zaporozhets2013-02-261-3/+0
|
* repair rspec (remove and rename files)Andrey Kumanyaev2013-01-241-0/+18