From c123291db91a8c54865779ee29ddebaad159d147 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 22 Feb 2022 06:16:10 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .gitlab/ci/global.gitlab-ci.yml | 6 +-- GITALY_SERVER_VERSION | 2 +- .../runner/components/runner_list.vue | 29 +++++++---- .../oauth/authorizations_controller.rb | 9 ++++ app/controllers/uploads_controller.rb | 45 ++++++++--------- app/finders/projects/topics_finder.rb | 2 +- app/graphql/resolvers/topics_resolver.rb | 4 +- app/models/projects/topic.rb | 4 +- app/policies/alert_management/alert_policy.rb | 2 + ...ulate_topics_non_private_projects_count.rb | 15 ++++++ db/schema_migrations/20220211090920 | 1 + doc/administration/auth/atlassian.md | 16 +++--- .../auth/ldap/ldap-troubleshooting.md | 14 +++--- doc/administration/gitaly/index.md | 15 +++--- doc/api/alert_management_alerts.md | 50 +++++++++++++++++++ .../reducing_the_repo_size_using_git.md | 8 +-- spec/finders/projects/topics_finder_spec.rb | 6 +-- .../runner/components/runner_list_spec.js | 7 +-- .../graphql/resolvers/topics_resolver_spec.rb | 6 +-- spec/models/projects/topic_spec.rb | 12 ++--- spec/requests/api/topics_spec.rb | 6 +-- 21 files changed, 173 insertions(+), 86 deletions(-) create mode 100644 db/migrate/20220211090920_cleanup_populate_topics_non_private_projects_count.rb create mode 100644 db/schema_migrations/20220211090920 create mode 100644 doc/api/alert_management_alerts.md diff --git a/.gitlab/ci/global.gitlab-ci.yml b/.gitlab/ci/global.gitlab-ci.yml index 33b04faf731..98c418a05f8 100644 --- a/.gitlab/ci/global.gitlab-ci.yml +++ b/.gitlab/ci/global.gitlab-ci.yml @@ -245,7 +245,7 @@ - name: postgres:11.6 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"] - name: redis:5.0-alpine - - name: elasticsearch:7.14.2 + - name: elasticsearch:7.17.0 command: ["elasticsearch", "-E", "discovery.type=single-node"] variables: POSTGRES_HOST_AUTH_METHOD: trust @@ -256,7 +256,7 @@ - name: postgres:12 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"] - name: redis:5.0-alpine - - name: elasticsearch:7.14.2 + - name: elasticsearch:7.17.0 command: ["elasticsearch", "-E", "discovery.type=single-node"] variables: POSTGRES_HOST_AUTH_METHOD: trust @@ -267,7 +267,7 @@ - name: postgres:13 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"] - name: redis:5.0-alpine - - name: elasticsearch:7.14.2 + - name: elasticsearch:7.17.0 command: ["elasticsearch", "-E", "discovery.type=single-node"] variables: POSTGRES_HOST_AUTH_METHOD: trust diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index f83d8b11dce..94604a3a7be 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -ad76c4bd99833148140d5c08b7258363e5163b9c +c1cabced28d02d667a37122860adde10068d28e2 diff --git a/app/assets/javascripts/runner/components/runner_list.vue b/app/assets/javascripts/runner/components/runner_list.vue index bb36882d3ae..17cbf01c9a1 100644 --- a/app/assets/javascripts/runner/components/runner_list.vue +++ b/app/assets/javascripts/runner/components/runner_list.vue @@ -1,5 +1,5 @@ diff --git a/app/controllers/oauth/authorizations_controller.rb b/app/controllers/oauth/authorizations_controller.rb index d1c409d071e..ccc155ddbf5 100644 --- a/app/controllers/oauth/authorizations_controller.rb +++ b/app/controllers/oauth/authorizations_controller.rb @@ -12,7 +12,10 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController # Overridden from Doorkeeper::AuthorizationsController to # include the call to session.delete def new + logger.info("#{self.class.name}#new: pre_auth_params['scope'] = #{pre_auth_params['scope'].inspect}") + if pre_auth.authorizable? + logger.info("#{self.class.name}#new: pre_auth.scopes = #{pre_auth.scopes.to_a.inspect}") if skip_authorization? || matching_token? auth = authorization.authorize parsed_redirect_uri = URI.parse(auth.redirect_uri) @@ -43,9 +46,15 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController auth_type = params.delete('gl_auth_type') return unless auth_type == 'login' + logger.info("#{self.class.name}: BEFORE application has read_user: #{application_has_read_user_scope?}") + logger.info("#{self.class.name}: BEFORE scope = #{params['scope'].inspect}") + ensure_read_user_scope! params['scope'] = Gitlab::Auth::READ_USER_SCOPE.to_s if application_has_read_user_scope? + + logger.info("#{self.class.name}: AFTER application has read_user: #{application_has_read_user_scope?}") + logger.info("#{self.class.name}: AFTER scope = #{params['scope'].inspect}") end # Configure the application to support read_user scope, if it already diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index d7eb3ccd274..4df0ef78907 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -40,30 +40,29 @@ class UploadsController < ApplicationController upload_model_class.find(params[:id]) end + def authorized? + case model + when Note + can?(current_user, :read_project, model.project) + when Snippet, ProjectSnippet + can?(current_user, :read_snippet, model) + when User + # We validate the current user has enough (writing) + # access to itself when a secret is given. + # For instance, user avatars are readable by anyone, + # while temporary, user snippet uploads are not. + !secret? || can?(current_user, :update_user, model) + when Appearance + true + when Projects::Topic + true + else + can?(current_user, "read_#{model.class.underscore}".to_sym, model) + end + end + def authorize_access! - authorized = - case model - when Note - can?(current_user, :read_project, model.project) - when Snippet, ProjectSnippet - can?(current_user, :read_snippet, model) - when User - # We validate the current user has enough (writing) - # access to itself when a secret is given. - # For instance, user avatars are readable by anyone, - # while temporary, user snippet uploads are not. - !secret? || can?(current_user, :update_user, model) - when Appearance - true - when Projects::Topic - true - else - permission = "read_#{model.class.underscore}".to_sym - - can?(current_user, permission, model) - end - - render_unauthorized unless authorized + render_unauthorized unless authorized? end def authorize_create_access! diff --git a/app/finders/projects/topics_finder.rb b/app/finders/projects/topics_finder.rb index 7c3abc27cf7..c26b166a786 100644 --- a/app/finders/projects/topics_finder.rb +++ b/app/finders/projects/topics_finder.rb @@ -12,7 +12,7 @@ module Projects end def execute - topics = Projects::Topic.order_by_total_projects_count + topics = Projects::Topic.order_by_non_private_projects_count by_search(topics) end diff --git a/app/graphql/resolvers/topics_resolver.rb b/app/graphql/resolvers/topics_resolver.rb index d8199f3d89b..68e2ff69282 100644 --- a/app/graphql/resolvers/topics_resolver.rb +++ b/app/graphql/resolvers/topics_resolver.rb @@ -10,9 +10,9 @@ module Resolvers def resolve(**args) if args[:search].present? - ::Projects::Topic.search(args[:search]).order_by_total_projects_count + ::Projects::Topic.search(args[:search]).order_by_non_private_projects_count else - ::Projects::Topic.order_by_total_projects_count + ::Projects::Topic.order_by_non_private_projects_count end end end diff --git a/app/models/projects/topic.rb b/app/models/projects/topic.rb index 235246b1f1d..b42b03f0618 100644 --- a/app/models/projects/topic.rb +++ b/app/models/projects/topic.rb @@ -14,12 +14,12 @@ module Projects has_many :project_topics, class_name: 'Projects::ProjectTopic' has_many :projects, through: :project_topics - scope :order_by_total_projects_count, -> { order(total_projects_count: :desc).order(id: :asc) } + scope :order_by_non_private_projects_count, -> { order(non_private_projects_count: :desc).order(id: :asc) } scope :reorder_by_similarity, -> (search) do order_expression = Gitlab::Database::SimilarityScore.build_expression(search: search, rules: [ { column: arel_table['name'] } ]) - reorder(order_expression.desc, arel_table['total_projects_count'].desc, arel_table['id']) + reorder(order_expression.desc, arel_table['non_private_projects_count'].desc, arel_table['id']) end class << self diff --git a/app/policies/alert_management/alert_policy.rb b/app/policies/alert_management/alert_policy.rb index 85fafcde2cc..e2383921c82 100644 --- a/app/policies/alert_management/alert_policy.rb +++ b/app/policies/alert_management/alert_policy.rb @@ -5,3 +5,5 @@ module AlertManagement delegate { @subject.project } end end + +AlertManagement::AlertPolicy.prepend_mod diff --git a/db/migrate/20220211090920_cleanup_populate_topics_non_private_projects_count.rb b/db/migrate/20220211090920_cleanup_populate_topics_non_private_projects_count.rb new file mode 100644 index 00000000000..5ab8feb2195 --- /dev/null +++ b/db/migrate/20220211090920_cleanup_populate_topics_non_private_projects_count.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class CleanupPopulateTopicsNonPrivateProjectsCount < Gitlab::Database::Migration[1.0] + MIGRATION = 'PopulateTopicsNonPrivateProjectsCount' + + disable_ddl_transaction! + + def up + finalize_background_migration(MIGRATION) + end + + def down + # no-op + end +end diff --git a/db/schema_migrations/20220211090920 b/db/schema_migrations/20220211090920 new file mode 100644 index 00000000000..1f08b66e508 --- /dev/null +++ b/db/schema_migrations/20220211090920 @@ -0,0 +1 @@ +644d38e401ac8179777cb9d3c5fefca2fb55e0c409197bb2d222f7e96e5dd42f \ No newline at end of file diff --git a/doc/administration/auth/atlassian.md b/doc/administration/auth/atlassian.md index 7c6aee2c2da..6be53922a5a 100644 --- a/doc/administration/auth/atlassian.md +++ b/doc/administration/auth/atlassian.md @@ -13,14 +13,14 @@ To enable the Atlassian OmniAuth provider for passwordless authentication you mu 1. Go to and sign-in with the Atlassian account to administer the application. -1. Click **Create a new app**. -1. Choose an App Name, such as 'GitLab', and click **Create**. +1. Select **Create a new app**. +1. Choose an App Name, such as 'GitLab', and select **Create**. 1. Note the `Client ID` and `Secret` for the [GitLab configuration](#gitlab-configuration) steps. -1. On the left sidebar under **APIS AND FEATURES**, click **OAuth 2.0 (3LO)**. -1. Enter the GitLab callback URL using the format `https://gitlab.example.com/users/auth/atlassian_oauth2/callback` and click **Save changes**. -1. Click **+ Add** in the left sidebar under **APIS AND FEATURES**. -1. Click **Add** for **Jira platform REST API** and then **Configure**. -1. Click **Add** next to the following scopes: +1. On the left sidebar under **APIS AND FEATURES**, select **OAuth 2.0 (3LO)**. +1. Enter the GitLab callback URL using the format `https://gitlab.example.com/users/auth/atlassian_oauth2/callback` and select **Save changes**. +1. Select **+ Add** in the left sidebar under **APIS AND FEATURES**. +1. Select **Add** for **Jira platform REST API** and then **Configure**. +1. Select **Add** next to the following scopes: - **View Jira issue data** - **View user profiles** - **Create and manage issues** @@ -73,6 +73,6 @@ To enable the Atlassian OmniAuth provider for passwordless authentication you mu 1. Save the configuration file. 1. [Reconfigure](../restart_gitlab.md#omnibus-gitlab-reconfigure) or [restart GitLab](../restart_gitlab.md#installations-from-source) for the changes to take effect if you installed GitLab via Omnibus or from source respectively. -On the sign-in page there should now be an Atlassian icon below the regular sign in form. Click the icon to begin the authentication process. +On the sign-in page there should now be an Atlassian icon below the regular sign in form. Select the icon to begin the authentication process. If everything goes right, the user is signed in to GitLab using their Atlassian credentials. diff --git a/doc/administration/auth/ldap/ldap-troubleshooting.md b/doc/administration/auth/ldap/ldap-troubleshooting.md index 06fe579e101..b8391bec72f 100644 --- a/doc/administration/auth/ldap/ldap-troubleshooting.md +++ b/doc/administration/auth/ldap/ldap-troubleshooting.md @@ -89,14 +89,14 @@ established but GitLab doesn't show you LDAP users in the output, one of the following is most likely true: - The `bind_dn` user doesn't have enough permissions to traverse the user tree. -- The user(s) don't fall under the [configured `base`](index.md#configure-ldap). -- The [configured `user_filter`](index.md#set-up-ldap-user-filter) blocks access to the user(s). +- The users don't fall under the [configured `base`](index.md#configure-ldap). +- The [configured `user_filter`](index.md#set-up-ldap-user-filter) blocks access to the users. In this case, you con confirm which of the above is true using [ldapsearch](#ldapsearch) with the existing LDAP configuration in your `/etc/gitlab/gitlab.rb`. -#### User(s) cannot sign-in +#### Users cannot sign-in A user can have trouble signing in for any number of reasons. To get started, here are some questions to ask yourself: @@ -284,7 +284,7 @@ If you don't find a particular user's GitLab email in the output, then that user hasn't signed in with LDAP yet. Next, GitLab searches its `identities` table for the existing -link between this user and the configured LDAP provider(s): +link between this user and the configured LDAP providers: ```sql Identity Load (0.9ms) SELECT "identities".* FROM "identities" WHERE "identities"."user_id" = 20 AND (provider LIKE 'ldap%') LIMIT 1 @@ -334,7 +334,7 @@ Gitlab::Auth::Ldap::Person.find_by_uid('', adapter) ### Group memberships **(PREMIUM SELF)** -#### Membership(s) not granted +#### Memberships not granted Sometimes you may think a particular user should be added to a GitLab group via LDAP group sync, but for some reason it's not happening. You can check several @@ -348,7 +348,7 @@ things to debug the situation. 1. On the top bar, select **Menu > Admin**. 1. On the left sidebar, select **Overview > Users**. 1. Search for the user. - 1. Open the user by clicking their name. Do not click **Edit**. + 1. Open the user by selecting their name. Do not select **Edit**. 1. Select the **Identities** tab. There should be an LDAP identity with an LDAP DN as the 'Identifier'. If not, this user hasn't signed in with LDAP yet and must do so first. @@ -558,7 +558,7 @@ aren't blocked or unable to access their accounts. NOTE: The following script requires that any new accounts with the new -email address are removed first. This is because emails have to be unique in GitLab. +email address are removed first. Email addresses must be unique in GitLab. Go to the [rails console](#rails-console) and then run: diff --git a/doc/administration/gitaly/index.md b/doc/administration/gitaly/index.md index ea24e901943..f88a1aa2b4d 100644 --- a/doc/administration/gitaly/index.md +++ b/doc/administration/gitaly/index.md @@ -13,7 +13,7 @@ It is used by GitLab to read and write Git data. Gitaly is present in every GitLab installation and coordinates Git repository storage and retrieval. Gitaly can be: -- A simple background service operating on a single instance Omnibus GitLab (all of +- A background service operating on a single instance Omnibus GitLab (all of GitLab on one machine). - Separated onto its own instance and configured in a full cluster configuration, depending on scaling and availability requirements. @@ -71,7 +71,7 @@ the current status of these issues, please refer to the referenced issues and ep | Gitaly Cluster + Geo - Issues retrying failed syncs | If Gitaly Cluster is used on a Geo secondary site, repositories that have failed to sync could continue to fail when Geo tries to resync them. Recovering from this state requires assistance from support to run manual steps. Work is in-progress to update Gitaly Cluster to [identify repositories with a unique and persistent identifier](https://gitlab.com/gitlab-org/gitaly/-/issues/3485), which is expected to resolve the issue. | No known solution at this time. | | Database inconsistencies due to repository access outside of Gitaly Cluster's control | Operations that write to the repository storage that do not go through normal Gitaly Cluster methods can cause database inconsistencies. These can include (but are not limited to) snapshot restoration for cluster node disks, node upgrades which modify files under Git control, or any other disk operation that may touch repository storage external to GitLab. The Gitaly team is actively working to provide manual commands to [reconcile the Praefect database with the repository storage](https://gitlab.com/groups/gitlab-org/-/epics/6723). | Don't directly change repositories on any Gitaly Cluster node at this time. | | Praefect unable to insert data into the database due to migrations not being applied after an upgrade | If the database is not kept up to date with completed migrations, then the Praefect node is unable to perform normal operation. | Make sure the Praefect database is up and running with all migrations completed (For example: `/opt/gitlab/embedded/bin/praefect -config /var/opt/gitlab/praefect/config.toml sql-migrate-status` should show a list of all applied migrations). Consider [requesting live upgrade assistance](https://about.gitlab.com/support/scheduling-live-upgrade-assistance.html) so your upgrade plan can be reviewed by support. | -| Restoring a Gitaly Cluster node from a snapshot in a running cluster | Because the Gitaly Cluster runs with consistent state, introducing a single node that is behind will result in the cluster not being able to reconcile the nodes data and other nodes data | Don't restore a single Gitaly Cluster node from a backup snapshot. If you need to restore from backup, it's best to snapshot all Gitaly Cluster nodes at the same time and take a database dump of the Praefect database. | +| Restoring a Gitaly Cluster node from a snapshot in a running cluster | Because the Gitaly Cluster runs with consistent state, introducing a single node that is behind will result in the cluster not being able to reconcile the nodes data and other nodes data | Don't restore a single Gitaly Cluster node from a backup snapshot. If you must restore from backup, it's best to snapshot all Gitaly Cluster nodes at the same time and take a database dump of the Praefect database. | ### Snapshot backup and recovery limitations @@ -179,7 +179,7 @@ In this example: - Repositories are stored on a virtual storage called `storage-1`. - Three Gitaly nodes provide `storage-1` access: `gitaly-1`, `gitaly-2`, and `gitaly-3`. - The three Gitaly nodes share data in three separate hashed storage locations. -- The [replication factor](#replication-factor) is `3`. There are three copies maintained +- The [replication factor](#replication-factor) is `3`. Three copies are maintained of each repository. The availability objectives for Gitaly clusters assuming a single node failure are: @@ -237,7 +237,7 @@ Engineering support for NFS for Git repositories is deprecated. Technical suppor is not well suited to Git workloads which are CPU and IOPS sensitive. Specifically: -- Git is sensitive to file system latency. Even simple operations require many +- Git is sensitive to file system latency. Some operations require many read operations. Operations that are fast on block storage can become an order of magnitude slower. This significantly impacts GitLab application performance. - NFS performance optimizations that prevent the performance gap between @@ -386,8 +386,7 @@ them back to direct Gitaly storage: 1. Create and configure a new [Gitaly server](configure_gitaly.md#run-gitaly-on-its-own-server). 1. [Move the repositories](../operations/moving_repositories.md#move-repositories) - to the newly created storage. There are different possibilities to move them - by shard or by group, this gives you the opportunity to spread them over + to the newly created storage. You can move them by shard or by group, which gives you the opportunity to spread them over multiple Gitaly servers. ## Monitor Gitaly and Gitaly Cluster @@ -509,7 +508,7 @@ The following metrics are available from the `/metrics` endpoint: They reflect configuration defined for this instance of Praefect. - `gitaly_praefect_replication_latency_bucket`, a histogram measuring the amount of time it takes - for replication to complete once the replication job starts. Available in GitLab 12.10 and later. + for replication to complete after the replication job starts. Available in GitLab 12.10 and later. - `gitaly_praefect_replication_delay_bucket`, a histogram measuring how much time passes between when the replication job is created and when it starts. Available in GitLab 12.10 and later. - `gitaly_praefect_node_latency_bucket`, a histogram measuring the latency in Gitaly returning @@ -542,7 +541,7 @@ You can also monitor the [Praefect logs](../logs.md#praefect-logs). The following metrics are available from the `/db_metrics` endpoint: - `gitaly_praefect_unavailable_repositories`, the number of repositories that have no healthy, up to date replicas. -- `gitaly_praefect_read_only_repositories`, the number of repositories in read-only mode within a virtual storage. +- `gitaly_praefect_read_only_repositories`, the number of repositories in read-only mode in a virtual storage. This metric is available for backwards compatibility reasons. `gitaly_praefect_unavailable_repositories` is more accurate. - `gitaly_praefect_replication_queue_depth`, the number of jobs in the replication queue. diff --git a/doc/api/alert_management_alerts.md b/doc/api/alert_management_alerts.md new file mode 100644 index 00000000000..ce27249bddc --- /dev/null +++ b/doc/api/alert_management_alerts.md @@ -0,0 +1,50 @@ +--- +stage: Monitor +group: Respond +info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments +--- + +# Alert Management Alerts API **(FREE)** + +This is the documentation of Alert Management Alerts API. + +NOTE: +This API is limited to metric images. For more API endpoints please refer to the [GraphQL API](graphql/reference/index.md#alertmanagementalert). + +## List metric images + +```plaintext +GET /projects/:id/alert_management_alerts/:alert_iid/metric_images +``` + +| Attribute | Type | Required | Description | +|-------------|---------|----------|--------------------------------------| +| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user | +| `alert_iid` | integer | yes | The internal ID of a project's alert | + +```shell +curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/5/alert_management_alerts/93/metric_images" +``` + +Example response: + +```json +[ + { + "id": 17, + "created_at": "2020-11-12T20:07:58.156Z", + "filename": "sample_2054", + "file_path": "/uploads/-/system/alert_metric_image/file/17/sample_2054.png", + "url": "example.com/metric", + "url_text": "An example metric" + }, + { + "id": 18, + "created_at": "2020-11-12T20:14:26.441Z", + "filename": "sample_2054", + "file_path": "/uploads/-/system/alert_metric_image/file/18/sample_2054.png", + "url": "example.com/metric", + "url_text": "An example metric" + } +] +``` diff --git a/doc/user/project/repository/reducing_the_repo_size_using_git.md b/doc/user/project/repository/reducing_the_repo_size_using_git.md index 31d3dfe3473..83fafd409e8 100644 --- a/doc/user/project/repository/reducing_the_repo_size_using_git.md +++ b/doc/user/project/repository/reducing_the_repo_size_using_git.md @@ -62,7 +62,7 @@ To purge files from a GitLab repository: git clone --bare --mirror /path/to/project.bundle ``` -1. Navigate to the `project.git` directory: +1. Go to the `project.git` directory: ```shell cd project.git @@ -159,7 +159,7 @@ operations before continuing. To clean up a repository: 1. Go to the project for the repository. -1. Navigate to **Settings > Repository**. +1. Go to **Settings > Repository**. 1. Upload a list of objects. For example, a `commit-map` file created by `git filter-repo` which is located in the `filter-repo` directory. @@ -169,7 +169,7 @@ To clean up a repository: split -l 3000 filter-repo/commit-map filter-repo/commit-map- ``` -1. Click **Start cleanup**. +1. Select **Start cleanup**. This: @@ -240,7 +240,7 @@ Until `git gc` runs on the GitLab side, the "removed" commits and blobs still ex must be able to push the rewritten history to GitLab, which may be impossible if you've already exceeded the maximum size limit. -In order to lift these restrictions, the administrator of the self-managed GitLab instance must +To lift these restrictions, the Administrator of the self-managed GitLab instance must increase the limit on the particular project that exceeded it. Therefore, it's always better to proactively stay underneath the limit. If you hit the limit, and can't have it temporarily increased, your only option is to: diff --git a/spec/finders/projects/topics_finder_spec.rb b/spec/finders/projects/topics_finder_spec.rb index 28802c5d49e..3812f0757bc 100644 --- a/spec/finders/projects/topics_finder_spec.rb +++ b/spec/finders/projects/topics_finder_spec.rb @@ -9,9 +9,9 @@ RSpec.describe Projects::TopicsFinder do let!(:topic2) { create(:topic, name: 'topicC') } let!(:topic3) { create(:topic, name: 'topicA') } - let!(:project1) { create(:project, namespace: user.namespace, topic_list: 'topicC, topicA, topicB') } - let!(:project2) { create(:project, namespace: user.namespace, topic_list: 'topicC, topicA') } - let!(:project3) { create(:project, namespace: user.namespace, topic_list: 'topicC') } + let!(:project1) { create(:project, :public, namespace: user.namespace, topic_list: 'topicC, topicA, topicB') } + let!(:project2) { create(:project, :public, namespace: user.namespace, topic_list: 'topicC, topicA') } + let!(:project3) { create(:project, :public, namespace: user.namespace, topic_list: 'topicC') } describe '#execute' do it 'returns topics' do diff --git a/spec/frontend/runner/components/runner_list_spec.js b/spec/frontend/runner/components/runner_list_spec.js index a7d3217fc2a..1720e42bbd4 100644 --- a/spec/frontend/runner/components/runner_list_spec.js +++ b/spec/frontend/runner/components/runner_list_spec.js @@ -1,4 +1,4 @@ -import { GlTable, GlSkeletonLoader } from '@gitlab/ui'; +import { GlTableLite, GlSkeletonLoader } from '@gitlab/ui'; import { extendedWrapper, shallowMountExtended, @@ -18,7 +18,7 @@ describe('RunnerList', () => { let wrapper; const findSkeletonLoader = () => wrapper.findComponent(GlSkeletonLoader); - const findTable = () => wrapper.findComponent(GlTable); + const findTable = () => wrapper.findComponent(GlTableLite); const findHeaders = () => wrapper.findAll('th'); const findRows = () => wrapper.findAll('[data-testid^="runner-row-"]'); const findCell = ({ row = 0, fieldKey }) => @@ -144,7 +144,8 @@ describe('RunnerList', () => { describe('When data is loading', () => { it('shows a busy state', () => { createComponent({ props: { runners: [], loading: true } }); - expect(findTable().attributes('busy')).toBeTruthy(); + + expect(findTable().classes('gl-opacity-6')).toBe(true); }); it('when there are no runners, shows an skeleton loader', () => { diff --git a/spec/graphql/resolvers/topics_resolver_spec.rb b/spec/graphql/resolvers/topics_resolver_spec.rb index 3ff1dabc927..89f4583bce8 100644 --- a/spec/graphql/resolvers/topics_resolver_spec.rb +++ b/spec/graphql/resolvers/topics_resolver_spec.rb @@ -6,9 +6,9 @@ RSpec.describe Resolvers::TopicsResolver do include GraphqlHelpers describe '#resolve' do - let!(:topic1) { create(:topic, name: 'GitLab', total_projects_count: 1) } - let!(:topic2) { create(:topic, name: 'git', total_projects_count: 2) } - let!(:topic3) { create(:topic, name: 'topic3', total_projects_count: 3) } + let!(:topic1) { create(:topic, name: 'GitLab', non_private_projects_count: 1) } + let!(:topic2) { create(:topic, name: 'git', non_private_projects_count: 2) } + let!(:topic3) { create(:topic, name: 'topic3', non_private_projects_count: 3) } it 'finds all topics' do expect(resolve_topics).to eq([topic3, topic2, topic1]) diff --git a/spec/models/projects/topic_spec.rb b/spec/models/projects/topic_spec.rb index b2d407d3298..aa3230da1e6 100644 --- a/spec/models/projects/topic_spec.rb +++ b/spec/models/projects/topic_spec.rb @@ -28,16 +28,16 @@ RSpec.describe Projects::Topic do end describe 'scopes' do - describe 'order_by_total_projects_count' do + describe 'order_by_non_private_projects_count' do let!(:topic1) { create(:topic, name: 'topicB') } let!(:topic2) { create(:topic, name: 'topicC') } let!(:topic3) { create(:topic, name: 'topicA') } - let!(:project1) { create(:project, topic_list: 'topicC, topicA, topicB') } - let!(:project2) { create(:project, topic_list: 'topicC, topicA') } - let!(:project3) { create(:project, topic_list: 'topicC') } + let!(:project1) { create(:project, :public, topic_list: 'topicC, topicA, topicB') } + let!(:project2) { create(:project, :public, topic_list: 'topicC, topicA') } + let!(:project3) { create(:project, :public, topic_list: 'topicC') } - it 'sorts topics by total_projects_count' do - topics = described_class.order_by_total_projects_count + it 'sorts topics by non_private_projects_count' do + topics = described_class.order_by_non_private_projects_count expect(topics.map(&:name)).to eq(%w[topicC topicA topicB topic]) end diff --git a/spec/requests/api/topics_spec.rb b/spec/requests/api/topics_spec.rb index 68c8f5fdc43..fd9f306128f 100644 --- a/spec/requests/api/topics_spec.rb +++ b/spec/requests/api/topics_spec.rb @@ -7,9 +7,9 @@ RSpec.describe API::Topics do let_it_be(:file) { fixture_file_upload('spec/fixtures/dk.png') } - let_it_be(:topic_1) { create(:topic, name: 'Git', total_projects_count: 1, avatar: file) } - let_it_be(:topic_2) { create(:topic, name: 'GitLab', total_projects_count: 2) } - let_it_be(:topic_3) { create(:topic, name: 'other-topic', total_projects_count: 3) } + let_it_be(:topic_1) { create(:topic, name: 'Git', total_projects_count: 1, non_private_projects_count: 1, avatar: file) } + let_it_be(:topic_2) { create(:topic, name: 'GitLab', total_projects_count: 2, non_private_projects_count: 2) } + let_it_be(:topic_3) { create(:topic, name: 'other-topic', total_projects_count: 3, non_private_projects_count: 3) } let_it_be(:admin) { create(:user, :admin) } let_it_be(:user) { create(:user) }