summaryrefslogtreecommitdiff
path: root/spec/models/group_spec.rb
Commit message (Collapse)AuthorAgeFilesLines
* Return max group access level in the projects APIAlejandro Rodríguez2019-01-161-0/+36
| | | | | | | | | | | | | | | | | Currently if a project is inside a nested group and a user doesn't have specific permissions for that group but does have permissions on a parent group the `GET /projects/:id` API call will return the following permissions: ```json permissions: { project_access: null, group_access: null } ``` It could also happen that the group specific permissions are of lower level than the ones the user has in parent groups. This patch makes it so that the permission returned for `group_access` is the highest from amongst the hierarchy, which is (ostensibly) the information that the API user is interested in for that field.
* Use FastDestroy for deleting uploadsJan Provaznik2018-12-061-1/+1
| | | | | | | | | | It gathers list of file paths to delete before destroying the parent object. Then after the parent_object is destroyed these paths are scheduled for deletion asynchronously. Carrierwave needed associated model for deleting upload file. To avoid this requirement, simple Fog/File layer is used directly for file deletion, this allows us to use just a simple list of paths.
* Resolve "Can add an existing group member into a group project with new ↵James Lopez2018-12-061-2/+2
| | | | permissions but permissions are not overridden"
* Unify into :group_clusters feature flagThong Kuah2018-12-051-0/+29
| | | | | | | With this MR, group clusters is now functional, so default to enabled. Have a single setting on the root ancestor group to enabled or disable group clusters feature as a whole
* Renaming Secret Variables in the codebaseMarcel Amirault2018-10-301-8/+8
|
* Associate clusters model to groups34758-create-group-clustersThong Kuah2018-10-291-0/+2
| | | | | | | | | | | | | | | | Even though we currently only should have one group for a cluster, we allow the flexibility to associate to other groups in the future. This also matches the runner <=> groups association. - Adds Cluster#first_group, aliased to Cluster#group. For the conceivable future, a cluster will have at most one group. - Prevent mixing of group and project clusters. If project type clusters, it should only have projects assigned. Similarly with groups. - Default cluster_type to :project_type. As it's very small table we can set default and null: false in one release.
* Applies the CE backport of EE#657Tiago Botelho2018-09-241-11/+31
|
* Resolve "Rename the `Master` role to `Maintainer`" BackendMark Chao2018-07-111-24/+24
|
* Updates from `rubocop -a`Lin Jen-Shin2018-07-091-2/+2
|
* Merge branch 'issue_44230' into 'master'Sean McGivern2018-06-071-0/+24
|\ | | | | | | | | | | | | Apply notification settings level of groups to all child objects Closes #44230 See merge request gitlab-org/gitlab-ce!19191
| * Apply notification settings level of groups to all child objectsFelipe Artur2018-06-071-0/+24
| |
* | send ico files with inline dispositionAlexis Reigel2018-06-051-1/+1
|/
* Delete remote uploadsJan Provaznik2018-05-161-1/+9
| | | | | | | | | | | | | | | | | | | | | | ObjectStore uploader requires presence of associated `uploads` record when deleting the upload file (through the carrierwave's after_commit hook) because we keep info whether file is LOCAL or REMOTE in `upload` object. For this reason we can not destroy uploads as "dependent: :destroy" hook because these would be deleted too soon. Instead we rely on carrierwave's hook to destroy `uploads` in after_commit hook. But in before_destroy hook we still have to delete not-mounted uploads (which don't use carrierwave's destroy hook). This has to be done in before_Destroy instead of after_commit because `FileUpload` requires existence of model's object on destroy action. This is not ideal state of things, in a next step we should investigate how to unify model dependencies so we can use same workflow for all uploads. Related to #45425
* Backport of 4084-epics-username-autocompleteMario de la Ossa2018-05-041-0/+89
|
* Change avatar error message to include allowed file formatsFabian Schneider2018-03-221-1/+1
|
* Projects and groups badges APIFrancisco Javier López2018-03-051-0/+1
|
* Merge branch 'mc/bug/38984-wildcard-protected-tags' into 'security-10-4'Kamil Trzciński2018-02-091-2/+6
| | | | Fix using wildcards in protected tags to expose protected variables
* Validate path uniqueness only on Route, and bubble up appropriatelyDouwe Maan2018-02-061-1/+0
|
* 31885 - Ability to transfer a single group to another groupMayra Cabrera2018-02-061-0/+16
|
* Always return full avatar URL for private/internal groups/projects when ↵Douwe Maan2017-11-091-8/+2
| | | | asset host is set
* Free up some group reserved wordsBob Van Landuyt2017-11-071-6/+0
|
* Support custom attributes on groupsMarkus Koller2017-11-061-0/+1
|
* Add system hooks user_rename and group_renameWinnie Hellmann2017-11-031-0/+41
|
* Optimize SQL queries used in Groups::GroupMembersController#create27374-groups-groupmemberscontroller-create-is-slow-due-to-sqlRubén Dávila2017-09-051-16/+3
| | | | | | | | | | | The following optimizations were performed: - Add new association to GroupMember and ProjectMember This new association will allow us to check if a user is a member of a Project or Group through a single query instead of two. - Optimize retrieving of Members when adding multiple Users
* fix failing tests due to new group visibility restrictionsMike Greiling2017-08-261-2/+2
|
* Add validation to check visibility level of sub groups.Rubén Dávila2017-08-261-0/+44
|
* Add validation for visibility level of sub groupsRubén Dávila2017-08-261-0/+33
| | | | Sub groups should not have a visibility level higher than its parent.
* Change all `:empty_project` to `:project`rs-empty_project-defaultRobert Speicher2017-08-021-1/+1
|
* Use described_class when possibleRémy Coutable2017-07-271-1/+1
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* 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>
* Don't treat anonymous users as owners when group has pending invitesSean McGivern2017-07-241-0/+4
| | | | | | The `members` table can have entries where `user_id: nil`, because people can invite group members by email. We never want to include those as members, because it might cause confusion with the anonymous (logged out) user.
* Update specs for new upload pathBob Van Landuyt2017-07-181-1/+1
|
* Mark a subgroup-related spec as PostgreSQL-onlyrs-issue-34847Robert Speicher2017-07-071-7/+7
| | | | Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/34847
* Add CASE When Clause for saving order when using where INShinya Maeda2017-07-071-5/+12
|
* Basic BE changeShinya Maeda2017-07-071-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix static-snalysis Move the precedence of group secure variable before project secure variable. Allow project_id to be null. Separate Ci::VariableProject and Ci::VariableGroup Add the forgotton files Add migration file to update type of ci_variables Fix form_for fpr VariableProject Fix test Change the table structure according to the yorik advice Add necessary migration files. Remove unnecessary migration spec. Revert safe_model_attributes.yml Fix models Fix spec Avoid self.variable. Use becomes for correct routing. Use unique index on group_id and key Add null: false for t.timestamps Fix schema version Rename VariableProject and VariableGroup to ProjectVariable and GroupVariable Rename the rest of them Add the rest of files Basic BE change Fix static-snalysis Move the precedence of group secure variable before project secure variable. Allow project_id to be null. Separate Ci::VariableProject and Ci::VariableGroup Add the forgotton files Add migration file to update type of ci_variables Fix form_for fpr VariableProject Fix test Change the table structure according to the yorik advice Add necessary migration files. Remove unnecessary migration spec. Revert safe_model_attributes.yml Fix models Fix spec Avoid self.variable. Use becomes for correct routing. Use unique index on group_id and key Add null: false for t.timestamps Fix schema version Rename VariableProject and VariableGroup to ProjectVariable and GroupVariable Rename the rest of them Add the rest of files Implement CURD Rename codes related to VariableGroup and VariableProject FE part Remove unneccesary changes Make Fe code up-to-date Add protected flag to migration file Protected group variables essential package Update schema Improve doc Fix logic and spec for models Fix logic and spec for controllers Fix logic and spec for views(pre feature) Add feature spec Fixed bugs. placeholder. reveal button. doc. Add changelog Remove unnecessary comment godfat nice catches Improve secret_variables_for arctecture Fix spec Fix StaticAnlysys & path_regex spec Revert "Improve secret_variables_for arctecture" This reverts commit c3216ca212322ecf6ca534cb12ce75811a4e77f1. Use ayufan suggestion for secret_variables_for Use find instead of find_by Fix spec message for variable is invalid Fix spec remove variable.group_id = group.id godffat spec nitpicks Use include Gitlab::Routing.url_helpers for presenter spec
* Enable Style/DotPosition Rubocop :cop:Grzegorz Bizon2017-06-211-2/+2
|
* Correct RSpec/SingleLineHook cop offensesRobert Speicher2017-06-141-6/+21
|
* Bring in security changes from the 9.2.5 releaseDJ Mountney2017-06-071-1/+1
| | | | | | | | | | | | | Ran: - git format-patch v9.2.2..v9.2.5 --stdout > patchfile.patch - git checkout -b 9-2-5-security-patch origin/v9.2.2 - git apply patchfile.patch - git commit - [Got the sha ref for the commit] - git checkout -b upstream-9-2-security master - git cherry-pick <SHA of the patchfile commit> - [Resolved conflicts] - git cherry-pick --continue
* Use CTEs for nested groups and authorizationsYorick Peterse2017-05-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 relative paths for group/project/user avatarsblackst0ne2017-05-101-6/+10
|
* Backport avatar-related spec changes from gitlab-org/gitlab-ee@4b464eaaeebackport-ee-4b464eaaeeRémy Coutable2017-05-041-0/+16
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Reject group-routes as names of child namespacesBob Van Landuyt2017-05-011-0/+6
|
* Streamline the path validation in groups & projectsBob Van Landuyt2017-05-011-0/+20
| | | | | | | | | | | | `Project` uses `ProjectPathValidator` which is now a `NamespaceValidator` that skips the format validation. That way we're sure we are using the same collection of reserved paths. I updated the path constraints to reflect the changes: We now allow some values that are only used on a top level namespace as a name for a nested group/project.
* Support 2FA requirement per-groupMarkus Koller2017-04-061-0/+42
|
* Merge branch 'master' into 'rs-carrierwave-db'rs-carrierwave-dbDouwe Maan2017-03-061-0/+1
|\ | | | | | | # Conflicts: # spec/models/group_spec.rb
| * Create MM team for GitLab groupZ.J. van de Weg2017-02-161-0/+1
| |
* | Add `has_many` associations for models that can have Upload recordsRobert Speicher2017-03-061-0/+1
|/
* Refresh authorizations when transferring projectsrefresh-permissions-when-moving-projectsYorick Peterse2017-02-071-0/+13
| | | | | | | | This ensures that project authorizations are refreshed when moving a project from one namespace to another. When doing so the permissions for all users of both the old and new namespaces are refreshed. See #26194 for more information.
* Merge branch 'backport-ee-changes-for-build-minutes' into 'master' Grzegorz Bizon2017-01-251-2/+8
|\ | | | | | | | | Backport changes introduced by https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1078 See merge request !8657
| * Backport changes introduced by ↵Kamil Trzcinski2017-01-201-2/+8
| | | | | | | | https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1083