Commit Graph

66 Commits

Author SHA1 Message Date
GitLab Bot 3bc741c0af Add latest changes from gitlab-org/gitlab@master 2025-05-15 03:19:55 +00:00
GitLab Bot b9ed0854d3 Add latest changes from gitlab-org/gitlab@master 2025-03-12 12:11:37 +00:00
GitLab Bot 5b5f5b84e7 Add latest changes from gitlab-org/gitlab@master 2024-10-18 00:16:17 +00:00
GitLab Bot e808a772e7 Add latest changes from gitlab-org/gitlab@master 2023-11-08 06:07:06 +00:00
GitLab Bot 28f0cd8e07 Add latest changes from gitlab-org/gitlab@master 2023-08-07 12:08:52 +00:00
GitLab Bot fc4faf47ac Add latest changes from gitlab-org/gitlab@master 2023-05-25 12:07:22 +00:00
GitLab Bot 4f8983ade8 Add latest changes from gitlab-org/gitlab@master 2023-02-17 12:11:17 +00:00
GitLab Bot 1862f4a83e Add latest changes from gitlab-org/gitlab@master 2022-09-22 18:11:12 +00:00
GitLab Bot b420660ef1 Add latest changes from gitlab-org/gitlab@master 2022-07-28 18:09:03 +00:00
GitLab Bot 2d18100383 Add latest changes from gitlab-org/gitlab@master 2022-06-06 18:09:02 +00:00
GitLab Bot 1943b0a274 Add latest changes from gitlab-org/gitlab@master 2022-03-14 06:07:47 +00:00
GitLab Bot 6b5937e93e Add latest changes from gitlab-org/gitlab@master 2022-01-20 09:11:11 +00:00
GitLab Bot 13f6669657 Add latest changes from gitlab-org/gitlab@master 2021-12-20 18:13:27 +00:00
GitLab Bot ff06f859cd Add latest changes from gitlab-org/gitlab@master 2020-11-10 15:09:14 +00:00
GitLab Bot 9215d9f761 Add latest changes from gitlab-org/gitlab@master 2020-07-15 12:09:26 +00:00
GitLab Bot 640e72ca92 Add latest changes from gitlab-org/gitlab@master 2020-06-04 03:08:05 +00:00
GitLab Bot 1219a9dce9 Add latest changes from gitlab-org/gitlab@master 2020-04-01 15:07:45 +00:00
GitLab Bot abae8f34f3 Add latest changes from gitlab-org/gitlab@master 2020-03-31 21:08:05 +00:00
GitLab Bot 22e9af3c8b Add latest changes from gitlab-org/gitlab@master 2020-01-27 12:08:35 +00:00
GitLab Bot 6c15c18fa4 Add latest changes from gitlab-org/gitlab@master 2020-01-09 18:07:52 +00:00
GitLab Bot b7d58ff8b1 Add latest changes from gitlab-org/gitlab@master 2019-12-14 00:08:27 +00:00
GitLab Bot 7ddd584699 Add latest changes from gitlab-org/gitlab@master 2019-11-30 00:06:03 +00:00
Igor f74b33cf6e Add can_merge option to autocomplete response
It's used only if merge_request_iid param is provided
2019-08-01 16:51:14 +00:00
Jan Provaznik 972b5f4555 Removed project autocomplete pagination
This pagination is not used anywhere so there is no reason
to keep it. It seems the usage of offset_id was probably
removed in 90c60138db
2019-07-22 11:44:20 +00:00
gfyoung 93a44e135b Add some frozen string to spec/**/*.rb
Adds frozen string to the following:

* spec/bin/**/*.rb
* spec/config/**/*.rb
* spec/controllers/**/*.rb

xref https://gitlab.com/gitlab-org/gitlab-ce/issues/59758
2019-04-15 10:17:05 +00:00
Hiroyuki Sato de784ac105 Filter merge requests by target branch 2019-03-09 12:22:58 +00:00
blackst0ne b44a2c801a Update specs to rails5 format
Updates specs to use new rails5 format.

The old format:
`get :show, { some: params }, { some: headers }`

The new format:
`get :show, params: { some: params }, headers: { some: headers }`
2018-12-19 10:04:31 +11:00
Yorick Peterse 6f3c490107
Refactor AutocompleteController
This refactors the AutocompleteController according to the guidelines
and boundaries discussed in
https://gitlab.com/gitlab-org/gitlab-ce/issues/49653. Specifically,
ActiveRecord logic is moved to different finders, which are then used in
the controller. View logic in turn is moved to presenters, instead of
directly using ActiveRecord's "to_json" method.

