diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-13 00:09:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-13 00:09:47 +0300 |
commit | a7e58fa022db10d17e085eb265871e2436914c9b (patch) | |
tree | 6b8dacb6d8d6a47bd3c0b606162c999124dca75d | |
parent | 04a7fe4f4b1a693f14a676c5aa556bcdfac9d899 (diff) |
Add latest changes from gitlab-org/gitlab@master
54 files changed, 107 insertions, 220 deletions
diff --git a/.gitlab/ci/memory.gitlab-ci.yml b/.gitlab/ci/memory.gitlab-ci.yml index f3ad8f81da5..9234b116ff8 100644 --- a/.gitlab/ci/memory.gitlab-ci.yml +++ b/.gitlab/ci/memory.gitlab-ci.yml @@ -4,6 +4,12 @@ - .rails-cache - .default-before_script - .memory:rules + variables: + METRICS_FILE: "metrics.txt" + artifacts: + reports: + metrics: "${METRICS_FILE}" + expire_in: 31d memory-static: extends: .only-code-memory-job-base @@ -11,24 +17,25 @@ memory-static: needs: ["setup-test-env"] variables: SETUP_DB: "false" + MEMORY_BUNDLE_MEM_FILE: "tmp/memory_bundle_mem.txt" + MEMORY_BUNDLE_OBJECTS_FILE: "tmp/memory_bundle_objects.txt" script: # Uses two different reports from the 'derailed_benchmars' gem. # Loads each of gems in the Gemfile and checks how much memory they consume when they are required. # 'derailed_benchmarks' internally uses 'get_process_mem' - - bundle exec derailed bundle:mem > tmp/memory_bundle_mem.txt - - scripts/generate-gems-size-metrics-static tmp/memory_bundle_mem.txt >> 'tmp/memory_metrics.txt' + - bundle exec derailed bundle:mem > "${MEMORY_BUNDLE_MEM_FILE}" + - scripts/generate-gems-size-metrics-static "${MEMORY_BUNDLE_MEM_FILE}" >> "${METRICS_FILE}" # Outputs detailed information about objects created while gems are loaded. # 'derailed_benchmarks' internally uses 'memory_profiler' - - bundle exec derailed bundle:objects > tmp/memory_bundle_objects.txt - - scripts/generate-gems-memory-metrics-static tmp/memory_bundle_objects.txt >> 'tmp/memory_metrics.txt' + - bundle exec derailed bundle:objects > "${MEMORY_BUNDLE_OBJECTS_FILE}" + - scripts/generate-gems-memory-metrics-static "${MEMORY_BUNDLE_OBJECTS_FILE}" >> "${METRICS_FILE}" artifacts: paths: - - tmp/memory_*.txt - reports: - metrics: tmp/memory_metrics.txt - expire_in: 31d + - "${METRICS_FILE}" + - "${MEMORY_BUNDLE_MEM_FILE}" + - "${MEMORY_BUNDLE_OBJECTS_FILE}" # Show memory usage caused by invoking require per gem. # Unlike `memory-static`, it hits the app with one request to ensure that any last minute require-s have been called. @@ -44,12 +51,11 @@ memory-on-boot: NODE_ENV: "production" RAILS_ENV: "production" SETUP_DB: "true" + MEMORY_ON_BOOT_FILE: "tmp/memory_on_boot.txt" script: - - PATH_TO_HIT="/users/sign_in" CUT_OFF=0.3 bundle exec derailed exec perf:mem >> 'tmp/memory_on_boot.txt' - - scripts/generate-memory-metrics-on-boot tmp/memory_on_boot.txt >> 'tmp/memory_on_boot_metrics.txt' + - PATH_TO_HIT="/users/sign_in" CUT_OFF=0.3 bundle exec derailed exec perf:mem >> "${MEMORY_ON_BOOT_FILE}" + - scripts/generate-memory-metrics-on-boot "${MEMORY_ON_BOOT_FILE}" >> "${METRICS_FILE}" artifacts: paths: - - tmp/memory_*.txt - reports: - metrics: tmp/memory_on_boot_metrics.txt - expire_in: 31d + - "${METRICS_FILE}" + - "${MEMORY_ON_BOOT_FILE}" diff --git a/app/assets/javascripts/lib/utils/constants.js b/app/assets/javascripts/lib/utils/constants.js index e41de72ded4..0e5a23a5cbb 100644 --- a/app/assets/javascripts/lib/utils/constants.js +++ b/app/assets/javascripts/lib/utils/constants.js @@ -20,3 +20,7 @@ export const BV_DROPDOWN_HIDE = 'bv::dropdown::hide'; export const DEFAULT_TH_CLASSES = 'gl-bg-transparent! gl-border-b-solid! gl-border-b-gray-100! gl-p-5! gl-border-b-1!'; + +// We set the drawer's z-index to 252 to clear flash messages that might +// be displayed in the page and that have a z-index of 251. +export const DRAWER_Z_INDEX = 252; diff --git a/app/assets/javascripts/merge_request.js b/app/assets/javascripts/merge_request.js index ed32f26583e..244cf1e150a 100644 --- a/app/assets/javascripts/merge_request.js +++ b/app/assets/javascripts/merge_request.js @@ -2,6 +2,7 @@ import $ from 'jquery'; import createFlash from '~/flash'; +import toast from '~/vue_shared/plugins/global_toast'; import { __ } from '~/locale'; import eventHub from '~/vue_merge_request_widget/event_hub'; import axios from './lib/utils/axios_utils'; @@ -136,10 +137,9 @@ MergeRequest.hideCloseButton = function () { MergeRequest.toggleDraftStatus = function (title, isReady) { if (isReady) { - createFlash({ - message: __('Marked as ready. Merging is now allowed.'), - type: 'notice', - }); + toast(__('Marked as ready. Merging is now allowed.')); + } else { + toast(__('Marked as draft. Can only be merged when marked as ready.')); } const titleEl = document.querySelector('.merge-request .detail-page-description .title'); diff --git a/app/assets/javascripts/vue_merge_request_widget/components/states/work_in_progress.vue b/app/assets/javascripts/vue_merge_request_widget/components/states/work_in_progress.vue index 393c599c7e8..790870ee4c6 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/states/work_in_progress.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/states/work_in_progress.vue @@ -3,6 +3,7 @@ import { GlButton } from '@gitlab/ui'; import { produce } from 'immer'; import $ from 'jquery'; import createFlash from '~/flash'; +import toast from '~/vue_shared/plugins/global_toast'; import { __ } from '~/locale'; import MergeRequest from '~/merge_request'; import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; @@ -123,10 +124,7 @@ export default { }, }, }) => { - createFlash({ - message: __('Marked as ready. Merging is now allowed.'), - type: 'notice', - }); + toast(__('Marked as ready. Merging is now allowed.')); $('.merge-request .detail-page-description .title').text(title); }, ) diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 32d02cd0712..2ecc9c27b54 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -116,6 +116,9 @@ class Namespace < ApplicationRecord # TODO: change to `type: Namespaces::UserNamespace.sti_name` when # working on issue https://gitlab.com/gitlab-org/gitlab/-/issues/341070 scope :user_namespaces, -> { where(type: [nil, Namespaces::UserNamespace.sti_name]) } + # TODO: this can be simplified with `type != 'Project'` when working on issue + # https://gitlab.com/gitlab-org/gitlab/-/issues/341070 + scope :without_project_namespaces, -> { where("type IS DISTINCT FROM ?", Namespaces::ProjectNamespace.sti_name) } scope :sort_by_type, -> { order(Gitlab::Database.nulls_first_order(:type)) } scope :include_route, -> { includes(:route) } scope :by_parent, -> (parent) { where(parent_id: parent) } diff --git a/doc/administration/auth/ldap/index.md b/doc/administration/auth/ldap/index.md index 7ffb5f1447a..2a503e018a0 100644 --- a/doc/administration/auth/ldap/index.md +++ b/doc/administration/auth/ldap/index.md @@ -39,7 +39,9 @@ the LDAP server, or share email addresses. ### User deletion Users deleted from the LDAP server are immediately blocked from signing in -to GitLab. However, there's an LDAP check cache time of one hour (which is +to GitLab and [no longer consumes a +license](../../../user/admin_area/moderate_users.md). +However, there's an LDAP check cache time of one hour (which is [configurable](#adjust-ldap-user-sync-schedule) for GitLab Premium users). This means users already signed-in or who are using Git over SSH can access GitLab for up to one hour. Manually block the user in the GitLab Admin Area diff --git a/doc/development/testing_guide/frontend_testing.md b/doc/development/testing_guide/frontend_testing.md index 2708159979e..9ce334193d3 100644 --- a/doc/development/testing_guide/frontend_testing.md +++ b/doc/development/testing_guide/frontend_testing.md @@ -848,10 +848,6 @@ describe GraphQL::Query, type: :request do all_releases_query_path = 'releases/graphql/queries/all_releases.query.graphql' - before(:all) do - clean_frontend_fixtures('graphql/releases/') - end - it "graphql/#{all_releases_query_path}.json" do query = get_graphql_query_as_string(all_releases_query_path) diff --git a/doc/user/admin_area/moderate_users.md b/doc/user/admin_area/moderate_users.md index bc946177b98..c8f160f729f 100644 --- a/doc/user/admin_area/moderate_users.md +++ b/doc/user/admin_area/moderate_users.md @@ -73,7 +73,7 @@ In order to completely prevent access of a user to the GitLab instance, administrators can choose to block the user. Users can be blocked [via an abuse report](review_abuse_reports.md#blocking-users), -or directly from the Admin Area. To do this: +by removing them in LDAP, or directly from the Admin Area. To do this: 1. On the top bar, select **Menu > Admin**. 1. On the left sidebar, select **Overview > Users**. diff --git a/lib/tasks/frontend.rake b/lib/tasks/frontend.rake index 95f26cc0800..e768c42736d 100644 --- a/lib/tasks/frontend.rake +++ b/lib/tasks/frontend.rake @@ -1,10 +1,14 @@ # frozen_string_literal: true -require 'yaml' unless Rails.env.production? namespace :frontend do desc 'GitLab | Frontend | Generate fixtures for JavaScript tests' RSpec::Core::RakeTask.new(:fixtures, [:pattern]) do |t, args| + require 'fileutils' + require_relative '../../spec/support/helpers/javascript_fixtures_helpers' + + FileUtils.rm_r(JavaScriptFixturesHelpers.fixture_root_path, force: true) + directories = %w[spec] directories << 'ee/spec' if Gitlab.ee? directory_glob = "{#{directories.join(',')}}" @@ -16,6 +20,8 @@ unless Rails.env.production? desc 'GitLab | Frontend | Generate fixtures for JavaScript integration tests' RSpec::Core::RakeTask.new(:mock_server_rspec_fixtures) do |t, args| + require 'yaml' + base_path = Pathname.new('spec/frontend_integration/fixture_generators.yml') ee_path = Pathname.new('ee') + base_path diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 571ff7c215a..a125c463087 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -20889,6 +20889,9 @@ msgstr "" msgid "Marked For Deletion At - %{deletion_time}" msgstr "" +msgid "Marked as draft. Can only be merged when marked as ready." +msgstr "" + msgid "Marked as ready. Merging is now allowed." msgstr "" @@ -23724,6 +23727,9 @@ msgstr "" msgid "OnCallSchedules|Your schedule has been successfully created. To add individual users to this schedule, use the Add a rotation button. To enable notifications for this schedule, you must also create an %{linkStart}escalation policy%{linkEnd}." msgstr "" +msgid "OnDemandScans|%{learnMoreLinkStart}Lean more about on-demand scans%{learnMoreLinkEnd}." +msgstr "" + msgid "OnDemandScans|Could not fetch scanner profiles. Please refresh the page, or try again later." msgstr "" @@ -23808,6 +23814,15 @@ msgstr "" msgid "OnDemandScans|Start time" msgstr "" +msgid "OnDemandScans|There are no finished scans." +msgstr "" + +msgid "OnDemandScans|There are no running scans." +msgstr "" + +msgid "OnDemandScans|There are no scheduled scans." +msgstr "" + msgid "OnDemandScans|Use existing scanner profile" msgstr "" diff --git a/scripts/utils.sh b/scripts/utils.sh index d2e8c151438..faabc151963 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -60,7 +60,7 @@ function setup_db_user_only() { function setup_db() { run_timed_command "setup_db_user_only" - run_timed_command "bundle exec rake db:drop db:create db:structure:load db:migrate gitlab:db:setup_ee" + run_timed_command_with_metric "bundle exec rake db:drop db:create db:structure:load db:migrate gitlab:db:setup_ee" "setup_db" } function install_api_client_dependencies_with_apk() { @@ -78,15 +78,27 @@ function install_tff_gem() { function run_timed_command() { local cmd="${1}" + local metric_name="${2}" + local timed_metric_file local start=$(date +%s) + echosuccess "\$ ${cmd}" eval "${cmd}" + local ret=$? local end=$(date +%s) local runtime=$((end-start)) if [[ $ret -eq 0 ]]; then echosuccess "==> '${cmd}' succeeded in ${runtime} seconds." + + if [[ -n "${metric_name}" ]]; then + timed_metric_file=$(timed_metric_file $metric_name) + echo "# TYPE ${metric_name} gauge" > "${timed_metric_file}" + echo "# UNIT ${metric_name} seconds" >> "${timed_metric_file}" + echo "${metric_name} ${runtime}" >> "${timed_metric_file}" + fi + return 0 else echoerr "==> '${cmd}' failed (${ret}) in ${runtime} seconds." @@ -94,6 +106,26 @@ function run_timed_command() { fi } +function run_timed_command_with_metric() { + local cmd="${1}" + local metric_name="${2}" + local metrics_file=${METRICS_FILE:-metrics.txt} + + run_timed_command "${cmd}" "${metric_name}" + + local ret=$? + + cat $(timed_metric_file $metric_name) >> "${metrics_file}" + + return $ret +} + +function timed_metric_file() { + local metric_name="${1}" + + echo "$(pwd)/tmp/duration_${metric_name}.txt" +} + function echoerr() { local header="${2}" diff --git a/spec/frontend/fixtures/abuse_reports.rb b/spec/frontend/fixtures/abuse_reports.rb index f5524a10033..d8c8737b125 100644 --- a/spec/frontend/fixtures/abuse_reports.rb +++ b/spec/frontend/fixtures/abuse_reports.rb @@ -13,10 +13,6 @@ RSpec.describe Admin::AbuseReportsController, '(JavaScript fixtures)', type: :co render_views - before(:all) do - clean_frontend_fixtures('abuse_reports/') - end - before do sign_in(admin) enable_admin_mode!(admin) diff --git a/spec/frontend/fixtures/admin_users.rb b/spec/frontend/fixtures/admin_users.rb index e0fecbdb1aa..5579f50da74 100644 --- a/spec/frontend/fixtures/admin_users.rb +++ b/spec/frontend/fixtures/admin_users.rb @@ -17,10 +17,6 @@ RSpec.describe Admin::UsersController, '(JavaScript fixtures)', type: :controlle render_views - before(:all) do - clean_frontend_fixtures('admin/users') - end - it 'admin/users/new_with_internal_user_regex.html' do stub_application_setting(user_default_external: true) stub_application_setting(user_default_internal_regex: '^(?:(?!\.ext@).)*$\r?') diff --git a/spec/frontend/fixtures/analytics.rb b/spec/frontend/fixtures/analytics.rb index 6d106dce166..4a13d5051a8 100644 --- a/spec/frontend/fixtures/analytics.rb +++ b/spec/frontend/fixtures/analytics.rb @@ -6,10 +6,6 @@ RSpec.describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do let_it_be(:value_stream_id) { 'default' } - before(:all) do - clean_frontend_fixtures('projects/analytics/value_stream_analytics/') - end - before do update_metrics create_deployment diff --git a/spec/frontend/fixtures/api_markdown.rb b/spec/frontend/fixtures/api_markdown.rb index cb9a116f293..89f012a5110 100644 --- a/spec/frontend/fixtures/api_markdown.rb +++ b/spec/frontend/fixtures/api_markdown.rb @@ -21,11 +21,7 @@ RSpec.describe API::MergeRequests, '(JavaScript fixtures)', type: :request do let(:project_wiki_page) { create(:wiki_page, wiki: project_wiki) } - fixture_subdir = 'api/markdown' - before(:all) do - clean_frontend_fixtures(fixture_subdir) - group.add_owner(user) project.add_maintainer(user) end @@ -49,7 +45,7 @@ RSpec.describe API::MergeRequests, '(JavaScript fixtures)', type: :request do name = "#{context}_#{name}" unless context.empty? - it "#{fixture_subdir}/#{name}.json" do + it "api/markdown/#{name}.json" do api_url = case context when 'project' "/#{project.full_path}/preview_markdown" diff --git a/spec/frontend/fixtures/api_merge_requests.rb b/spec/frontend/fixtures/api_merge_requests.rb index 7117c9a1c7a..47321fbbeaa 100644 --- a/spec/frontend/fixtures/api_merge_requests.rb +++ b/spec/frontend/fixtures/api_merge_requests.rb @@ -11,10 +11,6 @@ RSpec.describe API::MergeRequests, '(JavaScript fixtures)', type: :request do let_it_be(:project) { create(:project, :repository, namespace: namespace, path: 'lorem-ipsum') } let_it_be(:mr) { create(:merge_request, source_project: project) } - before(:all) do - clean_frontend_fixtures('api/merge_requests') - end - it 'api/merge_requests/get.json' do 4.times { |i| create(:merge_request, source_project: project, source_branch: "branch-#{i}") } diff --git a/spec/frontend/fixtures/api_projects.rb b/spec/frontend/fixtures/api_projects.rb index fa77ca1c0cf..eada2f8e0f7 100644 --- a/spec/frontend/fixtures/api_projects.rb +++ b/spec/frontend/fixtures/api_projects.rb @@ -11,10 +11,6 @@ RSpec.describe API::Projects, '(JavaScript fixtures)', type: :request do let(:project) { create(:project, :repository, namespace: namespace, path: 'lorem-ipsum') } let(:project_empty) { create(:project_empty_repo, namespace: namespace, path: 'lorem-ipsum-empty') } - before(:all) do - clean_frontend_fixtures('api/projects') - end - it 'api/projects/get.json' do get api("/projects/#{project.id}", admin) diff --git a/spec/frontend/fixtures/application_settings.rb b/spec/frontend/fixtures/application_settings.rb index b09bea56b94..9fa8d68e695 100644 --- a/spec/frontend/fixtures/application_settings.rb +++ b/spec/frontend/fixtures/application_settings.rb @@ -19,10 +19,6 @@ RSpec.describe Admin::ApplicationSettingsController, '(JavaScript fixtures)', ty render_views - before(:all) do - clean_frontend_fixtures('application_settings/') - end - after do remove_repository(project) end diff --git a/spec/frontend/fixtures/autocomplete.rb b/spec/frontend/fixtures/autocomplete.rb index 8983e241aa5..6215fa44e27 100644 --- a/spec/frontend/fixtures/autocomplete.rb +++ b/spec/frontend/fixtures/autocomplete.rb @@ -11,10 +11,6 @@ RSpec.describe ::AutocompleteController, '(JavaScript fixtures)', type: :control let(:project) { create(:project, namespace: group, path: 'autocomplete-project') } let(:merge_request) { create(:merge_request, source_project: project, author: user) } - before(:all) do - clean_frontend_fixtures('autocomplete/') - end - before do group.add_owner(user) sign_in(user) diff --git a/spec/frontend/fixtures/autocomplete_sources.rb b/spec/frontend/fixtures/autocomplete_sources.rb index 9ff0f959c11..74bf58cc106 100644 --- a/spec/frontend/fixtures/autocomplete_sources.rb +++ b/spec/frontend/fixtures/autocomplete_sources.rb @@ -10,10 +10,6 @@ RSpec.describe Projects::AutocompleteSourcesController, '(JavaScript fixtures)', let_it_be(:project) { create(:project, namespace: group, path: 'autocomplete-sources-project') } let_it_be(:issue) { create(:issue, project: project) } - before(:all) do - clean_frontend_fixtures('autocomplete_sources/') - end - before do group.add_owner(user) sign_in(user) diff --git a/spec/frontend/fixtures/blob.rb b/spec/frontend/fixtures/blob.rb index b112886b2ca..f90e3662e98 100644 --- a/spec/frontend/fixtures/blob.rb +++ b/spec/frontend/fixtures/blob.rb @@ -11,10 +11,6 @@ RSpec.describe Projects::BlobController, '(JavaScript fixtures)', type: :control render_views - before(:all) do - clean_frontend_fixtures('blob/') - end - before do sign_in(user) allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon') diff --git a/spec/frontend/fixtures/branches.rb b/spec/frontend/fixtures/branches.rb index f3b3633347d..828564977e0 100644 --- a/spec/frontend/fixtures/branches.rb +++ b/spec/frontend/fixtures/branches.rb @@ -9,11 +9,6 @@ RSpec.describe 'Branches (JavaScript fixtures)' do let_it_be(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') } let_it_be(:user) { project.owner } - before(:all) do - clean_frontend_fixtures('branches/') - clean_frontend_fixtures('api/branches/') - end - after(:all) do remove_repository(project) end diff --git a/spec/frontend/fixtures/clusters.rb b/spec/frontend/fixtures/clusters.rb index b37aa137504..ea883555255 100644 --- a/spec/frontend/fixtures/clusters.rb +++ b/spec/frontend/fixtures/clusters.rb @@ -12,10 +12,6 @@ RSpec.describe Projects::ClustersController, '(JavaScript fixtures)', type: :con render_views - before(:all) do - clean_frontend_fixtures('clusters/') - end - before do sign_in(user) end diff --git a/spec/frontend/fixtures/commit.rb b/spec/frontend/fixtures/commit.rb index ff62a8286fc..f9e0f604b52 100644 --- a/spec/frontend/fixtures/commit.rb +++ b/spec/frontend/fixtures/commit.rb @@ -9,11 +9,6 @@ RSpec.describe 'Commit (JavaScript fixtures)' do let_it_be(:user) { project.owner } let_it_be(:commit) { project.commit("master") } - before(:all) do - clean_frontend_fixtures('commit/') - clean_frontend_fixtures('api/commits/') - end - before do allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon') end diff --git a/spec/frontend/fixtures/deploy_keys.rb b/spec/frontend/fixtures/deploy_keys.rb index 5c24c071792..bed6c798793 100644 --- a/spec/frontend/fixtures/deploy_keys.rb +++ b/spec/frontend/fixtures/deploy_keys.rb @@ -13,10 +13,6 @@ RSpec.describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :c let(:project3) { create(:project, :internal)} let(:project4) { create(:project, :internal)} - before(:all) do - clean_frontend_fixtures('deploy_keys/') - end - before do # Using an admin for these fixtures because they are used for verifying a frontend # component that would normally get its data from `Admin::DeployKeysController` diff --git a/spec/frontend/fixtures/freeze_period.rb b/spec/frontend/fixtures/freeze_period.rb index 42762fa56f9..d9573c8000d 100644 --- a/spec/frontend/fixtures/freeze_period.rb +++ b/spec/frontend/fixtures/freeze_period.rb @@ -9,10 +9,6 @@ RSpec.describe 'Freeze Periods (JavaScript fixtures)' do let_it_be(:project) { create(:project, :repository, path: 'freeze-periods-project') } let_it_be(:user) { project.owner } - before(:all) do - clean_frontend_fixtures('api/freeze-periods/') - end - after(:all) do remove_repository(project) end diff --git a/spec/frontend/fixtures/groups.rb b/spec/frontend/fixtures/groups.rb index 42aad9f187e..ddd436b98c6 100644 --- a/spec/frontend/fixtures/groups.rb +++ b/spec/frontend/fixtures/groups.rb @@ -8,10 +8,6 @@ RSpec.describe 'Groups (JavaScript fixtures)', type: :controller do let(:user) { create(:user) } let(:group) { create(:group, name: 'frontend-fixtures-group', runners_token: 'runnerstoken:intabulasreferre')} - before(:all) do - clean_frontend_fixtures('groups/') - end - before do group.add_owner(user) sign_in(user) diff --git a/spec/frontend/fixtures/issues.rb b/spec/frontend/fixtures/issues.rb index a027247bd0d..6519416cb9e 100644 --- a/spec/frontend/fixtures/issues.rb +++ b/spec/frontend/fixtures/issues.rb @@ -11,10 +11,6 @@ RSpec.describe Projects::IssuesController, '(JavaScript fixtures)', type: :contr render_views - before(:all) do - clean_frontend_fixtures('issues/') - end - before do project.add_maintainer(user) sign_in(user) diff --git a/spec/frontend/fixtures/jobs.rb b/spec/frontend/fixtures/jobs.rb index 22179c790bd..12584f38629 100644 --- a/spec/frontend/fixtures/jobs.rb +++ b/spec/frontend/fixtures/jobs.rb @@ -21,10 +21,6 @@ RSpec.describe Projects::JobsController, '(JavaScript fixtures)', type: :control render_views - before(:all) do - clean_frontend_fixtures('jobs/') - end - before do sign_in(user) end diff --git a/spec/frontend/fixtures/labels.rb b/spec/frontend/fixtures/labels.rb index d7ca2aff18c..6736baed199 100644 --- a/spec/frontend/fixtures/labels.rb +++ b/spec/frontend/fixtures/labels.rb @@ -17,10 +17,6 @@ RSpec.describe 'Labels (JavaScript fixtures)' do let!(:groub_label_space) { create(:group_label, group: group, title: 'some space', color: '#FFFFFF') } let!(:groub_label_violets) { create(:group_label, group: group, title: 'violets', color: '#0000FF') } - before(:all) do - clean_frontend_fixtures('labels/') - end - after do remove_repository(project) end diff --git a/spec/frontend/fixtures/merge_requests.rb b/spec/frontend/fixtures/merge_requests.rb index f10f96f2516..68ed2ca2359 100644 --- a/spec/frontend/fixtures/merge_requests.rb +++ b/spec/frontend/fixtures/merge_requests.rb @@ -49,10 +49,6 @@ RSpec.describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: render_views - before(:all) do - clean_frontend_fixtures('merge_requests/') - end - before do sign_in(user) allow(Discussion).to receive(:build_discussion_id).and_return(['discussionid:ceterumcenseo']) diff --git a/spec/frontend/fixtures/merge_requests_diffs.rb b/spec/frontend/fixtures/merge_requests_diffs.rb index edf1fcf3c0a..e733764f248 100644 --- a/spec/frontend/fixtures/merge_requests_diffs.rb +++ b/spec/frontend/fixtures/merge_requests_diffs.rb @@ -20,10 +20,6 @@ RSpec.describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)' render_views - before(:all) do - clean_frontend_fixtures('merge_request_diffs/') - end - before do # Create a user that matches the project.commit author # This is so that the "author" information will be populated diff --git a/spec/frontend/fixtures/metrics_dashboard.rb b/spec/frontend/fixtures/metrics_dashboard.rb index eef79825ae7..d59b01b04af 100644 --- a/spec/frontend/fixtures/metrics_dashboard.rb +++ b/spec/frontend/fixtures/metrics_dashboard.rb @@ -12,10 +12,6 @@ RSpec.describe MetricsDashboard, '(JavaScript fixtures)', type: :controller do let_it_be(:environment) { create(:environment, id: 1, project: project) } let_it_be(:params) { { environment: environment } } - before(:all) do - clean_frontend_fixtures('metrics_dashboard/') - end - controller(::ApplicationController) do include MetricsDashboard end diff --git a/spec/frontend/fixtures/pipeline_schedules.rb b/spec/frontend/fixtures/pipeline_schedules.rb index a7d43fdbe62..6389f59aa0a 100644 --- a/spec/frontend/fixtures/pipeline_schedules.rb +++ b/spec/frontend/fixtures/pipeline_schedules.rb @@ -15,10 +15,6 @@ RSpec.describe Projects::PipelineSchedulesController, '(JavaScript fixtures)', t render_views - before(:all) do - clean_frontend_fixtures('pipeline_schedules/') - end - before do sign_in(user) end diff --git a/spec/frontend/fixtures/pipelines.rb b/spec/frontend/fixtures/pipelines.rb index f695b74ec87..709e14183df 100644 --- a/spec/frontend/fixtures/pipelines.rb +++ b/spec/frontend/fixtures/pipelines.rb @@ -23,10 +23,6 @@ RSpec.describe Projects::PipelinesController, '(JavaScript fixtures)', type: :co let!(:build_test) { create(:ci_build, pipeline: pipeline, stage: 'test') } let!(:build_deploy_failed) { create(:ci_build, status: :failed, pipeline: pipeline, stage: 'deploy') } - before(:all) do - clean_frontend_fixtures('pipelines/') - end - before do sign_in(user) end diff --git a/spec/frontend/fixtures/projects.rb b/spec/frontend/fixtures/projects.rb index 7873d59dbad..3c8964d398a 100644 --- a/spec/frontend/fixtures/projects.rb +++ b/spec/frontend/fixtures/projects.rb @@ -16,10 +16,6 @@ RSpec.describe 'Projects (JavaScript fixtures)', type: :controller do render_views - before(:all) do - clean_frontend_fixtures('projects/') - end - before do project_with_repo.add_maintainer(user) sign_in(user) @@ -57,10 +53,6 @@ RSpec.describe 'Projects (JavaScript fixtures)', type: :controller do project_variable_populated.add_maintainer(user) end - before(:all) do - clean_frontend_fixtures('graphql/projects/access_tokens') - end - base_input_path = 'access_tokens/graphql/queries/' base_output_path = 'graphql/projects/access_tokens/' query_name = 'get_projects.query.graphql' diff --git a/spec/frontend/fixtures/projects_json.rb b/spec/frontend/fixtures/projects_json.rb index c081d4f08dc..c4de56ccfab 100644 --- a/spec/frontend/fixtures/projects_json.rb +++ b/spec/frontend/fixtures/projects_json.rb @@ -8,10 +8,6 @@ RSpec.describe 'Projects JSON endpoints (JavaScript fixtures)', type: :controlle let(:admin) { create(:admin, name: 'root') } let(:project) { create(:project, :repository) } - before(:all) do - clean_frontend_fixtures('projects_json/') - end - before do project.add_maintainer(admin) sign_in(admin) diff --git a/spec/frontend/fixtures/prometheus_service.rb b/spec/frontend/fixtures/prometheus_service.rb index c349f2a24bc..bbd938c66f6 100644 --- a/spec/frontend/fixtures/prometheus_service.rb +++ b/spec/frontend/fixtures/prometheus_service.rb @@ -12,10 +12,6 @@ RSpec.describe Projects::ServicesController, '(JavaScript fixtures)', type: :con render_views - before(:all) do - clean_frontend_fixtures('services/prometheus') - end - before do sign_in(user) end diff --git a/spec/frontend/fixtures/raw.rb b/spec/frontend/fixtures/raw.rb index 44927bd29d8..211c4e7c048 100644 --- a/spec/frontend/fixtures/raw.rb +++ b/spec/frontend/fixtures/raw.rb @@ -9,14 +9,6 @@ RSpec.describe 'Raw files', '(JavaScript fixtures)' do let(:project) { create(:project, :repository, namespace: namespace, path: 'raw-project') } let(:response) { @blob.data.force_encoding('UTF-8') } - before(:all) do - clean_frontend_fixtures('blob/notebook/') - clean_frontend_fixtures('blob/pdf/') - clean_frontend_fixtures('blob/text/') - clean_frontend_fixtures('blob/binary/') - clean_frontend_fixtures('blob/images/') - end - after do remove_repository(project) end diff --git a/spec/frontend/fixtures/releases.rb b/spec/frontend/fixtures/releases.rb index e8f259fba15..fc344472588 100644 --- a/spec/frontend/fixtures/releases.rb +++ b/spec/frontend/fixtures/releases.rb @@ -116,10 +116,6 @@ RSpec.describe 'Releases (JavaScript fixtures)' do end describe API::Releases, type: :request do - before(:all) do - clean_frontend_fixtures('api/releases/') - end - it 'api/releases/release.json' do get api("/projects/#{project.id}/releases/#{release.tag}", admin) @@ -134,10 +130,6 @@ RSpec.describe 'Releases (JavaScript fixtures)' do one_release_query_path = 'releases/graphql/queries/one_release.query.graphql' one_release_for_editing_query_path = 'releases/graphql/queries/one_release_for_editing.query.graphql' - before(:all) do - clean_frontend_fixtures('graphql/releases/') - end - it "graphql/#{all_releases_query_path}.json" do query = get_graphql_query_as_string(all_releases_query_path) diff --git a/spec/frontend/fixtures/runner.rb b/spec/frontend/fixtures/runner.rb index d5d6f534def..fa150fbf57c 100644 --- a/spec/frontend/fixtures/runner.rb +++ b/spec/frontend/fixtures/runner.rb @@ -20,10 +20,6 @@ RSpec.describe 'Runner (JavaScript fixtures)' do query_path = 'runner/graphql/' fixtures_path = 'graphql/runner/' - before(:all) do - clean_frontend_fixtures(fixtures_path) - end - after(:all) do remove_repository(project) end diff --git a/spec/frontend/fixtures/search.rb b/spec/frontend/fixtures/search.rb index 264ce7d010c..db1ef67998f 100644 --- a/spec/frontend/fixtures/search.rb +++ b/spec/frontend/fixtures/search.rb @@ -9,10 +9,6 @@ RSpec.describe SearchController, '(JavaScript fixtures)', type: :controller do let_it_be(:user) { create(:user) } - before(:all) do - clean_frontend_fixtures('search/') - end - before do sign_in(user) end diff --git a/spec/frontend/fixtures/services.rb b/spec/frontend/fixtures/services.rb index 91e6c2eb280..a8293a080a9 100644 --- a/spec/frontend/fixtures/services.rb +++ b/spec/frontend/fixtures/services.rb @@ -12,10 +12,6 @@ RSpec.describe Projects::ServicesController, '(JavaScript fixtures)', type: :con render_views - before(:all) do - clean_frontend_fixtures('services/') - end - before do sign_in(user) end diff --git a/spec/frontend/fixtures/sessions.rb b/spec/frontend/fixtures/sessions.rb index 0ef14c1d4fa..bb73bf3215c 100644 --- a/spec/frontend/fixtures/sessions.rb +++ b/spec/frontend/fixtures/sessions.rb @@ -5,10 +5,6 @@ require 'spec_helper' RSpec.describe 'Sessions (JavaScript fixtures)' do include JavaScriptFixturesHelpers - before(:all) do - clean_frontend_fixtures('sessions/') - end - describe SessionsController, '(JavaScript fixtures)', type: :controller do include DeviseHelpers diff --git a/spec/frontend/fixtures/snippet.rb b/spec/frontend/fixtures/snippet.rb index 5211d52f374..397fb3e7124 100644 --- a/spec/frontend/fixtures/snippet.rb +++ b/spec/frontend/fixtures/snippet.rb @@ -12,10 +12,6 @@ RSpec.describe SnippetsController, '(JavaScript fixtures)', type: :controller do render_views - before(:all) do - clean_frontend_fixtures('snippets/') - end - before do sign_in(user) allow(Discussion).to receive(:build_discussion_id).and_return(['discussionid:ceterumcenseo']) diff --git a/spec/frontend/fixtures/startup_css.rb b/spec/frontend/fixtures/startup_css.rb index 067753207d2..e19a98c3bab 100644 --- a/spec/frontend/fixtures/startup_css.rb +++ b/spec/frontend/fixtures/startup_css.rb @@ -9,10 +9,6 @@ RSpec.describe 'Startup CSS fixtures', type: :controller do render_views - before(:all) do - clean_frontend_fixtures('startup_css/') - end - shared_examples 'startup css project fixtures' do |type| let(:user) { create(:user, :admin) } let(:project) { create(:project, :public, :repository, description: 'Code and stuff', creator: user) } diff --git a/spec/frontend/fixtures/tags.rb b/spec/frontend/fixtures/tags.rb index 9483f0a4492..6cfa5f82efe 100644 --- a/spec/frontend/fixtures/tags.rb +++ b/spec/frontend/fixtures/tags.rb @@ -8,10 +8,6 @@ RSpec.describe 'Tags (JavaScript fixtures)' do let_it_be(:project) { create(:project, :repository, path: 'tags-project') } let_it_be(:user) { project.owner } - before(:all) do - clean_frontend_fixtures('api/tags/') - end - after(:all) do remove_repository(project) end diff --git a/spec/frontend/fixtures/timezones.rb b/spec/frontend/fixtures/timezones.rb index 261dcf5e116..157f47855ea 100644 --- a/spec/frontend/fixtures/timezones.rb +++ b/spec/frontend/fixtures/timezones.rb @@ -8,10 +8,6 @@ RSpec.describe TimeZoneHelper, '(JavaScript fixtures)' do let(:response) { @timezones.sort_by! { |tz| tz[:name] }.to_json } - before(:all) do - clean_frontend_fixtures('timezones/') - end - it 'timezones/short.json' do @timezones = timezone_data(format: :short) end diff --git a/spec/frontend/fixtures/todos.rb b/spec/frontend/fixtures/todos.rb index 985afafe50e..a0573b0b658 100644 --- a/spec/frontend/fixtures/todos.rb +++ b/spec/frontend/fixtures/todos.rb @@ -13,10 +13,6 @@ RSpec.describe 'Todos (JavaScript fixtures)' do let(:issue_2) { create(:issue, title: 'issue_2', project: project) } let!(:todo_2) { create(:todo, :done, user: user, project: project, target: issue_2, created_at: 50.hours.ago) } - before(:all) do - clean_frontend_fixtures('todos/') - end - after do remove_repository(project) end diff --git a/spec/frontend/fixtures/u2f.rb b/spec/frontend/fixtures/u2f.rb index a6a8ba7318b..96820c9ae80 100644 --- a/spec/frontend/fixtures/u2f.rb +++ b/spec/frontend/fixtures/u2f.rb @@ -7,10 +7,6 @@ RSpec.context 'U2F' do let(:user) { create(:user, :two_factor_via_u2f, otp_secret: 'otpsecret:coolkids') } - before(:all) do - clean_frontend_fixtures('u2f/') - end - before do stub_feature_flags(webauthn: false) end diff --git a/spec/frontend/fixtures/webauthn.rb b/spec/frontend/fixtures/webauthn.rb index b195fee76f0..c6e9b41b584 100644 --- a/spec/frontend/fixtures/webauthn.rb +++ b/spec/frontend/fixtures/webauthn.rb @@ -7,10 +7,6 @@ RSpec.context 'WebAuthn' do let(:user) { create(:user, :two_factor_via_webauthn, otp_secret: 'otpsecret:coolkids') } - before(:all) do - clean_frontend_fixtures('webauthn/') - end - describe SessionsController, '(JavaScript fixtures)', type: :controller do include DeviseHelpers diff --git a/spec/frontend/vue_mr_widget/components/states/mr_widget_wip_spec.js b/spec/frontend/vue_mr_widget/components/states/mr_widget_wip_spec.js index 61e44140efc..be15e4df66d 100644 --- a/spec/frontend/vue_mr_widget/components/states/mr_widget_wip_spec.js +++ b/spec/frontend/vue_mr_widget/components/states/mr_widget_wip_spec.js @@ -1,9 +1,9 @@ import Vue from 'vue'; -import createFlash from '~/flash'; import WorkInProgress from '~/vue_merge_request_widget/components/states/work_in_progress.vue'; +import toast from '~/vue_shared/plugins/global_toast'; import eventHub from '~/vue_merge_request_widget/event_hub'; -jest.mock('~/flash'); +jest.mock('~/vue_shared/plugins/global_toast'); const createComponent = () => { const Component = Vue.extend(WorkInProgress); @@ -63,10 +63,7 @@ describe('Wip', () => { setImmediate(() => { expect(vm.isMakingRequest).toBeTruthy(); expect(eventHub.$emit).toHaveBeenCalledWith('UpdateWidgetData', mrObj); - expect(createFlash).toHaveBeenCalledWith({ - message: 'Marked as ready. Merging is now allowed.', - type: 'notice', - }); + expect(toast).toHaveBeenCalledWith('Marked as ready. Merging is now allowed.'); done(); }); }); diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index bc117de75cc..9363aa86140 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -299,6 +299,15 @@ RSpec.describe Namespace do expect(described_class.sorted_by_similarity_and_parent_id_desc('Namespace')).to eq([namespace2, namespace1, namespace2sub, namespace1sub, namespace]) end end + + describe '.without_project_namespaces' do + let_it_be(:user_namespace) { create(:user_namespace) } + let_it_be(:project_namespace) { create(:project_namespace) } + + it 'excludes project namespaces' do + expect(described_class.without_project_namespaces).to match_array([namespace, namespace1, namespace2, namespace1sub, namespace2sub, user_namespace, project_namespace.parent]) + end + end end describe 'delegate' do diff --git a/spec/support/helpers/javascript_fixtures_helpers.rb b/spec/support/helpers/javascript_fixtures_helpers.rb index 3adf337acfd..fb909008f12 100644 --- a/spec/support/helpers/javascript_fixtures_helpers.rb +++ b/spec/support/helpers/javascript_fixtures_helpers.rb @@ -3,6 +3,8 @@ require 'action_dispatch/testing/test_request' require 'fileutils' +require_relative '../../../lib/gitlab/popen' + module JavaScriptFixturesHelpers extend ActiveSupport::Concern include Gitlab::Popen @@ -25,15 +27,6 @@ module JavaScriptFixturesHelpers 'tmp/tests/frontend/fixtures' + (Gitlab.ee? ? '-ee' : '') end - # Public: Removes all fixture files from given directory - # - # directory_name - directory of the fixtures (relative to .fixture_root_path) - # - # TODO: Make sure this isn't called anymore. - def clean_frontend_fixtures(directory_name) - # We don't really need to cleanup fixtures, as this can be a problem when FOSS & EE fixtures try to generate files in the same folder. - end - def remove_repository(project) Gitlab::Shell.new.remove_repository(project.repository_storage, project.disk_path) end |