Commit Graph

71 Commits

Author SHA1 Message Date
Robert Speicher 72a7b30c9f Change all `:empty_project` to `:project` 2017-08-02 17:47:31 -04:00
Robert Speicher 1a0064dceb Use `empty_project` where possible in spec/features/projects 2017-07-27 13:12:16 -04:00
Keifer Furzland 7e113b6824 Remove superfluous type defs in specs
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-27 14:31:52 +02:00
Paul Charlton cb3b4a15e6 Support multiple Redis instances based on queue type 2017-07-11 03:35:47 +00:00
Robert Speicher 7d03012f2a Merge branch 'master' into rs-sign_in 2017-07-07 11:42:00 -04:00
Tim Zallmann 64e589c581 Resolve "Inconsistent location of members page between groups and projects" 2017-07-07 14:40:41 +00:00
Robert Speicher eef068754a Merge branch 'master' into rs-sign_in 2017-07-06 12:43:51 -04:00
Robert Speicher 9eeba8fb49 Auto-correct ProjectPathHelper violations 2017-07-06 12:20:50 -04:00
Douwe Maan fe13f11041 Create and use project path helpers that only need a project, no namespace 2017-07-05 11:11:59 -05:00
Robert Speicher e939bf7be1 Change gitlab_sign_in to sign_in where possible 2017-06-29 12:18:23 -04:00
Robert Speicher 45fb1f9542 Change `login_as` uses to `gitlab_sign_in` 2017-06-19 18:59:01 -05: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
Oswaldo Ferreira 2338785ec9 Use wait_for_requests to wait all JS request 2017-05-22 20:39:49 -03: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
Toon Claes ab7c90331f Add :redis keyword to some specs clear state of trackable attributes
The specs that rely on a correct value of the trackable attributes, should
include the `:redis` keyword in the spec to ensure the state is reset between
various specs.

The trackable attributes being:

- sign_in_count      : Increased every time a sign in is made (by form, openid, oauth)
- current_sign_in_at : A timestamp updated when the user signs in
- last_sign_in_at    : Holds the timestamp of the previous sign in
- current_sign_in_ip : The remote ip updated when the user sign in
- last_sign_in_ip    : Holds the remote ip of the previous sign in

The limiting of writing trackable attributes was introduced in
gitlab-org/gitlab-ce!11053.
2017-05-09 20:58:15 +02:00
Rémy Coutable 3855751d02
Merge branch 'jacopo-beschi/gitlab-ce-29712-unnecessary-wait-for-ajax'
See merge request !10567

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-04-24 18:06:47 +02:00
James Edwards-Jones 2fe0d9f25a Added test to prevent ‘Request access’ regression 2017-04-22 00:18:09 +01:00
Jacopo ff76adb547 Unnecessary "include WaitForAjax" and "include ApiHelpers"
Removed all the unnecessary include of `WaitForAjax` and `ApiHelpers` in the specs.
Removed unnecessary usage of `api:true`
2017-04-21 22:32:02 +02:00
Dmitriy Zaporozhets 5f08760482
Move some project/group members spinach tests to rspec
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2017-04-17 21:03:30 +03:00
Mike Greiling ba6864343b update sub-nav selector in user_requests_access_spec 2017-03-23 11:52:23 -05:00
Jose Ivan Vargas 69b4ec954e fixed user_access_request_spec 2017-03-07 23:26:57 -06:00
Douwe Maan ad640bc5f9 Use Namespace#full_path instead of #path where appropriate 2017-02-23 17:55:01 -06:00
Phil Hughes 12cc9a530c Changed date check test 2017-02-06 09:38:53 +00:00
Phil Hughes 8331036944 Fixed some specs
CHANGELOG item
2017-02-06 09:25:11 +00:00
Jose Ivan Vargas 5ce4883da0 Fixed a test and change the arrow functions to named functions 2017-01-04 18:43:55 -06:00
Jose Ivan Vargas 57b5612aaa Removed the "Groups" option from the settings gear
Fixed more tests
2017-01-03 10:52:14 -06:00
Jose Ivan Vargas def6c43da1 Fixed more rspec tests as well as spinach features 2017-01-03 10:52:14 -06:00
Jose Ivan Vargas 68c730bb99 Fixed rspec tests for the project members also fixed the index
view (removed an extra tag )
2017-01-03 10:52:14 -06:00
Jose Ivan Vargas 4cd139e948 Moved the members (project_members)option to a single controller called members
This controller is going to contain both the project members and groups options
for the settings gear.