The finder MoveToProjectFinder is also adjusted according to the
abstraction guidelines and boundaries, resulting in a much more simple
finder.

By using finders (and other abstractions) more actively, we can push a
lot of logic out of the controller. We also remove the need for various
"before_action" hooks, though this could be achieved without using
finders as well.

The various finders related to AutcompleteController have also been
moved into a namespace. This removes the need for calling everything
"AutocompleteSmurfFinder", instead you can use
"Autocomplete::SmurfFinder".
2018-08-20 13:53:00 +02:00
Mark Chao a63bce1a4b Resolve "Rename the `Master` role to `Maintainer`" Backend 2018-07-11 14:36:08 +00:00
Dmitriy Zaporozhets 9fb733c323
Revert few more broken specs related to *_with_namespace methods
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2018-03-05 18:25:52 +02:00
Dmitriy Zaporozhets 8fe9995f11
Replace deprecated name_with_namespace with full_name in app and spec
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2018-03-05 16:15:26 +02:00
Yorick Peterse d2e43fbde6
Removed pagination from AutocompleteUsersFinder
The frontend code doesn't use this so there's no practical point in
supporting this. We also hardcode the limit to 20 so users can no longer
request their own limit, which could overload the database (depending on
any upper bounds perhaps enforced by Kaminari).
2018-02-22 18:55:36 +01:00
Jacopo 2f40dac352 Refactor `have_http_status` into `have_gitlab_http_status` in the specs 2017-10-20 10:13:18 +02:00
Eric Eastwood 90c60138db Move "Move to different project" to sidebar
Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/34261
2017-09-03 22:03:17 -05:00
Hiroyuki Sato 7187395ef1 Add filter by my reaction 2017-08-30 07:48:55 +00:00
Robert Speicher c8b802471b Enable the RSpec/HookArgument cop and auto-correct offenses 2017-08-10 19:29:42 -04:00
Rémy Coutable ebf5a0bd1b
Fix and improve spec/controllers/autocomplete_controller_spec.rb
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-08-10 09:45:03 +02:00
Robert Speicher 72a7b30c9f Change all `:empty_project` to `:project` 2017-08-02 17:47:31 -04:00
Robert Speicher 9513bd18c4 Ensure all project factories use `:repository` trait or `:empty_project` 2017-08-01 14:51:52 -04:00
Tiago Botelho 574b3efd6b Fixes the user order being overriden in the autocomplete controller 2017-07-14 16:31:45 +01:00
Robert Speicher a6ec5121f0 Correct RSpec/SingleLineHook cop offenses 2017-06-14 13:18:56 -05:00
DJ Mountney 982368dc55 Merge branch 'dz-restrict-autocomplete' into 'security-9-1'
Allow users autocomplete by author_id only for authenticated users

See merge request !2100
2017-06-08 09:52:27 -07:00
Douwe Maan 26bcef97d6 Merge branch 'rework-authorizations-performance' into 'master'
Rework project authorizations and nested groups for better performance

See merge request !10885
2017-05-29 15:49:56 +00:00
Clement Ho 2339bef1bc Add per page to user autocomplete 2017-05-26 12:59:00 -05:00
Yorick Peterse ac382b5682
Use CTEs for nested groups and authorizations
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.
2017-05-17 16:51:08 +02:00
Robert Speicher 4642ca6686 Use `empty_project` where possible in controller specs 2017-01-25 17:14:38 -05:00
Semyon Pupkov f5e8337c7b Do not raise error in AutocompleteController#users when not authorized
https://gitlab.com/gitlab-org/gitlab-ce/issues/25031
2016-11-30 10:09:14 +05:00
Timothy Andrew 41bf093662 CE-specific changes gitlab-org/gitlab-ee#1137
- Extract all common {push,merge} access level model code into the
  `ProtectedBranchAccess` module

- Use the HTTP verb to define controller specs
2016-11-29 17:38:45 +05:30
Robert Speicher eef3609123 Add shortcuts for adding users to a project team with a specific role
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
2016-11-18 14:55:04 +02:00
Paco Guzman ff903e6453 Move to project dropdown with infinite scroll for better performance
Use just SQL to check is a user can admin_issue on a project

Using offset pagination instead pages to avoid a count query

Tradeoff

- we duplicate how we check admin_issue in a SQL relation in the Ability class
2016-08-18 15:31:51 +02:00