Generated the route and modified the routing to point to the new members setting path
2017-01-03 10:52:14 -06:00
Felipe Artur 8275efa36b Fix member with expiration date feature spec 2016-12-19 22:52:10 -02:00
Nur Rony ecea127cd1 Improve test for sort dropdown on members page 2016-12-16 20:30:27 -02:00
Douglas Barbosa Alexandre 0ef2c8dfbe Use factories to create project/group membership on specs 2016-12-16 20:28:40 -02:00
Douglas Barbosa Alexandre 3a2905f507 Sort group/project members alphabetically by default 2016-12-16 20:28:38 -02:00
Douglas Barbosa Alexandre 4b7a3d0c38 Add feature spec for sort functionality on group/project members list 2016-12-16 20:28:38 -02:00
Jacob Schatz ffa1b67d2f Merge branch '23305-leave-project-and-leave-group-should-be-buttons' into 'master'
Remove 'Leave Project' and 'Leave Group' from settings dropdowns

## What does this MR do?

Removes `Leave Project` and `Leave Group` from the settings dropdown.

Adds it to the `views/shared/members/access_request_buttons.html.haml`.

## Are there points in the code the reviewer needs to double check?

## Why was this MR needed?

## Screenshots (if relevant)

![Screen_Shot_2016-11-19_at_15.34.26](/uploads/5c66a025513b4780a9e881f0036381e4/Screen_Shot_2016-11-19_at_15.34.26.png)
![Screen_Shot_2016-11-19_at_15.35.29](/uploads/ed74a5dfe982cf65bb49c0c4fb307061/Screen_Shot_2016-11-19_at_15.35.29.png)

## Does this MR meet the acceptance criteria?

- [x] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [ ] API support added
- Tests
  - [ ] Added for this feature/bug
  - [x] All builds are passing
- [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if it does - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

## What are the relevant issue numbers?


Closes #23305

See merge request !7600
2016-12-09 19:27:09 +00:00
Fatih Acet 5bb43bb953 Merge branch 'members-dropdowns' into 'master'
Updated members dropdowns

## What does this MR do?

EE has different dropdowns to allow for group LDAP members to be overridden, this ports the dropdown changes over to reduce conflicts.

## Screenshots (if relevant)

![Screen_Shot_2016-12-07_at_15.28.20](/uploads/6cb6def34015b024dc878aa3b99be4a0/Screen_Shot_2016-12-07_at_15.28.20.png)

See merge request !7974
2016-12-09 18:11:47 +00:00
Phil Hughes fcf332a4fa Group links spec update 2016-12-09 16:39:00 +00:00
Rémy Coutable 96f162125d
Handle an edge-case whith invitees
When the project has invitees, no group members were
returned due to a `user_id NOT IN (42, NULL)` query which
always returned [] since a `user_id` would be NULL, thus the condition
could never match.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-12-07 09:59:52 +01:00
Phil Hughes 89c22ed5af Shows group members in the project members list
Closes #24122
2016-12-02 16:49:53 +00:00
Luke "Jared" Bennett c47d8ab69e
Removed leave buttons from settings dropdowns
Updated specs
2016-11-26 14:27:08 +00:00
Nick Thomas d211011698 Make access request specs explicitly enable or disable access requests as required 2016-11-11 15:45:47 +00:00
Phil Hughes 2a6942abef Merge branch 'master' into members-ui 2016-10-04 11:03:07 +01:00
Rémy Coutable ec0061a95c Allow Member.add_user to handle access requesters
Changes include:

- Ensure Member.add_user is not called directly when not necessary
- New GroupMember.add_users_to_group to have the same abstraction level as for Project
- Refactor Member.add_user to take a source instead of an array of members
- Fix Rubocop offenses
- Always use Project#add_user instead of project.team.add_user
- Factorize users addition as members in Member.add_users_to_source
- Make access_level a keyword argument in GroupMember.add_users_to_group and ProjectMember.add_users_to_projects
- Destroy any requester before adding them as a member
- Improve the way we handle access requesters in Member.add_user
  Instead of removing the requester and creating a new member,
  we now simply accepts their access request. This way, they will
  receive a "access request granted" email.
- Fix error that was previously silently ignored
- Stop raising when access level is invalid in Member, let Rails validation do their work

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-09-28 09:43:00 +02:00
Phil Hughes ecf7640b28 Fixed group_links expire date not updating in view 2016-09-13 08:44:59 +01:00
Phil Hughes 2b41db9215 Search project groups 2016-09-13 08:44:59 +01:00
Phil Hughes 73c4da1780 Fixed removing groups 2016-09-13 08:44:59 +01:00
Phil Hughes 11c0c65092 Expires in test update 2016-09-13 08:44:59 +01:00
Phil Hughes e747626fad Added test for updating groups permissions 2016-09-13 08:44:59 +01:00
Phil Hughes 2c3fa33ca2 Updated some specs
Fixed issue with group name not showing
2016-09-13 08:44:59 +01:00
Phil Hughes 999f184805 Tests update 2016-09-13 08:44:59 +01:00