diff options
128 files changed, 623 insertions, 489 deletions
diff --git a/GITLAB_PAGES_VERSION b/GITLAB_PAGES_VERSION index af92bdd9f58..9405730420f 100644 --- a/GITLAB_PAGES_VERSION +++ b/GITLAB_PAGES_VERSION @@ -1 +1 @@ -1.63.0 +1.64.0 diff --git a/app/assets/javascripts/header.js b/app/assets/javascripts/header.js index 9b6113c7444..4d03a523486 100644 --- a/app/assets/javascripts/header.js +++ b/app/assets/javascripts/header.js @@ -84,6 +84,8 @@ function initStatusTriggers() { }) .catch(() => {}); }); + + setStatusModalTriggerEl.classList.add('ready'); } } diff --git a/app/assets/javascripts/monitoring/components/dashboard_panel_builder.vue b/app/assets/javascripts/monitoring/components/dashboard_panel_builder.vue index 8efea2bfc3e..e8a9c24f5c2 100644 --- a/app/assets/javascripts/monitoring/components/dashboard_panel_builder.vue +++ b/app/assets/javascripts/monitoring/components/dashboard_panel_builder.vue @@ -100,7 +100,7 @@ export default { <gl-form-textarea id="panel-yml-input" v-model="yml" - class="gl-h-200! gl-font-monospace! gl-font-size-monospace!" + class="gl-h-200! gl-font-monospace!" /> </gl-form-group> <div class="gl-text-right"> diff --git a/app/assets/stylesheets/fonts.scss b/app/assets/stylesheets/fonts.scss new file mode 100644 index 00000000000..a6ecca88bd4 --- /dev/null +++ b/app/assets/stylesheets/fonts.scss @@ -0,0 +1,32 @@ +/* ------------------------------------------------------- +Inter variable font. + +Usage: + html { font-family: 'GitLab Sans', sans-serif; } +*/ +@font-face { + font-family: 'GitLab Sans'; + font-weight: 100 900; + font-display: optional; + font-style: normal; + font-named-instance: 'Regular'; /* stylelint-disable property-no-unknown */ + src: font-url('gitlab-sans/GitLabSans.woff2') format('woff2'); +} + +/* ------------------------------------------------------- +Monospaced font: JetBrains Mono. + +Usage: + html { font-family: 'JetBrains Mono', sans-serif; } +*/ +@font-face { + font-family: 'JetBrains Mono'; + font-display: optional; + font-style: normal; + src: font-url('jetbrains-mono/JetBrainsMono.woff2') format('woff2'); +} + +:root { + --default-mono-font: 'JetBrains Mono', 'Menlo'; + --default-regular-font: 'GitLab Sans', -apple-system; +} diff --git a/app/assets/stylesheets/framework/filters.scss b/app/assets/stylesheets/framework/filters.scss index 37b61d36911..860686565c7 100644 --- a/app/assets/stylesheets/framework/filters.scss +++ b/app/assets/stylesheets/framework/filters.scss @@ -433,8 +433,7 @@ .search-token-target-branch { .value { - font-family: $monospace-font; - font-size: $gl-font-size-monospace; + @include gl-font-monospace; } } diff --git a/app/assets/stylesheets/framework/kbd.scss b/app/assets/stylesheets/framework/kbd.scss index 7dd0ae47834..a9211ef92e5 100644 --- a/app/assets/stylesheets/framework/kbd.scss +++ b/app/assets/stylesheets/framework/kbd.scss @@ -1,7 +1,7 @@ kbd { display: inline-block; padding: 3px 5px; - font-size: $gl-font-size-monospace-sm; + @include gl-font-sm; line-height: 10px; color: var(--gray-700, $gray-700); vertical-align: middle; diff --git a/app/assets/stylesheets/framework/typography.scss b/app/assets/stylesheets/framework/typography.scss index d8f0375358c..80d022e5334 100644 --- a/app/assets/stylesheets/framework/typography.scss +++ b/app/assets/stylesheets/framework/typography.scss @@ -658,7 +658,7 @@ pre { display: block; padding: $gl-padding-8 $input-horizontal-padding; margin: 0 0 $gl-padding-8; - font-size: $gl-font-size-monospace; + @include gl-font-base; word-break: break-all; word-wrap: break-word; color: $gl-text-color; @@ -680,7 +680,7 @@ code { } .monospace { - font-family: $monospace-font; + @include gl-font-monospace; } .weight-normal { @@ -706,7 +706,7 @@ code { */ textarea.js-gfm-input { font-family: $monospace-font; - font-size: $gl-font-size-monospace; + @include gl-font-base; } h1, diff --git a/app/assets/stylesheets/framework/variables.scss b/app/assets/stylesheets/framework/variables.scss index 6086405226e..9f0fb56b25e 100644 --- a/app/assets/stylesheets/framework/variables.scss +++ b/app/assets/stylesheets/framework/variables.scss @@ -555,11 +555,13 @@ $diff-jagged-border-gradient-color: darken($white-normal, 8%); /* * Fonts */ -$monospace-font: 'Menlo', 'DejaVu Sans Mono', 'Liberation Mono', 'Consolas', 'Ubuntu Mono', - 'Courier New', 'andale mono', 'lucida console', monospace; -$regular-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans', Ubuntu, Cantarell, - 'Helvetica Neue', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', - 'Noto Color Emoji'; +$monospace-font: var(--default-mono-font, 'Menlo'), 'DejaVu Sans Mono', 'Liberation Mono', 'Consolas', + 'Ubuntu Mono', 'Courier New', 'andale mono', 'lucida console', monospace; +$regular-font: var(--default-regular-font, -apple-system), BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans', + Ubuntu, Cantarell, 'Helvetica Neue', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', + 'Segoe UI Symbol', 'Noto Color Emoji'; +$gl-monospace-font: $monospace-font; +$gl-regular-font: $regular-font; /* * Dropdowns diff --git a/app/assets/stylesheets/pages/note_form.scss b/app/assets/stylesheets/pages/note_form.scss index cb77c31d59a..adeab227670 100644 --- a/app/assets/stylesheets/pages/note_form.scss +++ b/app/assets/stylesheets/pages/note_form.scss @@ -287,8 +287,7 @@ table { .discussion-reply-holder { .reply-placeholder-text-field { - font-family: $monospace-font; - font-size: $gl-font-size-monospace; + @include gl-font-monospace; border-radius: $gl-border-radius-base; width: 100%; resize: none; diff --git a/app/assets/stylesheets/startup/startup-dark.scss b/app/assets/stylesheets/startup/startup-dark.scss index c171770a374..cfc9ce1b998 100644 --- a/app/assets/stylesheets/startup/startup-dark.scss +++ b/app/assets/stylesheets/startup/startup-dark.scss @@ -758,7 +758,7 @@ input { kbd { display: inline-block; padding: 3px 5px; - font-size: 0.6875rem; + font-size: 0.75rem; line-height: 10px; color: var(--gray-700, #bfbfc3); vertical-align: middle; diff --git a/app/assets/stylesheets/startup/startup-general.scss b/app/assets/stylesheets/startup/startup-general.scss index 5337c10c55b..c7a2c33e9e8 100644 --- a/app/assets/stylesheets/startup/startup-general.scss +++ b/app/assets/stylesheets/startup/startup-general.scss @@ -758,7 +758,7 @@ input { kbd { display: inline-block; padding: 3px 5px; - font-size: 0.6875rem; + font-size: 0.75rem; line-height: 10px; color: var(--gray-700, #535158); vertical-align: middle; diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 249b1ed6aaa..e9b1eece969 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -290,6 +290,10 @@ module ApplicationHelper !params.has_key?(:no_startup_css) end + def use_new_fonts? + Feature.enabled?(:new_fonts, current_user) || request.params.has_key?(:new_fonts) + end + def outdated_browser? browser.ie? end diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index aff7c1a6b05..ea2f452b9e2 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -37,6 +37,8 @@ = stylesheet_link_tag "disable_animations", media: "all" if Rails.env.test? || Gitlab.config.gitlab['disable_animations'] = stylesheet_link_tag "test_environment", media: "all" if Rails.env.test? + = stylesheet_link_tag_defer "fonts" if use_new_fonts? + = stylesheet_link_tag_defer "highlight/themes/#{user_color_scheme}" - if startup_css_enabled? diff --git a/app/views/layouts/_loading_hints.html.haml b/app/views/layouts/_loading_hints.html.haml index b3bb474ea43..b1d1447ae2a 100644 --- a/app/views/layouts/_loading_hints.html.haml +++ b/app/views/layouts/_loading_hints.html.haml @@ -13,3 +13,9 @@ = preload_link_tag(path_to_stylesheet("highlight/themes/#{user_color_scheme}"), crossorigin: css_crossorigin) - if Gitlab::Tracking.enabled? && Gitlab::Tracking.collector_hostname %link{ rel: 'preconnect', href: "https://#{Gitlab::Tracking.collector_hostname}", crossorigin: '' } + - if use_new_fonts? + -# Do not use preload_link_tag for fonts, to work around Firefox double-fetch bug. + -# See https://github.com/web-platform-tests/wpt/pull/36930 + %link{ rel: 'preload', href: font_path('gitlab-sans/GitLabSans.woff2'), as: 'font', crossorigin: css_crossorigin } + %link{ rel: 'preload', href: font_path('jetbrains-mono/JetBrainsMono.woff2'), as: 'font', crossorigin: css_crossorigin } + = preload_link_tag(path_to_stylesheet('fonts'), crossorigin: css_crossorigin) diff --git a/app/views/shared/web_hooks/_form.html.haml b/app/views/shared/web_hooks/_form.html.haml index 52e95cba82b..7eafd6ae092 100644 --- a/app/views/shared/web_hooks/_form.html.haml +++ b/app/views/shared/web_hooks/_form.html.haml @@ -1,13 +1,6 @@ = form_errors(hook) -- if Feature.enabled?(:webhook_form_mask_url) - .js-vue-webhook-form{ data: webhook_form_data(hook) } -- else - .form-group - = form.label :url, s_('Webhooks|URL'), class: 'label-bold' - = form.text_field :url, class: 'form-control gl-form-input', placeholder: 'http://example.com/trigger-ci.json' - %p.form-text.text-muted - = s_('Webhooks|URL must be percent-encoded if it contains one or more special characters.') +.js-vue-webhook-form{ data: webhook_form_data(hook) } .form-group = form.label :token, s_('Webhooks|Secret token'), class: 'label-bold' = form.password_field :token, value: hook.masked_token, autocomplete: 'new-password', class: 'form-control gl-form-input' diff --git a/config/application.rb b/config/application.rb index 56eabc59815..51818579ccf 100644 --- a/config/application.rb +++ b/config/application.rb @@ -333,6 +333,7 @@ module Gitlab config.assets.precompile << "disable_animations.css" config.assets.precompile << "test_environment.css" config.assets.precompile << "snippets.css" + config.assets.precompile << "fonts.css" config.assets.precompile << "locale/**/app.js" config.assets.precompile << "emoji_sprites.css" config.assets.precompile << "errors.css" @@ -344,6 +345,11 @@ module Gitlab config.assets.precompile << "highlight/diff_custom_colors_addition.css" config.assets.precompile << "highlight/diff_custom_colors_deletion.css" + # Import woff2 for fonts + config.assets.paths << "#{config.root}/node_modules/@gitlab/fonts/" + config.assets.precompile << "gitlab-sans/*.woff2" + config.assets.precompile << "jetbrains-mono/*.woff2" + # Import gitlab-svgs directly from vendored directory config.assets.paths << "#{config.root}/node_modules/@gitlab/svgs/dist" config.assets.paths << "#{config.root}/node_modules/@jihulab/svgs/dist" if Gitlab.jh? diff --git a/config/dependency_decisions.yml b/config/dependency_decisions.yml index c3d9179a160..e68de8b11f3 100644 --- a/config/dependency_decisions.yml +++ b/config/dependency_decisions.yml @@ -250,8 +250,8 @@ :when: 2019-09-11 13:08:28.431132000 Z - - :permit - "(MIT OR CC0-1.0)" - - :who: - :why: + - :who: + :why: :versions: [] :when: 2019-11-08 10:03:31.787226000 Z - - :permit @@ -369,3 +369,9 @@ :why: https://github.com/gridstack/gridstack.js/blob/v7.0.0/LICENSE :versions: [] :when: 2022-10-18 16:24:56.611523399 Z +- - :approve + - "@gitlab/fonts" + - :who: Lukas Eipert + :why: https://gitlab.com/gitlab-com/legal-and-compliance/-/issues/1265 + :versions: [] + :when: 2022-12-02 08:24:56.611523399 Z diff --git a/config/feature_flags/development/webhook_form_mask_url.yml b/config/feature_flags/development/new_fonts.yml index 445fcb0b6b3..20bf283e704 100644 --- a/config/feature_flags/development/webhook_form_mask_url.yml +++ b/config/feature_flags/development/new_fonts.yml @@ -1,8 +1,8 @@ --- -name: webhook_form_mask_url -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/99995 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/376106 -milestone: '15.5' +name: new_fonts +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/102347 +rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/379147 +milestone: '15.7' type: development -group: group::integrations +group: group::foundations default_enabled: false diff --git a/db/docs/experiment_subjects.yml b/db/docs/experiment_subjects.yml deleted file mode 100644 index 7e3eabd6a83..00000000000 --- a/db/docs/experiment_subjects.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -table_name: experiment_subjects -classes: -- ExperimentSubject -feature_categories: -- experimentation_conversion -description: TODO -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/47042 -milestone: '13.7' -gitlab_schema: gitlab_main diff --git a/db/docs/experiments.yml b/db/docs/experiments.yml deleted file mode 100644 index 68aab38f8b6..00000000000 --- a/db/docs/experiments.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -table_name: experiments -classes: -- Experiment -feature_categories: -- experimentation_conversion -description: TODO -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/38397 -milestone: '13.3' -gitlab_schema: gitlab_main diff --git a/db/post_migrate/20221019194751_disable_fastupdate_on_issues_title_gin_index.rb b/db/post_migrate/20221019194751_disable_fastupdate_on_issues_title_gin_index.rb index 6ad846dda1c..64d935489c2 100644 --- a/db/post_migrate/20221019194751_disable_fastupdate_on_issues_title_gin_index.rb +++ b/db/post_migrate/20221019194751_disable_fastupdate_on_issues_title_gin_index.rb @@ -6,6 +6,8 @@ class DisableFastupdateOnIssuesTitleGinIndex < Gitlab::Database::Migration[2.0] INDEX_NAME = 'index_issues_on_title_trigram' def up + return unless index_exists_by_name?(:issues, INDEX_NAME) + with_lock_retries do execute <<~SQL ALTER INDEX #{INDEX_NAME} SET ( fastupdate = false ) ; @@ -14,6 +16,8 @@ class DisableFastupdateOnIssuesTitleGinIndex < Gitlab::Database::Migration[2.0] end def down + return unless index_exists_by_name?(:issues, INDEX_NAME) + with_lock_retries do execute <<~SQL ALTER INDEX #{INDEX_NAME} RESET ( fastupdate ) ; diff --git a/db/post_migrate/20221019195754_disable_fastupdate_on_issues_description_gin_index.rb b/db/post_migrate/20221019195754_disable_fastupdate_on_issues_description_gin_index.rb index ce09a48833f..8822cb3b414 100644 --- a/db/post_migrate/20221019195754_disable_fastupdate_on_issues_description_gin_index.rb +++ b/db/post_migrate/20221019195754_disable_fastupdate_on_issues_description_gin_index.rb @@ -6,6 +6,8 @@ class DisableFastupdateOnIssuesDescriptionGinIndex < Gitlab::Database::Migration INDEX_NAME = 'index_issues_on_description_trigram' def up + return unless index_exists_by_name?(:issues, INDEX_NAME) + with_lock_retries do execute <<~SQL ALTER INDEX #{INDEX_NAME} SET ( fastupdate = false ) ; @@ -14,6 +16,8 @@ class DisableFastupdateOnIssuesDescriptionGinIndex < Gitlab::Database::Migration end def down + return unless index_exists_by_name?(:issues, INDEX_NAME) + with_lock_retries do execute <<~SQL ALTER INDEX #{INDEX_NAME} RESET ( fastupdate ) ; diff --git a/db/post_migrate/20221019200033_disable_fastupdate_on_merge_requests_title_gin_index.rb b/db/post_migrate/20221019200033_disable_fastupdate_on_merge_requests_title_gin_index.rb index eb4c413a5a9..3e1124dc2bb 100644 --- a/db/post_migrate/20221019200033_disable_fastupdate_on_merge_requests_title_gin_index.rb +++ b/db/post_migrate/20221019200033_disable_fastupdate_on_merge_requests_title_gin_index.rb @@ -6,6 +6,8 @@ class DisableFastupdateOnMergeRequestsTitleGinIndex < Gitlab::Database::Migratio INDEX_NAME = 'index_merge_requests_on_title_trigram' def up + return unless index_exists_by_name?(:merge_requests, INDEX_NAME) + with_lock_retries do execute <<~SQL ALTER INDEX #{INDEX_NAME} SET ( fastupdate = false ) ; @@ -14,6 +16,8 @@ class DisableFastupdateOnMergeRequestsTitleGinIndex < Gitlab::Database::Migratio end def down + return unless index_exists_by_name?(:merge_requests, INDEX_NAME) + with_lock_retries do execute <<~SQL ALTER INDEX #{INDEX_NAME} RESET ( fastupdate ) ; diff --git a/db/post_migrate/20221019200206_disable_fastupdate_on_merge_requests_description_gin_index.rb b/db/post_migrate/20221019200206_disable_fastupdate_on_merge_requests_description_gin_index.rb index 2e55937db36..7ab6f40e206 100644 --- a/db/post_migrate/20221019200206_disable_fastupdate_on_merge_requests_description_gin_index.rb +++ b/db/post_migrate/20221019200206_disable_fastupdate_on_merge_requests_description_gin_index.rb @@ -6,6 +6,8 @@ class DisableFastupdateOnMergeRequestsDescriptionGinIndex < Gitlab::Database::Mi INDEX_NAME = 'index_merge_requests_on_description_trigram' def up + return unless index_exists_by_name?(:merge_requests, INDEX_NAME) + with_lock_retries do execute <<~SQL ALTER INDEX #{INDEX_NAME} SET ( fastupdate = false ) ; @@ -14,6 +16,8 @@ class DisableFastupdateOnMergeRequestsDescriptionGinIndex < Gitlab::Database::Mi end def down + return unless index_exists_by_name?(:merge_requests, INDEX_NAME) + with_lock_retries do execute <<~SQL ALTER INDEX #{INDEX_NAME} RESET ( fastupdate ) ; diff --git a/db/post_migrate/20221114142044_delete_experiments_foreign_keys.rb b/db/post_migrate/20221114142044_delete_experiments_foreign_keys.rb new file mode 100644 index 00000000000..d44b7a6eb51 --- /dev/null +++ b/db/post_migrate/20221114142044_delete_experiments_foreign_keys.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +class DeleteExperimentsForeignKeys < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + def up + with_lock_retries do + remove_foreign_key_if_exists :experiment_subjects, :users, name: 'fk_dfc3e211d4' + end + + with_lock_retries do + remove_foreign_key_if_exists :experiment_subjects, :experiments, name: 'fk_rails_ede5754774' + end + + with_lock_retries do + remove_foreign_key_if_exists :experiment_subjects, :projects, name: 'fk_ccc28f8ceb' + end + + with_lock_retries do + remove_foreign_key_if_exists :experiment_subjects, :namespaces, name: 'fk_842649f2f5' + end + end + + def down + add_concurrent_foreign_key :experiment_subjects, + :users, column: :user_id, name: 'fk_dfc3e211d4', on_delete: :cascade + add_concurrent_foreign_key :experiment_subjects, + :experiments, column: :experiment_id, name: 'fk_rails_ede5754774', on_delete: :cascade + add_concurrent_foreign_key :experiment_subjects, + :projects, column: :project_id, name: 'fk_ccc28f8ceb', on_delete: :cascade + add_concurrent_foreign_key :experiment_subjects, + :namespaces, column: :namespace_id, name: 'fk_842649f2f5', on_delete: :cascade + end +end diff --git a/db/post_migrate/20221114142602_drop_experiment_subjects_table.rb b/db/post_migrate/20221114142602_drop_experiment_subjects_table.rb new file mode 100644 index 00000000000..371f214de6d --- /dev/null +++ b/db/post_migrate/20221114142602_drop_experiment_subjects_table.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +class DropExperimentSubjectsTable < Gitlab::Database::Migration[2.0] + def up + drop_table :experiment_subjects, if_exists: true + end + + def down + unless table_exists?(:experiment_subjects) + create_table :experiment_subjects do |t| # rubocop:disable Migration/SchemaAdditionMethodsNoPost + t.bigint :experiment_id, null: false + t.bigint :user_id + t.bigint :project_id + t.integer :variant, limit: 2, null: false, default: 0 + t.timestamps_with_timezone null: false + t.datetime_with_timezone :converted_at + t.jsonb :context, null: false, default: {} + t.bigint :namespace_id + + t.index :experiment_id + t.index :namespace_id + t.index :project_id + t.index :user_id + end + end + + # Require exactly one of user_id, group_id, or project_id to be NOT NULL + execute <<-SQL + ALTER TABLE experiment_subjects ADD CONSTRAINT check_f6411bc4b5 CHECK (num_nonnulls(user_id, namespace_id, project_id) = 1); + SQL + end +end diff --git a/db/post_migrate/20221114142616_drop_experiments_table.rb b/db/post_migrate/20221114142616_drop_experiments_table.rb new file mode 100644 index 00000000000..da6c1122494 --- /dev/null +++ b/db/post_migrate/20221114142616_drop_experiments_table.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class DropExperimentsTable < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + def up + drop_table :experiments, if_exists: true + end + + def down + unless table_exists?(:experiments) + create_table :experiments do |t| # rubocop:disable Migration/SchemaAdditionMethodsNoPost + t.text :name, null: false + + t.index :name, unique: true + end + end + + add_text_limit :experiments, :name, 255 + end +end diff --git a/db/schema_migrations/20221114142044 b/db/schema_migrations/20221114142044 new file mode 100644 index 00000000000..cd0e0bd8abb --- /dev/null +++ b/db/schema_migrations/20221114142044 @@ -0,0 +1 @@ +5df7ccad8b87eb93db804886d93d5cab40ef988f8706bfe9b54c044ea49b78f9
\ No newline at end of file diff --git a/db/schema_migrations/20221114142602 b/db/schema_migrations/20221114142602 new file mode 100644 index 00000000000..d59022a5ba7 --- /dev/null +++ b/db/schema_migrations/20221114142602 @@ -0,0 +1 @@ +0ce9bc1eb8164103c13be54e5b94b5d78e64c9a61a0d4c29ea7cbac6655c3d02
\ No newline at end of file diff --git a/db/schema_migrations/20221114142616 b/db/schema_migrations/20221114142616 new file mode 100644 index 00000000000..ad8e685cb85 --- /dev/null +++ b/db/schema_migrations/20221114142616 @@ -0,0 +1 @@ +6532501a17c42d41dab53d277624992e8be1dd8597b8c9eda08e3d62d6e1c33a
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index ae31e2894cc..4fe6646c271 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -15409,44 +15409,6 @@ CREATE SEQUENCE evidences_id_seq ALTER SEQUENCE evidences_id_seq OWNED BY evidences.id; -CREATE TABLE experiment_subjects ( - id bigint NOT NULL, - experiment_id bigint NOT NULL, - user_id bigint, - project_id bigint, - variant smallint DEFAULT 0 NOT NULL, - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, - converted_at timestamp with time zone, - context jsonb DEFAULT '{}'::jsonb NOT NULL, - namespace_id bigint, - CONSTRAINT check_f6411bc4b5 CHECK ((num_nonnulls(user_id, namespace_id, project_id) = 1)) -); - -CREATE SEQUENCE experiment_subjects_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - -ALTER SEQUENCE experiment_subjects_id_seq OWNED BY experiment_subjects.id; - -CREATE TABLE experiments ( - id bigint NOT NULL, - name text NOT NULL, - CONSTRAINT check_e2dda25ed0 CHECK ((char_length(name) <= 255)) -); - -CREATE SEQUENCE experiments_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - -ALTER SEQUENCE experiments_id_seq OWNED BY experiments.id; - CREATE TABLE external_approval_rules ( id bigint NOT NULL, project_id bigint NOT NULL, @@ -23955,10 +23917,6 @@ ALTER TABLE ONLY events ALTER COLUMN id SET DEFAULT nextval('events_id_seq'::reg ALTER TABLE ONLY evidences ALTER COLUMN id SET DEFAULT nextval('evidences_id_seq'::regclass); -ALTER TABLE ONLY experiment_subjects ALTER COLUMN id SET DEFAULT nextval('experiment_subjects_id_seq'::regclass); - -ALTER TABLE ONLY experiments ALTER COLUMN id SET DEFAULT nextval('experiments_id_seq'::regclass); - ALTER TABLE ONLY external_approval_rules ALTER COLUMN id SET DEFAULT nextval('external_approval_rules_id_seq'::regclass); ALTER TABLE ONLY external_approval_rules_protected_branches ALTER COLUMN id SET DEFAULT nextval('external_approval_rules_protected_branches_id_seq'::regclass); @@ -25875,12 +25833,6 @@ ALTER TABLE ONLY events ALTER TABLE ONLY evidences ADD CONSTRAINT evidences_pkey PRIMARY KEY (id); -ALTER TABLE ONLY experiment_subjects - ADD CONSTRAINT experiment_subjects_pkey PRIMARY KEY (id); - -ALTER TABLE ONLY experiments - ADD CONSTRAINT experiments_pkey PRIMARY KEY (id); - ALTER TABLE ONLY external_approval_rules ADD CONSTRAINT external_approval_rules_pkey PRIMARY KEY (id); @@ -29281,16 +29233,6 @@ CREATE UNIQUE INDEX index_events_on_target_type_and_target_id_and_fingerprint ON CREATE INDEX index_evidences_on_release_id ON evidences USING btree (release_id); -CREATE INDEX index_experiment_subjects_on_experiment_id ON experiment_subjects USING btree (experiment_id); - -CREATE INDEX index_experiment_subjects_on_namespace_id ON experiment_subjects USING btree (namespace_id); - -CREATE INDEX index_experiment_subjects_on_project_id ON experiment_subjects USING btree (project_id); - -CREATE INDEX index_experiment_subjects_on_user_id ON experiment_subjects USING btree (user_id); - -CREATE UNIQUE INDEX index_experiments_on_name ON experiments USING btree (name); - CREATE INDEX index_expired_and_not_notified_personal_access_tokens ON personal_access_tokens USING btree (id, expires_at) WHERE ((impersonation = false) AND (revoked = false) AND (expire_notification_delivered = false)); CREATE UNIQUE INDEX index_external_audit_event_destinations_on_namespace_id ON audit_events_external_audit_event_destinations USING btree (namespace_id, destination_url); @@ -33371,9 +33313,6 @@ ALTER TABLE ONLY import_export_uploads ALTER TABLE ONLY push_rules ADD CONSTRAINT fk_83b29894de FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; -ALTER TABLE ONLY experiment_subjects - ADD CONSTRAINT fk_842649f2f5 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; - ALTER TABLE ONLY merge_request_diffs ADD CONSTRAINT fk_8483f3258f FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE; @@ -33662,9 +33601,6 @@ ALTER TABLE ONLY external_status_checks_protected_branches ALTER TABLE ONLY dast_profiles_pipelines ADD CONSTRAINT fk_cc206a8c13 FOREIGN KEY (dast_profile_id) REFERENCES dast_profiles(id) ON DELETE CASCADE; -ALTER TABLE ONLY experiment_subjects - ADD CONSTRAINT fk_ccc28f8ceb FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY todos ADD CONSTRAINT fk_ccf0373936 FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE CASCADE; @@ -33743,9 +33679,6 @@ ALTER TABLE ONLY protected_branches ALTER TABLE ONLY issues ADD CONSTRAINT fk_df75a7c8b8 FOREIGN KEY (promoted_to_epic_id) REFERENCES epics(id) ON DELETE SET NULL; -ALTER TABLE ONLY experiment_subjects - ADD CONSTRAINT fk_dfc3e211d4 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; - ALTER TABLE ONLY ci_resources ADD CONSTRAINT fk_e169a8e3d5 FOREIGN KEY (build_id) REFERENCES ci_builds(id) ON DELETE SET NULL; @@ -35405,9 +35338,6 @@ ALTER TABLE ONLY project_security_settings ALTER TABLE ONLY packages_debian_group_distributions ADD CONSTRAINT fk_rails_ede0bb937f FOREIGN KEY (creator_id) REFERENCES users(id) ON DELETE SET NULL; -ALTER TABLE ONLY experiment_subjects - ADD CONSTRAINT fk_rails_ede5754774 FOREIGN KEY (experiment_id) REFERENCES experiments(id) ON DELETE CASCADE; - ALTER TABLE ONLY ci_daily_build_group_report_results ADD CONSTRAINT fk_rails_ee072d13b3 FOREIGN KEY (last_pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE; diff --git a/doc/ci/git_submodules.md b/doc/ci/git_submodules.md index ed94410e6f9..0f206b3fceb 100644 --- a/doc/ci/git_submodules.md +++ b/doc/ci/git_submodules.md @@ -68,7 +68,7 @@ To make submodules work correctly in CI/CD jobs: ``` 1. You can filter or exclude specific submodules to control which submodules will be synced using - [`GIT_SUBMODULE_PATHS`](runners/configure_runners.md#git-submodule-paths). + [`GIT_SUBMODULE_PATHS`](runners/configure_runners.md#sync-or-exclude-specific-submodules-from-ci-jobs). ```yaml variables: @@ -83,7 +83,7 @@ To make submodules work correctly in CI/CD jobs: GIT_SUBMODULE_STRATEGY: recursive GIT_SUBMODULE_UPDATE_FLAGS: --jobs 4 ``` - + If you use the [`CI_JOB_TOKEN`](jobs/ci_job_token.md) to clone a submodule in a pipeline job, the user executing the job must be assigned to a role that has [permission](../user/permissions.md#gitlab-cicd-permissions) to trigger a pipeline diff --git a/doc/ci/runners/configure_runners.md b/doc/ci/runners/configure_runners.md index 3757410e355..b2035868c06 100644 --- a/doc/ci/runners/configure_runners.md +++ b/doc/ci/runners/configure_runners.md @@ -309,7 +309,6 @@ globally or for individual jobs: - [`GIT_CHECKOUT`](#git-checkout) - [`GIT_CLEAN_FLAGS`](#git-clean-flags) - [`GIT_FETCH_EXTRA_FLAGS`](#git-fetch-extra-flags) -- [`GIT_SUBMODULE_PATHS`](#git-submodule-paths) - [`GIT_SUBMODULE_UPDATE_FLAGS`](#git-submodule-update-flags) - [`GIT_DEPTH`](#shallow-cloning) (shallow cloning) - [`GIT_SUBMODULE_DEPTH`](#git-submodule-depth) @@ -497,16 +496,13 @@ git fetch origin $REFSPECS --depth 50 --prune Where `$REFSPECS` is a value provided to the runner internally by GitLab. -### Git submodule paths +### Sync or exclude specific submodules from CI jobs > [Introduced](https://gitlab.com/gitlab-org/gitlab-runner/-/merge_requests/2249) in GitLab Runner 14.0. Use the `GIT_SUBMODULE_PATHS` variable to control which submodules have to be synced or updated. You can set it globally or per-job in the [`variables`](../yaml/index.md#variables) section. -This variable can be very useful for projects which have a large number of submodules which not all of them -need to be synced or updated in all CI jobs. - The path syntax is the same as [`git submodule`](https://git-scm.com/docs/git-submodule#Documentation/git-submodule.txt-ltpathgt82308203): - To sync and update specific paths: diff --git a/doc/ci/yaml/index.md b/doc/ci/yaml/index.md index 52422cba111..dfd96e7d7f1 100644 --- a/doc/ci/yaml/index.md +++ b/doc/ci/yaml/index.md @@ -2252,6 +2252,9 @@ This example creates four paths of execution: in a job's `needs` section. - In GitLab 13.9 and older, if `needs` refers to a job that might not be added to a pipeline because of `only`, `except`, or `rules`, the pipeline might fail to create. In GitLab 13.10 and later, use the [`needs:optional`](#needsoptional) keyword to resolve a failed pipeline creation. +- If a pipeline has jobs with `needs: []` and jobs in the [`.pre`](#stage-pre) stage, they will + all start as soon as the pipeline is created. Jobs with `needs: []` start immediately, + and jobs in the `.pre` stage also start immediately. #### `needs:artifacts` @@ -3924,6 +3927,12 @@ job2: - echo "This job runs in the test stage." ``` +**Additional details:** + +- If a pipeline has jobs with [`needs: []`](#needs) and jobs in the `.pre` stage, they will + all start as soon as the pipeline is created. Jobs with `needs: []` start immediately, + ignoring any stage configuration. + ### `tags` > - A limit of 50 tags per job [enabled on GitLab.com](https://gitlab.com/gitlab-org/gitlab/-/issues/338929) in GitLab 14.3. diff --git a/doc/user/application_security/policies/scan-result-policies.md b/doc/user/application_security/policies/scan-result-policies.md index 7482df18cc3..5df910efb15 100644 --- a/doc/user/application_security/policies/scan-result-policies.md +++ b/doc/user/application_security/policies/scan-result-policies.md @@ -184,3 +184,12 @@ It corresponds to a single object from the previous example: user_approvers: - adalberto.dare ``` + +## Example situations where scan result policies require additional approval + +There are several situations where the scan result policy will require an additional approval step. For example: + +- The number of security jobs is reduced in the working branch and no longer matches the number of security jobs in the target branch. Users can't skip the Scanning Result Policies by removing scanning jobs from the CI configuration. +- Someone stops a pipeline security job, and users can't skip the security scan. +- A job in a merge request fails and is configured with `allow_failure: false`. As a result, the pipeline is in a blocked state. +- A pipeline has a manual job that must run successfully for the entire pipeline to pass. diff --git a/doc/user/project/integrations/webhooks.md b/doc/user/project/integrations/webhooks.md index 53c396fa9af..2eab5fc29bb 100644 --- a/doc/user/project/integrations/webhooks.md +++ b/doc/user/project/integrations/webhooks.md @@ -64,10 +64,9 @@ You can configure a webhook for a group or a project. ## Mask sensitive portions of webhook URLs -> Introduced in GitLab 15.6 [with a flag](../../../administration/feature_flags.md) named `webhook_form_mask_url`. Disabled by default. - -FLAG: -On self-managed GitLab, by default this feature is not available. To make it available, ask an administrator to [enable the feature flag](../../../administration/feature_flags.md) named `webhook_form_mask_url`. On GitLab.com, this feature is not available. +> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/99995) in GitLab 15.5 [with a flag](../../../administration/feature_flags.md) named `webhook_form_mask_url`. Disabled by default. +> - [Enabled on GitLab.com](https://gitlab.com/gitlab-org/gitlab/-/issues/376106) in GitLab 15.6. +> - [Generally available](https://gitlab.com/gitlab-org/gitlab/-/issues/376106) in GitLab 15.7. Feature flag `webhook_form_mask_url` removed. You can define and mask sensitive portions of webhook URLs and replace them with configured values any number of times when webhooks are executed. diff --git a/lib/gitlab/database/gitlab_schemas.yml b/lib/gitlab/database/gitlab_schemas.yml index 53434d464ee..4dc06489797 100644 --- a/lib/gitlab/database/gitlab_schemas.yml +++ b/lib/gitlab/database/gitlab_schemas.yml @@ -208,8 +208,6 @@ error_tracking_error_events: :gitlab_main error_tracking_errors: :gitlab_main events: :gitlab_main evidences: :gitlab_main -experiments: :gitlab_main -experiment_subjects: :gitlab_main external_approval_rules: :gitlab_main external_approval_rules_protected_branches: :gitlab_main external_pull_requests: :gitlab_ci diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 709d15193db..12732bc9678 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -46179,9 +46179,6 @@ msgstr "" msgid "Webhooks|Trigger" msgstr "" -msgid "Webhooks|URL" -msgstr "" - msgid "Webhooks|URL must be percent-encoded if it contains one or more special characters." msgstr "" diff --git a/package.json b/package.json index 2e44fb8be2f..dd42dd78cc0 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "@cubejs-client/core": "^0.31.0", "@gitlab/at.js": "1.5.7", "@gitlab/favicon-overlay": "2.0.0", + "@gitlab/fonts": "^1.0.0", "@gitlab/svgs": "3.13.0", "@gitlab/ui": "51.1.1", "@gitlab/visual-review-tools": "1.7.3", diff --git a/spec/features/profiles/user_edit_profile_spec.rb b/spec/features/profiles/user_edit_profile_spec.rb index 2cd9913a929..67604292090 100644 --- a/spec/features/profiles/user_edit_profile_spec.rb +++ b/spec/features/profiles/user_edit_profile_spec.rb @@ -301,6 +301,8 @@ RSpec.describe 'User edit profile', feature_category: :users do find('.header-user-dropdown-toggle').click page.within ".header-user" do + find('.js-set-status-modal-trigger.ready') + click_button button_text end end @@ -365,7 +367,7 @@ RSpec.describe 'User edit profile', feature_category: :users do end end - it 'sets the users status to busy', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/382965' do + it 'sets the users status to busy' do open_user_status_modal busy_status = find('[data-testid="user-availability-checkbox"]') diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index ac811b46c39..3384f9fea05 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe ApplicationHelper do + include Devise::Test::ControllerHelpers + describe 'current_controller?' do before do stub_controller_name('foo') @@ -685,4 +687,28 @@ RSpec.describe ApplicationHelper do expect(helper.stylesheet_link_tag_defer('test')).to eq( '<link rel="stylesheet" media="screen" href="/stylesheets/test.css" />') end end + + describe '#use_new_fonts?' do + subject { helper.use_new_fonts? } + + it { is_expected.to eq true } + + context 'when the feature flag is disabled' do + before do + stub_feature_flags(new_fonts: false) + end + + it { is_expected.to eq false } + + context 'with special request param' do + let(:request) { instance_double(ActionController::TestRequest, params: { new_fonts: true }) } + + before do + allow(helper).to receive(:request).and_return(request) + end + + it { is_expected.to eq true } + end + end + end end diff --git a/spec/lib/gitlab/background_migration/backfill_jira_tracker_deployment_type2_spec.rb b/spec/lib/gitlab/background_migration/backfill_jira_tracker_deployment_type2_spec.rb index 65f5f8368df..8db45ac0f57 100644 --- a/spec/lib/gitlab/background_migration/backfill_jira_tracker_deployment_type2_spec.rb +++ b/spec/lib/gitlab/background_migration/backfill_jira_tracker_deployment_type2_spec.rb @@ -3,11 +3,11 @@ require 'spec_helper' RSpec.describe Gitlab::BackgroundMigration::BackfillJiraTrackerDeploymentType2, :migration, schema: 20210301200959 do - let_it_be(:jira_integration_temp) { described_class::JiraServiceTemp } - let_it_be(:jira_tracker_data_temp) { described_class::JiraTrackerDataTemp } - let_it_be(:atlassian_host) { 'https://api.atlassian.net' } - let_it_be(:mixedcase_host) { 'https://api.AtlassiaN.nEt' } - let_it_be(:server_host) { 'https://my.server.net' } + let!(:jira_integration_temp) { described_class::JiraServiceTemp } + let!(:jira_tracker_data_temp) { described_class::JiraTrackerDataTemp } + let!(:atlassian_host) { 'https://api.atlassian.net' } + let!(:mixedcase_host) { 'https://api.AtlassiaN.nEt' } + let!(:server_host) { 'https://my.server.net' } let(:jira_integration) { jira_integration_temp.create!(type: 'JiraService', active: true, category: 'issue_tracker') } diff --git a/spec/lib/gitlab/background_migration/backfill_project_namespace_details_spec.rb b/spec/lib/gitlab/background_migration/backfill_project_namespace_details_spec.rb index 77d6cc43114..01daf16d10c 100644 --- a/spec/lib/gitlab/background_migration/backfill_project_namespace_details_spec.rb +++ b/spec/lib/gitlab/background_migration/backfill_project_namespace_details_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' RSpec.describe Gitlab::BackgroundMigration::BackfillProjectNamespaceDetails, :migration do - let_it_be(:namespace_details) { table(:namespace_details) } - let_it_be(:namespaces) { table(:namespaces) } - let_it_be(:projects) { table(:projects) } + let!(:namespace_details) { table(:namespace_details) } + let!(:namespaces) { table(:namespaces) } + let!(:projects) { table(:projects) } subject(:perform_migration) do described_class.new(start_id: projects.minimum(:id), diff --git a/spec/lib/gitlab/background_migration/delete_orphaned_operational_vulnerabilities_spec.rb b/spec/lib/gitlab/background_migration/delete_orphaned_operational_vulnerabilities_spec.rb index afa955a6056..c03962c8d21 100644 --- a/spec/lib/gitlab/background_migration/delete_orphaned_operational_vulnerabilities_spec.rb +++ b/spec/lib/gitlab/background_migration/delete_orphaned_operational_vulnerabilities_spec.rb @@ -5,9 +5,9 @@ require 'spec_helper' RSpec.describe Gitlab::BackgroundMigration::DeleteOrphanedOperationalVulnerabilities, :migration do include MigrationHelpers::VulnerabilitiesHelper - let_it_be(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } - let_it_be(:users) { table(:users) } - let_it_be(:user) do + let!(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } + let!(:users) { table(:users) } + let!(:user) do users.create!( name: "Example User", email: "user@example.com", @@ -17,7 +17,7 @@ RSpec.describe Gitlab::BackgroundMigration::DeleteOrphanedOperationalVulnerabili ) end - let_it_be(:project) do + let!(:project) do table(:projects).create!( id: 123, namespace_id: namespace.id, @@ -25,9 +25,9 @@ RSpec.describe Gitlab::BackgroundMigration::DeleteOrphanedOperationalVulnerabili ) end - let_it_be(:scanners) { table(:vulnerability_scanners) } - let_it_be(:scanner) { scanners.create!(project_id: project.id, external_id: 'test 1', name: 'test scanner 1') } - let_it_be(:different_scanner) do + let!(:scanners) { table(:vulnerability_scanners) } + let!(:scanner) { scanners.create!(project_id: project.id, external_id: 'test 1', name: 'test scanner 1') } + let!(:different_scanner) do scanners.create!( project_id: project.id, external_id: 'test 2', @@ -35,22 +35,22 @@ RSpec.describe Gitlab::BackgroundMigration::DeleteOrphanedOperationalVulnerabili ) end - let_it_be(:vulnerabilities) { table(:vulnerabilities) } - let_it_be(:vulnerability_with_finding) do + let!(:vulnerabilities) { table(:vulnerabilities) } + let!(:vulnerability_with_finding) do create_vulnerability!( project_id: project.id, author_id: user.id ) end - let_it_be(:vulnerability_without_finding) do + let!(:vulnerability_without_finding) do create_vulnerability!( project_id: project.id, author_id: user.id ) end - let_it_be(:cis_vulnerability_without_finding) do + let!(:cis_vulnerability_without_finding) do create_vulnerability!( project_id: project.id, author_id: user.id, @@ -58,7 +58,7 @@ RSpec.describe Gitlab::BackgroundMigration::DeleteOrphanedOperationalVulnerabili ) end - let_it_be(:custom_vulnerability_without_finding) do + let!(:custom_vulnerability_without_finding) do create_vulnerability!( project_id: project.id, author_id: user.id, @@ -66,8 +66,8 @@ RSpec.describe Gitlab::BackgroundMigration::DeleteOrphanedOperationalVulnerabili ) end - let_it_be(:vulnerability_identifiers) { table(:vulnerability_identifiers) } - let_it_be(:primary_identifier) do + let!(:vulnerability_identifiers) { table(:vulnerability_identifiers) } + let!(:primary_identifier) do vulnerability_identifiers.create!( project_id: project.id, external_type: 'uuid-v5', @@ -76,8 +76,8 @@ RSpec.describe Gitlab::BackgroundMigration::DeleteOrphanedOperationalVulnerabili name: 'Identifier for UUIDv5') end - let_it_be(:vulnerabilities_findings) { table(:vulnerability_occurrences) } - let_it_be(:finding) do + let!(:vulnerabilities_findings) { table(:vulnerability_occurrences) } + let!(:finding) do create_finding!( vulnerability_id: vulnerability_with_finding.id, project_id: project.id, diff --git a/spec/lib/gitlab/background_migration/disable_expiration_policies_linked_to_no_container_images_spec.rb b/spec/lib/gitlab/background_migration/disable_expiration_policies_linked_to_no_container_images_spec.rb index 8a63673bf38..e7b0471810d 100644 --- a/spec/lib/gitlab/background_migration/disable_expiration_policies_linked_to_no_container_images_spec.rb +++ b/spec/lib/gitlab/background_migration/disable_expiration_policies_linked_to_no_container_images_spec.rb @@ -3,10 +3,10 @@ require 'spec_helper' RSpec.describe Gitlab::BackgroundMigration::DisableExpirationPoliciesLinkedToNoContainerImages, :migration, schema: 20220326161803 do # rubocop:disable Layout/LineLength - let_it_be(:projects) { table(:projects) } - let_it_be(:container_expiration_policies) { table(:container_expiration_policies) } - let_it_be(:container_repositories) { table(:container_repositories) } - let_it_be(:namespaces) { table(:namespaces) } + let!(:projects) { table(:projects) } + let!(:container_expiration_policies) { table(:container_expiration_policies) } + let!(:container_repositories) { table(:container_repositories) } + let!(:namespaces) { table(:namespaces) } let!(:namespace) { namespaces.create!(name: 'test', path: 'test') } diff --git a/spec/lib/gitlab/background_migration/drop_invalid_vulnerabilities_spec.rb b/spec/lib/gitlab/background_migration/drop_invalid_vulnerabilities_spec.rb index 5b6722a3384..194500586f8 100644 --- a/spec/lib/gitlab/background_migration/drop_invalid_vulnerabilities_spec.rb +++ b/spec/lib/gitlab/background_migration/drop_invalid_vulnerabilities_spec.rb @@ -3,33 +3,33 @@ require 'spec_helper' RSpec.describe Gitlab::BackgroundMigration::DropInvalidVulnerabilities, schema: 20210301200959 do - let_it_be(:background_migration_jobs) { table(:background_migration_jobs) } - let_it_be(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } - let_it_be(:users) { table(:users) } - let_it_be(:user) { create_user! } - let_it_be(:project) { table(:projects).create!(id: 123, namespace_id: namespace.id) } - - let_it_be(:scanners) { table(:vulnerability_scanners) } - let_it_be(:scanner) { scanners.create!(project_id: project.id, external_id: 'test 1', name: 'test scanner 1') } - let_it_be(:different_scanner) { scanners.create!(project_id: project.id, external_id: 'test 2', name: 'test scanner 2') } - - let_it_be(:vulnerabilities) { table(:vulnerabilities) } - let_it_be(:vulnerability_with_finding) do + let!(:background_migration_jobs) { table(:background_migration_jobs) } + let!(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } + let!(:users) { table(:users) } + let!(:user) { create_user! } + let!(:project) { table(:projects).create!(id: 123, namespace_id: namespace.id) } + + let!(:scanners) { table(:vulnerability_scanners) } + let!(:scanner) { scanners.create!(project_id: project.id, external_id: 'test 1', name: 'test scanner 1') } + let!(:different_scanner) { scanners.create!(project_id: project.id, external_id: 'test 2', name: 'test scanner 2') } + + let!(:vulnerabilities) { table(:vulnerabilities) } + let!(:vulnerability_with_finding) do create_vulnerability!( project_id: project.id, author_id: user.id ) end - let_it_be(:vulnerability_without_finding) do + let!(:vulnerability_without_finding) do create_vulnerability!( project_id: project.id, author_id: user.id ) end - let_it_be(:vulnerability_identifiers) { table(:vulnerability_identifiers) } - let_it_be(:primary_identifier) do + let!(:vulnerability_identifiers) { table(:vulnerability_identifiers) } + let!(:primary_identifier) do vulnerability_identifiers.create!( project_id: project.id, external_type: 'uuid-v5', @@ -38,8 +38,8 @@ RSpec.describe Gitlab::BackgroundMigration::DropInvalidVulnerabilities, schema: name: 'Identifier for UUIDv5') end - let_it_be(:vulnerabilities_findings) { table(:vulnerability_occurrences) } - let_it_be(:finding) do + let!(:vulnerabilities_findings) { table(:vulnerability_occurrences) } + let!(:finding) do create_finding!( vulnerability_id: vulnerability_with_finding.id, project_id: project.id, diff --git a/spec/lib/gitlab/background_migration/populate_container_repository_migration_plan_spec.rb b/spec/lib/gitlab/background_migration/populate_container_repository_migration_plan_spec.rb index 0463f5a0c0d..477167c9074 100644 --- a/spec/lib/gitlab/background_migration/populate_container_repository_migration_plan_spec.rb +++ b/spec/lib/gitlab/background_migration/populate_container_repository_migration_plan_spec.rb @@ -3,12 +3,12 @@ require 'spec_helper' RSpec.describe Gitlab::BackgroundMigration::PopulateContainerRepositoryMigrationPlan, schema: 20220316202640 do - let_it_be(:container_repositories) { table(:container_repositories) } - let_it_be(:projects) { table(:projects) } - let_it_be(:namespaces) { table(:namespaces) } - let_it_be(:gitlab_subscriptions) { table(:gitlab_subscriptions) } - let_it_be(:plans) { table(:plans) } - let_it_be(:namespace_statistics) { table(:namespace_statistics) } + let!(:container_repositories) { table(:container_repositories) } + let!(:projects) { table(:projects) } + let!(:namespaces) { table(:namespaces) } + let!(:gitlab_subscriptions) { table(:gitlab_subscriptions) } + let!(:plans) { table(:plans) } + let!(:namespace_statistics) { table(:namespace_statistics) } let!(:namepace1) { namespaces.create!(id: 1, type: 'Group', name: 'group1', path: 'group1', traversal_ids: [1]) } let!(:namepace2) { namespaces.create!(id: 2, type: 'Group', name: 'group2', path: 'group2', traversal_ids: [2]) } diff --git a/spec/lib/gitlab/background_migration/populate_namespace_statistics_spec.rb b/spec/lib/gitlab/background_migration/populate_namespace_statistics_spec.rb index 98b2bc437f3..4a7d52ee784 100644 --- a/spec/lib/gitlab/background_migration/populate_namespace_statistics_spec.rb +++ b/spec/lib/gitlab/background_migration/populate_namespace_statistics_spec.rb @@ -3,10 +3,10 @@ require 'spec_helper' RSpec.describe Gitlab::BackgroundMigration::PopulateNamespaceStatistics do - let_it_be(:namespaces) { table(:namespaces) } - let_it_be(:namespace_statistics) { table(:namespace_statistics) } - let_it_be(:dependency_proxy_manifests) { table(:dependency_proxy_manifests) } - let_it_be(:dependency_proxy_blobs) { table(:dependency_proxy_blobs) } + let!(:namespaces) { table(:namespaces) } + let!(:namespace_statistics) { table(:namespace_statistics) } + let!(:dependency_proxy_manifests) { table(:dependency_proxy_manifests) } + let!(:dependency_proxy_blobs) { table(:dependency_proxy_blobs) } let!(:group1) { namespaces.create!(id: 10, type: 'Group', name: 'group1', path: 'group1') } let!(:group2) { namespaces.create!(id: 20, type: 'Group', name: 'group2', path: 'group2') } diff --git a/spec/lib/gitlab/background_migration/remove_backfilled_job_artifacts_expire_at_spec.rb b/spec/lib/gitlab/background_migration/remove_backfilled_job_artifacts_expire_at_spec.rb index 10597e65910..5fede892463 100644 --- a/spec/lib/gitlab/background_migration/remove_backfilled_job_artifacts_expire_at_spec.rb +++ b/spec/lib/gitlab/background_migration/remove_backfilled_job_artifacts_expire_at_spec.rb @@ -20,8 +20,8 @@ RSpec.describe Gitlab::BackgroundMigration::RemoveBackfilledJobArtifactsExpireAt ) end - let_it_be(:namespace) { table(:namespaces).create!(id: 1, name: 'user', path: 'user') } - let_it_be(:project) do + let!(:namespace) { table(:namespaces).create!(id: 1, name: 'user', path: 'user') } + let!(:project) do table(:projects).create!( id: 1, name: 'gitlab1', diff --git a/spec/lib/gitlab/background_migration/update_timelogs_null_spent_at_spec.rb b/spec/lib/gitlab/background_migration/update_timelogs_null_spent_at_spec.rb index 982e3319063..908f11aabc3 100644 --- a/spec/lib/gitlab/background_migration/update_timelogs_null_spent_at_spec.rb +++ b/spec/lib/gitlab/background_migration/update_timelogs_null_spent_at_spec.rb @@ -3,19 +3,19 @@ require 'spec_helper' RSpec.describe Gitlab::BackgroundMigration::UpdateTimelogsNullSpentAt, schema: 20211215090620 do - let_it_be(:previous_time) { 10.days.ago } - let_it_be(:namespace) { table(:namespaces).create!(name: 'namespace', path: 'namespace') } - let_it_be(:project) { table(:projects).create!(namespace_id: namespace.id) } - let_it_be(:issue) { table(:issues).create!(project_id: project.id) } - let_it_be(:merge_request) { table(:merge_requests).create!(target_project_id: project.id, source_branch: 'master', target_branch: 'feature') } - let_it_be(:timelog1) { create_timelog!(issue_id: issue.id) } - let_it_be(:timelog2) { create_timelog!(merge_request_id: merge_request.id) } - let_it_be(:timelog3) { create_timelog!(issue_id: issue.id, spent_at: previous_time) } - let_it_be(:timelog4) { create_timelog!(merge_request_id: merge_request.id, spent_at: previous_time) } + let!(:previous_time) { 10.days.ago } + let!(:namespace) { table(:namespaces).create!(name: 'namespace', path: 'namespace') } + let!(:project) { table(:projects).create!(namespace_id: namespace.id) } + let!(:issue) { table(:issues).create!(project_id: project.id) } + let!(:merge_request) { table(:merge_requests).create!(target_project_id: project.id, source_branch: 'master', target_branch: 'feature') } + let!(:timelog1) { create_timelog!(issue_id: issue.id) } + let!(:timelog2) { create_timelog!(merge_request_id: merge_request.id) } + let!(:timelog3) { create_timelog!(issue_id: issue.id, spent_at: previous_time) } + let!(:timelog4) { create_timelog!(merge_request_id: merge_request.id, spent_at: previous_time) } subject(:background_migration) { described_class.new } - before_all do + before do table(:timelogs).where.not(id: [timelog3.id, timelog4.id]).update_all(spent_at: nil) end diff --git a/spec/migrations/20210406144743_backfill_total_tuple_count_for_batched_migrations_spec.rb b/spec/migrations/20210406144743_backfill_total_tuple_count_for_batched_migrations_spec.rb index 1f18f7e581a..78001ac3ae9 100644 --- a/spec/migrations/20210406144743_backfill_total_tuple_count_for_batched_migrations_spec.rb +++ b/spec/migrations/20210406144743_backfill_total_tuple_count_for_batched_migrations_spec.rb @@ -4,11 +4,11 @@ require 'spec_helper' require_migration! RSpec.describe BackfillTotalTupleCountForBatchedMigrations, :migration, schema: 20210406140057 do - let_it_be(:table_name) { 'projects' } + let!(:table_name) { 'projects' } - let_it_be(:migrations) { table(:batched_background_migrations) } + let!(:migrations) { table(:batched_background_migrations) } - let_it_be(:migration) do + let!(:migration) do migrations.create!( created_at: Time.now, updated_at: Time.now, diff --git a/spec/migrations/20210423160427_schedule_drop_invalid_vulnerabilities_spec.rb b/spec/migrations/20210423160427_schedule_drop_invalid_vulnerabilities_spec.rb index faf440eb117..99dee9f47e9 100644 --- a/spec/migrations/20210423160427_schedule_drop_invalid_vulnerabilities_spec.rb +++ b/spec/migrations/20210423160427_schedule_drop_invalid_vulnerabilities_spec.rb @@ -4,32 +4,32 @@ require 'spec_helper' require_migration! RSpec.describe ScheduleDropInvalidVulnerabilities, :migration do - let_it_be(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } - let_it_be(:users) { table(:users) } - let_it_be(:user) { create_user! } - let_it_be(:project) { table(:projects).create!(id: 123, namespace_id: namespace.id) } + let!(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } + let!(:users) { table(:users) } + let!(:user) { create_user! } + let!(:project) { table(:projects).create!(id: 123, namespace_id: namespace.id) } - let_it_be(:scanners) { table(:vulnerability_scanners) } - let_it_be(:scanner) { scanners.create!(project_id: project.id, external_id: 'test 1', name: 'test scanner 1') } - let_it_be(:different_scanner) { scanners.create!(project_id: project.id, external_id: 'test 2', name: 'test scanner 2') } + let!(:scanners) { table(:vulnerability_scanners) } + let!(:scanner) { scanners.create!(project_id: project.id, external_id: 'test 1', name: 'test scanner 1') } + let!(:different_scanner) { scanners.create!(project_id: project.id, external_id: 'test 2', name: 'test scanner 2') } - let_it_be(:vulnerabilities) { table(:vulnerabilities) } - let_it_be(:vulnerability_with_finding) do + let!(:vulnerabilities) { table(:vulnerabilities) } + let!(:vulnerability_with_finding) do create_vulnerability!( project_id: project.id, author_id: user.id ) end - let_it_be(:vulnerability_without_finding) do + let!(:vulnerability_without_finding) do create_vulnerability!( project_id: project.id, author_id: user.id ) end - let_it_be(:vulnerability_identifiers) { table(:vulnerability_identifiers) } - let_it_be(:primary_identifier) do + let!(:vulnerability_identifiers) { table(:vulnerability_identifiers) } + let!(:primary_identifier) do vulnerability_identifiers.create!( project_id: project.id, external_type: 'uuid-v5', @@ -38,8 +38,8 @@ RSpec.describe ScheduleDropInvalidVulnerabilities, :migration do name: 'Identifier for UUIDv5') end - let_it_be(:vulnerabilities_findings) { table(:vulnerability_occurrences) } - let_it_be(:finding) do + let!(:vulnerabilities_findings) { table(:vulnerability_occurrences) } + let!(:finding) do create_finding!( vulnerability_id: vulnerability_with_finding.id, project_id: project.id, diff --git a/spec/migrations/20210511142748_schedule_drop_invalid_vulnerabilities2_spec.rb b/spec/migrations/20210511142748_schedule_drop_invalid_vulnerabilities2_spec.rb index dd557c833f3..d2a297e84c6 100644 --- a/spec/migrations/20210511142748_schedule_drop_invalid_vulnerabilities2_spec.rb +++ b/spec/migrations/20210511142748_schedule_drop_invalid_vulnerabilities2_spec.rb @@ -4,34 +4,34 @@ require 'spec_helper' require_migration! RSpec.describe ScheduleDropInvalidVulnerabilities2, :migration do - let_it_be(:background_migration_jobs) { table(:background_migration_jobs) } + let!(:background_migration_jobs) { table(:background_migration_jobs) } - let_it_be(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } - let_it_be(:users) { table(:users) } - let_it_be(:user) { create_user! } - let_it_be(:project) { table(:projects).create!(id: 123, namespace_id: namespace.id) } + let!(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } + let!(:users) { table(:users) } + let!(:user) { create_user! } + let!(:project) { table(:projects).create!(id: 123, namespace_id: namespace.id) } - let_it_be(:scanners) { table(:vulnerability_scanners) } - let_it_be(:scanner) { scanners.create!(project_id: project.id, external_id: 'test 1', name: 'test scanner 1') } - let_it_be(:different_scanner) { scanners.create!(project_id: project.id, external_id: 'test 2', name: 'test scanner 2') } + let!(:scanners) { table(:vulnerability_scanners) } + let!(:scanner) { scanners.create!(project_id: project.id, external_id: 'test 1', name: 'test scanner 1') } + let!(:different_scanner) { scanners.create!(project_id: project.id, external_id: 'test 2', name: 'test scanner 2') } - let_it_be(:vulnerabilities) { table(:vulnerabilities) } - let_it_be(:vulnerability_with_finding) do + let!(:vulnerabilities) { table(:vulnerabilities) } + let!(:vulnerability_with_finding) do create_vulnerability!( project_id: project.id, author_id: user.id ) end - let_it_be(:vulnerability_without_finding) do + let!(:vulnerability_without_finding) do create_vulnerability!( project_id: project.id, author_id: user.id ) end - let_it_be(:vulnerability_identifiers) { table(:vulnerability_identifiers) } - let_it_be(:primary_identifier) do + let!(:vulnerability_identifiers) { table(:vulnerability_identifiers) } + let!(:primary_identifier) do vulnerability_identifiers.create!( project_id: project.id, external_type: 'uuid-v5', @@ -40,8 +40,8 @@ RSpec.describe ScheduleDropInvalidVulnerabilities2, :migration do name: 'Identifier for UUIDv5') end - let_it_be(:vulnerabilities_findings) { table(:vulnerability_occurrences) } - let_it_be(:finding) do + let!(:vulnerabilities_findings) { table(:vulnerability_occurrences) } + let!(:finding) do create_finding!( vulnerability_id: vulnerability_with_finding.id, project_id: project.id, diff --git a/spec/migrations/20210722150102_operations_feature_flags_correct_flexible_rollout_values_spec.rb b/spec/migrations/20210722150102_operations_feature_flags_correct_flexible_rollout_values_spec.rb index 94af2bb1e9a..3adde8fccd1 100644 --- a/spec/migrations/20210722150102_operations_feature_flags_correct_flexible_rollout_values_spec.rb +++ b/spec/migrations/20210722150102_operations_feature_flags_correct_flexible_rollout_values_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' require_migration! RSpec.describe OperationsFeatureFlagsCorrectFlexibleRolloutValues, :migration do - let_it_be(:strategies) { table(:operations_strategies) } + let!(:strategies) { table(:operations_strategies) } let(:namespace) { table(:namespaces).create!(name: 'feature_flag', path: 'feature_flag') } let(:project) { table(:projects).create!(namespace_id: namespace.id) } diff --git a/spec/migrations/20210804150320_create_base_work_item_types_spec.rb b/spec/migrations/20210804150320_create_base_work_item_types_spec.rb index ae510826fe1..f8e571f8eab 100644 --- a/spec/migrations/20210804150320_create_base_work_item_types_spec.rb +++ b/spec/migrations/20210804150320_create_base_work_item_types_spec.rb @@ -6,7 +6,7 @@ require_migration! RSpec.describe CreateBaseWorkItemTypes, :migration do include MigrationHelpers::WorkItemTypesHelper - let_it_be(:work_item_types) { table(:work_item_types) } + let!(:work_item_types) { table(:work_item_types) } let(:base_types) do { diff --git a/spec/migrations/20210831203408_upsert_base_work_item_types_spec.rb b/spec/migrations/20210831203408_upsert_base_work_item_types_spec.rb index 552602983d9..f2abd34f632 100644 --- a/spec/migrations/20210831203408_upsert_base_work_item_types_spec.rb +++ b/spec/migrations/20210831203408_upsert_base_work_item_types_spec.rb @@ -6,7 +6,7 @@ require_migration! RSpec.describe UpsertBaseWorkItemTypes, :migration do include MigrationHelpers::WorkItemTypesHelper - let_it_be(:work_item_types) { table(:work_item_types) } + let!(:work_item_types) { table(:work_item_types) } let(:base_types) do { diff --git a/spec/migrations/20210918201050_remove_old_pending_jobs_for_recalculate_vulnerabilities_occurrences_uuid_spec.rb b/spec/migrations/20210918201050_remove_old_pending_jobs_for_recalculate_vulnerabilities_occurrences_uuid_spec.rb index d1c04c5d320..5943a80abf0 100644 --- a/spec/migrations/20210918201050_remove_old_pending_jobs_for_recalculate_vulnerabilities_occurrences_uuid_spec.rb +++ b/spec/migrations/20210918201050_remove_old_pending_jobs_for_recalculate_vulnerabilities_occurrences_uuid_spec.rb @@ -22,9 +22,9 @@ def create_background_migration_jobs(ids, status, created_at) end RSpec.describe RemoveOldPendingJobsForRecalculateVulnerabilitiesOccurrencesUuid, :migration do - let_it_be(:background_migration_jobs) { table(:background_migration_jobs) } - let_it_be(:before_target_date) { -Float::INFINITY..(DateTime.new(2021, 8, 17, 23, 59, 59)) } - let_it_be(:after_target_date) { (DateTime.new(2021, 8, 18, 0, 0, 0))..Float::INFINITY } + let!(:background_migration_jobs) { table(:background_migration_jobs) } + let!(:before_target_date) { -Float::INFINITY..(DateTime.new(2021, 8, 17, 23, 59, 59)) } + let!(:after_target_date) { (DateTime.new(2021, 8, 18, 0, 0, 0))..Float::INFINITY } context 'when old RecalculateVulnerabilitiesOccurrencesUuid jobs are pending' do before do diff --git a/spec/migrations/20211110143306_add_not_null_constraint_to_security_findings_uuid_spec.rb b/spec/migrations/20211110143306_add_not_null_constraint_to_security_findings_uuid_spec.rb index 946fbf7f568..0d1de294708 100644 --- a/spec/migrations/20211110143306_add_not_null_constraint_to_security_findings_uuid_spec.rb +++ b/spec/migrations/20211110143306_add_not_null_constraint_to_security_findings_uuid_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' require_migration! RSpec.describe AddNotNullConstraintToSecurityFindingsUuid do - let_it_be(:security_findings) { table(:security_findings) } - let_it_be(:migration) { described_class.new } + let!(:security_findings) { table(:security_findings) } + let!(:migration) { described_class.new } before do allow(migration).to receive(:transaction_open?).and_return(false) diff --git a/spec/migrations/20211110151350_schedule_drop_invalid_security_findings_spec.rb b/spec/migrations/20211110151350_schedule_drop_invalid_security_findings_spec.rb index b35cf5cbf4c..57ddbe4c71b 100644 --- a/spec/migrations/20211110151350_schedule_drop_invalid_security_findings_spec.rb +++ b/spec/migrations/20211110151350_schedule_drop_invalid_security_findings_spec.rb @@ -3,20 +3,20 @@ require 'spec_helper' require_migration! -RSpec.describe ScheduleDropInvalidSecurityFindings, :migration, schema: 20211108211434 do - let_it_be(:background_migration_jobs) { table(:background_migration_jobs) } +RSpec.describe ScheduleDropInvalidSecurityFindings, :migration, :suppress_gitlab_schemas_validate_connection, schema: 20211108211434 do + let!(:background_migration_jobs) { table(:background_migration_jobs) } - let_it_be(:namespace) { table(:namespaces).create!(name: 'user', path: 'user', type: Namespaces::UserNamespace.sti_name) } - let_it_be(:project) { table(:projects).create!(namespace_id: namespace.id) } + let!(:namespace) { table(:namespaces).create!(name: 'user', path: 'user', type: Namespaces::UserNamespace.sti_name) } + let!(:project) { table(:projects).create!(namespace_id: namespace.id) } - let_it_be(:pipelines) { table(:ci_pipelines) } - let_it_be(:pipeline) { pipelines.create!(project_id: project.id) } + let!(:pipelines) { table(:ci_pipelines) } + let!(:pipeline) { pipelines.create!(project_id: project.id) } - let_it_be(:ci_builds) { table(:ci_builds) } - let_it_be(:ci_build) { ci_builds.create! } + let!(:ci_builds) { table(:ci_builds) } + let!(:ci_build) { ci_builds.create! } - let_it_be(:security_scans) { table(:security_scans) } - let_it_be(:security_scan) do + let!(:security_scans) { table(:security_scans) } + let!(:security_scan) do security_scans.create!( scan_type: 1, status: 1, @@ -26,11 +26,11 @@ RSpec.describe ScheduleDropInvalidSecurityFindings, :migration, schema: 20211108 ) end - let_it_be(:vulnerability_scanners) { table(:vulnerability_scanners) } - let_it_be(:vulnerability_scanner) { vulnerability_scanners.create!(project_id: project.id, external_id: 'test 1', name: 'test scanner 1') } + let!(:vulnerability_scanners) { table(:vulnerability_scanners) } + let!(:vulnerability_scanner) { vulnerability_scanners.create!(project_id: project.id, external_id: 'test 1', name: 'test scanner 1') } - let_it_be(:security_findings) { table(:security_findings) } - let_it_be(:security_finding_without_uuid) do + let!(:security_findings) { table(:security_findings) } + let!(:security_finding_without_uuid) do security_findings.create!( severity: 1, confidence: 1, @@ -40,7 +40,7 @@ RSpec.describe ScheduleDropInvalidSecurityFindings, :migration, schema: 20211108 ) end - let_it_be(:security_finding_with_uuid) do + let!(:security_finding_with_uuid) do security_findings.create!( severity: 1, confidence: 1, diff --git a/spec/migrations/20211116111644_schedule_remove_occurrence_pipelines_and_duplicate_vulnerabilities_findings_spec.rb b/spec/migrations/20211116111644_schedule_remove_occurrence_pipelines_and_duplicate_vulnerabilities_findings_spec.rb index cf6a033b4b8..a80332aa743 100644 --- a/spec/migrations/20211116111644_schedule_remove_occurrence_pipelines_and_duplicate_vulnerabilities_findings_spec.rb +++ b/spec/migrations/20211116111644_schedule_remove_occurrence_pipelines_and_duplicate_vulnerabilities_findings_spec.rb @@ -5,22 +5,22 @@ require_migration! RSpec.describe ScheduleRemoveOccurrencePipelinesAndDuplicateVulnerabilitiesFindings, :suppress_gitlab_schemas_validate_connection, :migration do - let_it_be(:background_migration_jobs) { table(:background_migration_jobs) } - let_it_be(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } - let_it_be(:users) { table(:users) } - let_it_be(:user) { create_user! } - let_it_be(:project) { table(:projects).create!(id: 14219619, namespace_id: namespace.id) } - let_it_be(:pipelines) { table(:ci_pipelines) } - let_it_be(:scanners) { table(:vulnerability_scanners) } - let_it_be(:scanner1) { scanners.create!(project_id: project.id, external_id: 'test 1', name: 'test scanner 1') } - let_it_be(:scanner2) { scanners.create!(project_id: project.id, external_id: 'test 2', name: 'test scanner 2') } - let_it_be(:scanner3) { scanners.create!(project_id: project.id, external_id: 'test 3', name: 'test scanner 3') } - let_it_be(:unrelated_scanner) { scanners.create!(project_id: project.id, external_id: 'unreleated_scanner', name: 'unrelated scanner') } - let_it_be(:vulnerabilities) { table(:vulnerabilities) } - let_it_be(:vulnerability_findings) { table(:vulnerability_occurrences) } - let_it_be(:vulnerability_finding_pipelines) { table(:vulnerability_occurrence_pipelines) } - let_it_be(:vulnerability_identifiers) { table(:vulnerability_identifiers) } - let_it_be(:vulnerability_identifier) do + let!(:background_migration_jobs) { table(:background_migration_jobs) } + let!(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } + let!(:users) { table(:users) } + let!(:user) { create_user! } + let!(:project) { table(:projects).create!(id: 14219619, namespace_id: namespace.id) } + let!(:pipelines) { table(:ci_pipelines) } + let!(:scanners) { table(:vulnerability_scanners) } + let!(:scanner1) { scanners.create!(project_id: project.id, external_id: 'test 1', name: 'test scanner 1') } + let!(:scanner2) { scanners.create!(project_id: project.id, external_id: 'test 2', name: 'test scanner 2') } + let!(:scanner3) { scanners.create!(project_id: project.id, external_id: 'test 3', name: 'test scanner 3') } + let!(:unrelated_scanner) { scanners.create!(project_id: project.id, external_id: 'unreleated_scanner', name: 'unrelated scanner') } + let!(:vulnerabilities) { table(:vulnerabilities) } + let!(:vulnerability_findings) { table(:vulnerability_occurrences) } + let!(:vulnerability_finding_pipelines) { table(:vulnerability_occurrence_pipelines) } + let!(:vulnerability_identifiers) { table(:vulnerability_identifiers) } + let!(:vulnerability_identifier) do vulnerability_identifiers.create!( id: 1244459, project_id: project.id, @@ -30,14 +30,14 @@ RSpec.describe ScheduleRemoveOccurrencePipelinesAndDuplicateVulnerabilitiesFindi name: 'vulnerability identifier') end - let_it_be(:vulnerability_for_first_duplicate) do + let!(:vulnerability_for_first_duplicate) do create_vulnerability!( project_id: project.id, author_id: user.id ) end - let_it_be(:first_finding_duplicate) do + let!(:first_finding_duplicate) do create_finding!( id: 5606961, uuid: "bd95c085-71aa-51d7-9bb6-08ae669c262e", @@ -50,14 +50,14 @@ RSpec.describe ScheduleRemoveOccurrencePipelinesAndDuplicateVulnerabilitiesFindi ) end - let_it_be(:vulnerability_for_second_duplicate) do + let!(:vulnerability_for_second_duplicate) do create_vulnerability!( project_id: project.id, author_id: user.id ) end - let_it_be(:second_finding_duplicate) do + let!(:second_finding_duplicate) do create_finding!( id: 8765432, uuid: "5b714f58-1176-5b26-8fd5-e11dfcb031b5", @@ -70,14 +70,14 @@ RSpec.describe ScheduleRemoveOccurrencePipelinesAndDuplicateVulnerabilitiesFindi ) end - let_it_be(:vulnerability_for_third_duplicate) do + let!(:vulnerability_for_third_duplicate) do create_vulnerability!( project_id: project.id, author_id: user.id ) end - let_it_be(:third_finding_duplicate) do + let!(:third_finding_duplicate) do create_finding!( id: 8832995, uuid: "cfe435fa-b25b-5199-a56d-7b007cc9e2d4", @@ -90,7 +90,7 @@ RSpec.describe ScheduleRemoveOccurrencePipelinesAndDuplicateVulnerabilitiesFindi ) end - let_it_be(:unrelated_finding) do + let!(:unrelated_finding) do create_finding!( id: 9999999, uuid: "unreleated_finding", diff --git a/spec/migrations/20211126204445_add_task_to_work_item_types_spec.rb b/spec/migrations/20211126204445_add_task_to_work_item_types_spec.rb index 34a6e2fdd12..935f15df75d 100644 --- a/spec/migrations/20211126204445_add_task_to_work_item_types_spec.rb +++ b/spec/migrations/20211126204445_add_task_to_work_item_types_spec.rb @@ -6,7 +6,7 @@ require_migration! RSpec.describe AddTaskToWorkItemTypes, :migration do include MigrationHelpers::WorkItemTypesHelper - let_it_be(:work_item_types) { table(:work_item_types) } + let!(:work_item_types) { table(:work_item_types) } let(:base_types) do { diff --git a/spec/migrations/20211207125331_remove_jobs_for_recalculate_vulnerabilities_occurrences_uuid_spec.rb b/spec/migrations/20211207125331_remove_jobs_for_recalculate_vulnerabilities_occurrences_uuid_spec.rb index 491aad1b30b..c3003eda0f6 100644 --- a/spec/migrations/20211207125331_remove_jobs_for_recalculate_vulnerabilities_occurrences_uuid_spec.rb +++ b/spec/migrations/20211207125331_remove_jobs_for_recalculate_vulnerabilities_occurrences_uuid_spec.rb @@ -21,7 +21,7 @@ def create_background_migration_jobs(ids, status, created_at) end RSpec.describe RemoveJobsForRecalculateVulnerabilitiesOccurrencesUuid, :migration do - let_it_be(:background_migration_jobs) { table(:background_migration_jobs) } + let!(:background_migration_jobs) { table(:background_migration_jobs) } context 'when RecalculateVulnerabilitiesOccurrencesUuid jobs are present' do before do diff --git a/spec/migrations/20211210140629_encrypt_static_object_token_spec.rb b/spec/migrations/20211210140629_encrypt_static_object_token_spec.rb index 289cf9a93ed..aa2d25976c6 100644 --- a/spec/migrations/20211210140629_encrypt_static_object_token_spec.rb +++ b/spec/migrations/20211210140629_encrypt_static_object_token_spec.rb @@ -4,8 +4,8 @@ require 'spec_helper' require_migration! RSpec.describe EncryptStaticObjectToken, :migration do - let_it_be(:background_migration_jobs) { table(:background_migration_jobs) } - let_it_be(:users) { table(:users) } + let!(:background_migration_jobs) { table(:background_migration_jobs) } + let!(:users) { table(:users) } let!(:user_without_tokens) { create_user!(name: 'notoken') } let!(:user_with_plaintext_token_1) { create_user!(name: 'plaintext_1', token: 'token') } diff --git a/spec/migrations/20211217174331_mark_recalculate_finding_signatures_as_completed_spec.rb b/spec/migrations/20211217174331_mark_recalculate_finding_signatures_as_completed_spec.rb index c5058f30d82..3df3959c947 100644 --- a/spec/migrations/20211217174331_mark_recalculate_finding_signatures_as_completed_spec.rb +++ b/spec/migrations/20211217174331_mark_recalculate_finding_signatures_as_completed_spec.rb @@ -21,7 +21,7 @@ def create_background_migration_jobs(ids, status, created_at) end RSpec.describe MarkRecalculateFindingSignaturesAsCompleted, :migration do - let_it_be(:background_migration_jobs) { table(:background_migration_jobs) } + let!(:background_migration_jobs) { table(:background_migration_jobs) } context 'when RecalculateVulnerabilitiesOccurrencesUuid jobs are present' do before do diff --git a/spec/migrations/20220107064845_populate_vulnerability_reads_spec.rb b/spec/migrations/20220107064845_populate_vulnerability_reads_spec.rb index 063a51227dd..44e8343256c 100644 --- a/spec/migrations/20220107064845_populate_vulnerability_reads_spec.rb +++ b/spec/migrations/20220107064845_populate_vulnerability_reads_spec.rb @@ -4,16 +4,16 @@ require 'spec_helper' require_migration! RSpec.describe PopulateVulnerabilityReads, :migration do - let_it_be(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } - let_it_be(:user) { table(:users).create!(email: 'author@example.com', username: 'author', projects_limit: 10) } - let_it_be(:project) { table(:projects).create!(namespace_id: namespace.id) } - let_it_be(:scanner) { table(:vulnerability_scanners).create!(project_id: project.id, external_id: 'test 1', name: 'test scanner 1') } - let_it_be(:background_migration_jobs) { table(:background_migration_jobs) } - let_it_be(:vulnerabilities) { table(:vulnerabilities) } - let_it_be(:vulnerability_reads) { table(:vulnerability_reads) } - let_it_be(:vulnerabilities_findings) { table(:vulnerability_occurrences) } - let_it_be(:vulnerability_issue_links) { table(:vulnerability_issue_links) } - let_it_be(:vulnerability_ids) { [] } + let!(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } + let!(:user) { table(:users).create!(email: 'author@example.com', username: 'author', projects_limit: 10) } + let!(:project) { table(:projects).create!(namespace_id: namespace.id) } + let!(:scanner) { table(:vulnerability_scanners).create!(project_id: project.id, external_id: 'test 1', name: 'test scanner 1') } + let!(:background_migration_jobs) { table(:background_migration_jobs) } + let!(:vulnerabilities) { table(:vulnerabilities) } + let!(:vulnerability_reads) { table(:vulnerability_reads) } + let!(:vulnerabilities_findings) { table(:vulnerability_occurrences) } + let!(:vulnerability_issue_links) { table(:vulnerability_issue_links) } + let!(:vulnerability_ids) { [] } before do stub_const("#{described_class}::BATCH_SIZE", 1) diff --git a/spec/migrations/20220204095121_backfill_namespace_statistics_with_dependency_proxy_size_spec.rb b/spec/migrations/20220204095121_backfill_namespace_statistics_with_dependency_proxy_size_spec.rb index 39398fa058d..a207c76c122 100644 --- a/spec/migrations/20220204095121_backfill_namespace_statistics_with_dependency_proxy_size_spec.rb +++ b/spec/migrations/20220204095121_backfill_namespace_statistics_with_dependency_proxy_size_spec.rb @@ -4,22 +4,22 @@ require 'spec_helper' require_migration! RSpec.describe BackfillNamespaceStatisticsWithDependencyProxySize do - let_it_be(:groups) { table(:namespaces) } - let_it_be(:group1) { groups.create!(id: 10, name: 'test1', path: 'test1', type: 'Group') } - let_it_be(:group2) { groups.create!(id: 20, name: 'test2', path: 'test2', type: 'Group') } - let_it_be(:group3) { groups.create!(id: 30, name: 'test3', path: 'test3', type: 'Group') } - let_it_be(:group4) { groups.create!(id: 40, name: 'test4', path: 'test4', type: 'Group') } + let!(:groups) { table(:namespaces) } + let!(:group1) { groups.create!(id: 10, name: 'test1', path: 'test1', type: 'Group') } + let!(:group2) { groups.create!(id: 20, name: 'test2', path: 'test2', type: 'Group') } + let!(:group3) { groups.create!(id: 30, name: 'test3', path: 'test3', type: 'Group') } + let!(:group4) { groups.create!(id: 40, name: 'test4', path: 'test4', type: 'Group') } - let_it_be(:dependency_proxy_blobs) { table(:dependency_proxy_blobs) } - let_it_be(:dependency_proxy_manifests) { table(:dependency_proxy_manifests) } + let!(:dependency_proxy_blobs) { table(:dependency_proxy_blobs) } + let!(:dependency_proxy_manifests) { table(:dependency_proxy_manifests) } - let_it_be(:group1_manifest) { create_manifest(10, 10) } - let_it_be(:group2_manifest) { create_manifest(20, 20) } - let_it_be(:group3_manifest) { create_manifest(30, 30) } + let!(:group1_manifest) { create_manifest(10, 10) } + let!(:group2_manifest) { create_manifest(20, 20) } + let!(:group3_manifest) { create_manifest(30, 30) } - let_it_be(:group1_blob) { create_blob(10, 10) } - let_it_be(:group2_blob) { create_blob(20, 20) } - let_it_be(:group3_blob) { create_blob(30, 30) } + let!(:group1_blob) { create_blob(10, 10) } + let!(:group2_blob) { create_blob(20, 20) } + let!(:group3_blob) { create_blob(30, 30) } describe '#up' do it 'correctly schedules background migrations' do diff --git a/spec/migrations/20220208080921_schedule_migrate_personal_namespace_project_maintainer_to_owner_spec.rb b/spec/migrations/20220208080921_schedule_migrate_personal_namespace_project_maintainer_to_owner_spec.rb index 41f3476dea8..a7c3eb46204 100644 --- a/spec/migrations/20220208080921_schedule_migrate_personal_namespace_project_maintainer_to_owner_spec.rb +++ b/spec/migrations/20220208080921_schedule_migrate_personal_namespace_project_maintainer_to_owner_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe ScheduleMigratePersonalNamespaceProjectMaintainerToOwner do - let_it_be(:migration) { described_class::MIGRATION } + let!(:migration) { described_class::MIGRATION } describe '#up' do it 'schedules background jobs for each batch of members' do diff --git a/spec/migrations/20220222192524_create_not_null_constraint_releases_tag_spec.rb b/spec/migrations/20220222192524_create_not_null_constraint_releases_tag_spec.rb index bd7d992240a..7ecb91d75cd 100644 --- a/spec/migrations/20220222192524_create_not_null_constraint_releases_tag_spec.rb +++ b/spec/migrations/20220222192524_create_not_null_constraint_releases_tag_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' require_migration! RSpec.describe CreateNotNullConstraintReleasesTag do - let_it_be(:releases) { table(:releases) } - let_it_be(:migration) { described_class.new } + let!(:releases) { table(:releases) } + let!(:migration) { described_class.new } before do allow(migration).to receive(:transaction_open?).and_return(false) diff --git a/spec/migrations/20220305223212_add_security_training_providers_spec.rb b/spec/migrations/20220305223212_add_security_training_providers_spec.rb index 3d0089aaa8d..691ba7d8546 100644 --- a/spec/migrations/20220305223212_add_security_training_providers_spec.rb +++ b/spec/migrations/20220305223212_add_security_training_providers_spec.rb @@ -6,7 +6,7 @@ require_migration! RSpec.describe AddSecurityTrainingProviders, :migration do include MigrationHelpers::WorkItemTypesHelper - let_it_be(:security_training_providers) { table(:security_training_providers) } + let!(:security_training_providers) { table(:security_training_providers) } it 'creates default data' do # Need to delete all as security training providers are seeded before entire test suite diff --git a/spec/migrations/20220316202640_populate_container_repositories_migration_plan_spec.rb b/spec/migrations/20220316202640_populate_container_repositories_migration_plan_spec.rb index 7b5c8254163..7cb3e57f80a 100644 --- a/spec/migrations/20220316202640_populate_container_repositories_migration_plan_spec.rb +++ b/spec/migrations/20220316202640_populate_container_repositories_migration_plan_spec.rb @@ -4,9 +4,9 @@ require 'spec_helper' require_migration! RSpec.describe PopulateContainerRepositoriesMigrationPlan, :aggregate_failures do - let_it_be(:namespaces) { table(:namespaces) } - let_it_be(:projects) { table(:projects) } - let_it_be(:container_repositories) { table(:container_repositories) } + let!(:namespaces) { table(:namespaces) } + let!(:projects) { table(:projects) } + let!(:container_repositories) { table(:container_repositories) } let!(:namespace) { namespaces.create!(id: 1, name: 'namespace', path: 'namespace') } let!(:project) { projects.create!(id: 1, name: 'project', path: 'project', namespace_id: 1) } diff --git a/spec/migrations/20220324165436_schedule_backfill_project_settings_spec.rb b/spec/migrations/20220324165436_schedule_backfill_project_settings_spec.rb index a8014e73bf0..ed1454fa732 100644 --- a/spec/migrations/20220324165436_schedule_backfill_project_settings_spec.rb +++ b/spec/migrations/20220324165436_schedule_backfill_project_settings_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe ScheduleBackfillProjectSettings do - let_it_be(:migration) { described_class::MIGRATION } + let!(:migration) { described_class::MIGRATION } describe '#up' do it 'schedules background jobs for each batch of projects' do diff --git a/spec/migrations/20220416054011_schedule_backfill_project_member_namespace_id_spec.rb b/spec/migrations/20220416054011_schedule_backfill_project_member_namespace_id_spec.rb index 2838fc9387c..d5b979c2fcf 100644 --- a/spec/migrations/20220416054011_schedule_backfill_project_member_namespace_id_spec.rb +++ b/spec/migrations/20220416054011_schedule_backfill_project_member_namespace_id_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe ScheduleBackfillProjectMemberNamespaceId do - let_it_be(:migration) { described_class::MIGRATION } + let!(:migration) { described_class::MIGRATION } describe '#up' do it 'schedules background jobs for each batch of project members' do diff --git a/spec/migrations/20220513043344_reschedule_expire_o_auth_tokens_spec.rb b/spec/migrations/20220513043344_reschedule_expire_o_auth_tokens_spec.rb index 63fff279acc..e550920aa66 100644 --- a/spec/migrations/20220513043344_reschedule_expire_o_auth_tokens_spec.rb +++ b/spec/migrations/20220513043344_reschedule_expire_o_auth_tokens_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe RescheduleExpireOAuthTokens do - let_it_be(:migration) { described_class::MIGRATION } + let!(:migration) { described_class::MIGRATION } describe '#up' do it 'schedules background jobs for each batch of oauth tokens' do diff --git a/spec/migrations/20220525221133_schedule_backfill_vulnerability_reads_cluster_agent_spec.rb b/spec/migrations/20220525221133_schedule_backfill_vulnerability_reads_cluster_agent_spec.rb index 3f1a2d8c4b9..924e159bb0d 100644 --- a/spec/migrations/20220525221133_schedule_backfill_vulnerability_reads_cluster_agent_spec.rb +++ b/spec/migrations/20220525221133_schedule_backfill_vulnerability_reads_cluster_agent_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe ScheduleBackfillVulnerabilityReadsClusterAgent do - let_it_be(:batched_migration) { described_class::MIGRATION_NAME } + let!(:batched_migration) { described_class::MIGRATION_NAME } it 'schedules background jobs for each batch of vulnerability reads' do reversible_migration do |migration| diff --git a/spec/migrations/20220601110011_schedule_remove_self_managed_wiki_notes_spec.rb b/spec/migrations/20220601110011_schedule_remove_self_managed_wiki_notes_spec.rb index 44e80980b27..635922077d7 100644 --- a/spec/migrations/20220601110011_schedule_remove_self_managed_wiki_notes_spec.rb +++ b/spec/migrations/20220601110011_schedule_remove_self_managed_wiki_notes_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe ScheduleRemoveSelfManagedWikiNotes do - let_it_be(:batched_migration) { described_class::MIGRATION } + let!(:batched_migration) { described_class::MIGRATION } it 'schedules new batched migration' do reversible_migration do |migration| diff --git a/spec/migrations/20220606080509_fix_incorrect_job_artifacts_expire_at_spec.rb b/spec/migrations/20220606080509_fix_incorrect_job_artifacts_expire_at_spec.rb index 5921dd64c0e..f1f2f90f521 100644 --- a/spec/migrations/20220606080509_fix_incorrect_job_artifacts_expire_at_spec.rb +++ b/spec/migrations/20220606080509_fix_incorrect_job_artifacts_expire_at_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe FixIncorrectJobArtifactsExpireAt, migration: :gitlab_ci do - let_it_be(:batched_migration) { described_class::MIGRATION } + let!(:batched_migration) { described_class::MIGRATION } it 'does not schedule background jobs when Gitlab.com is true' do allow(Gitlab).to receive(:com?).and_return(true) diff --git a/spec/migrations/20220622080547_backfill_project_statistics_with_container_registry_size_spec.rb b/spec/migrations/20220622080547_backfill_project_statistics_with_container_registry_size_spec.rb index 52b75f0b8a9..21be36d2a7b 100644 --- a/spec/migrations/20220622080547_backfill_project_statistics_with_container_registry_size_spec.rb +++ b/spec/migrations/20220622080547_backfill_project_statistics_with_container_registry_size_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe BackfillProjectStatisticsWithContainerRegistrySize do - let_it_be(:batched_migration) { described_class::MIGRATION_CLASS } + let!(:batched_migration) { described_class::MIGRATION_CLASS } it 'does not schedule background jobs when Gitlab.com is false' do allow(Gitlab).to receive(:com?).and_return(false) diff --git a/spec/migrations/20220628012902_finalise_project_namespace_members_spec.rb b/spec/migrations/20220628012902_finalise_project_namespace_members_spec.rb index 1f116cf6a7e..e5103afc07a 100644 --- a/spec/migrations/20220628012902_finalise_project_namespace_members_spec.rb +++ b/spec/migrations/20220628012902_finalise_project_namespace_members_spec.rb @@ -6,7 +6,7 @@ require_migration! RSpec.describe FinaliseProjectNamespaceMembers, :migration do let(:batched_migrations) { table(:batched_background_migrations) } - let_it_be(:migration) { described_class::MIGRATION } + let!(:migration) { described_class::MIGRATION } describe '#up' do shared_examples 'finalizes the migration' do diff --git a/spec/migrations/20220802114351_reschedule_backfill_container_registry_size_into_project_statistics_spec.rb b/spec/migrations/20220802114351_reschedule_backfill_container_registry_size_into_project_statistics_spec.rb index cc1c1dac4c3..6f9ddd5f316 100644 --- a/spec/migrations/20220802114351_reschedule_backfill_container_registry_size_into_project_statistics_spec.rb +++ b/spec/migrations/20220802114351_reschedule_backfill_container_registry_size_into_project_statistics_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe RescheduleBackfillContainerRegistrySizeIntoProjectStatistics do - let_it_be(:batched_migration) { described_class::MIGRATION_CLASS } + let!(:batched_migration) { described_class::MIGRATION_CLASS } it 'does not schedule background jobs when Gitlab.com is false' do allow(Gitlab).to receive(:com?).and_return(false) diff --git a/spec/migrations/20220906074449_schedule_disable_legacy_open_source_license_for_projects_less_than_one_mb_spec.rb b/spec/migrations/20220906074449_schedule_disable_legacy_open_source_license_for_projects_less_than_one_mb_spec.rb index e4ac094ab48..863d8f5d7ac 100644 --- a/spec/migrations/20220906074449_schedule_disable_legacy_open_source_license_for_projects_less_than_one_mb_spec.rb +++ b/spec/migrations/20220906074449_schedule_disable_legacy_open_source_license_for_projects_less_than_one_mb_spec.rb @@ -4,8 +4,8 @@ require 'spec_helper' require_migration! RSpec.describe ScheduleDisableLegacyOpenSourceLicenseForProjectsLessThanOneMb do - let_it_be(:migration) { described_class.new } - let_it_be(:post_migration) { described_class::MIGRATION } + let!(:migration) { described_class.new } + let!(:post_migration) { described_class::MIGRATION } context 'when on gitlab.com' do before do diff --git a/spec/migrations/20220928225711_schedule_update_ci_pipeline_artifacts_locked_status_spec.rb b/spec/migrations/20220928225711_schedule_update_ci_pipeline_artifacts_locked_status_spec.rb index 7e3f8caa966..50eb79ea3dd 100644 --- a/spec/migrations/20220928225711_schedule_update_ci_pipeline_artifacts_locked_status_spec.rb +++ b/spec/migrations/20220928225711_schedule_update_ci_pipeline_artifacts_locked_status_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe ScheduleUpdateCiPipelineArtifactsLockedStatus, migration: :gitlab_ci do - let_it_be(:migration) { described_class::MIGRATION } + let!(:migration) { described_class::MIGRATION } describe '#up' do it 'schedules background jobs for each batch of ci_pipeline_artifacts' do diff --git a/spec/migrations/20220929213730_schedule_delete_orphaned_operational_vulnerabilities_spec.rb b/spec/migrations/20220929213730_schedule_delete_orphaned_operational_vulnerabilities_spec.rb index 9220b5e8a95..2c608ecf7e5 100644 --- a/spec/migrations/20220929213730_schedule_delete_orphaned_operational_vulnerabilities_spec.rb +++ b/spec/migrations/20220929213730_schedule_delete_orphaned_operational_vulnerabilities_spec.rb @@ -4,8 +4,8 @@ require 'spec_helper' require_migration! RSpec.describe ScheduleDeleteOrphanedOperationalVulnerabilities do - let_it_be(:migration) { described_class.new } - let_it_be(:post_migration) { described_class::MIGRATION } + let!(:migration) { described_class.new } + let!(:post_migration) { described_class::MIGRATION } describe '#up' do it 'schedules background jobs for each batch of vulnerabilities' do diff --git a/spec/migrations/20221004094814_schedule_destroy_invalid_members_spec.rb b/spec/migrations/20221004094814_schedule_destroy_invalid_members_spec.rb index 73fdfa78eb4..c62a11dfd9e 100644 --- a/spec/migrations/20221004094814_schedule_destroy_invalid_members_spec.rb +++ b/spec/migrations/20221004094814_schedule_destroy_invalid_members_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe ScheduleDestroyInvalidMembers, :migration do - let_it_be(:migration) { described_class::MIGRATION } + let!(:migration) { described_class::MIGRATION } describe '#up' do it 'schedules background jobs for each batch of members' do diff --git a/spec/migrations/20221012033107_add_password_last_changed_at_to_user_details_spec.rb b/spec/migrations/20221012033107_add_password_last_changed_at_to_user_details_spec.rb index 46a7b097d02..4052636d08c 100644 --- a/spec/migrations/20221012033107_add_password_last_changed_at_to_user_details_spec.rb +++ b/spec/migrations/20221012033107_add_password_last_changed_at_to_user_details_spec.rb @@ -5,9 +5,9 @@ require 'spec_helper' require_migration! RSpec.describe AddPasswordLastChangedAtToUserDetails do - let_it_be(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } - let_it_be(:users) { table(:users) } - let_it_be(:user) { create_user! } + let!(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } + let!(:users) { table(:users) } + let!(:user) { create_user! } let(:user_detail) { table(:user_details).create!(user_id: user.id, provisioned_by_group_id: namespace.id) } describe "#up" do diff --git a/spec/migrations/20221018050323_add_objective_and_keyresult_to_work_item_types_spec.rb b/spec/migrations/20221018050323_add_objective_and_keyresult_to_work_item_types_spec.rb index 4de897802b9..1e8a33c635a 100644 --- a/spec/migrations/20221018050323_add_objective_and_keyresult_to_work_item_types_spec.rb +++ b/spec/migrations/20221018050323_add_objective_and_keyresult_to_work_item_types_spec.rb @@ -6,7 +6,7 @@ require_migration! RSpec.describe AddObjectiveAndKeyresultToWorkItemTypes, :migration do include MigrationHelpers::WorkItemTypesHelper - let_it_be(:work_item_types) { table(:work_item_types) } + let!(:work_item_types) { table(:work_item_types) } let(:base_types) do { diff --git a/spec/migrations/20221018062308_schedule_backfill_project_namespace_details_spec.rb b/spec/migrations/20221018062308_schedule_backfill_project_namespace_details_spec.rb index 4dd6d5757ce..951cfd4e95a 100644 --- a/spec/migrations/20221018062308_schedule_backfill_project_namespace_details_spec.rb +++ b/spec/migrations/20221018062308_schedule_backfill_project_namespace_details_spec.rb @@ -5,8 +5,8 @@ require_migration! RSpec.describe ScheduleBackfillProjectNamespaceDetails, schema: 20221018062308 do context 'when on gitlab.com' do - let_it_be(:background_migration) { described_class::MIGRATION } - let_it_be(:migration) { described_class.new } + let!(:background_migration) { described_class::MIGRATION } + let!(:migration) { described_class.new } before do migration.up diff --git a/spec/migrations/20221018193635_ensure_task_note_renaming_background_migration_finished_spec.rb b/spec/migrations/20221018193635_ensure_task_note_renaming_background_migration_finished_spec.rb index ea95c34674e..3e3cab953b0 100644 --- a/spec/migrations/20221018193635_ensure_task_note_renaming_background_migration_finished_spec.rb +++ b/spec/migrations/20221018193635_ensure_task_note_renaming_background_migration_finished_spec.rb @@ -8,7 +8,7 @@ RSpec.describe EnsureTaskNoteRenamingBackgroundMigrationFinished, :migration do let(:batch_failed_status) { 2 } let(:batch_finalized_status) { 3 } - let_it_be(:migration) { described_class::MIGRATION } + let!(:migration) { described_class::MIGRATION } describe '#up' do shared_examples 'finalizes the migration' do diff --git a/spec/migrations/20221021145820_create_routing_table_for_builds_metadata_v2_spec.rb b/spec/migrations/20221021145820_create_routing_table_for_builds_metadata_v2_spec.rb index 48a00df430d..e65a9706a37 100644 --- a/spec/migrations/20221021145820_create_routing_table_for_builds_metadata_v2_spec.rb +++ b/spec/migrations/20221021145820_create_routing_table_for_builds_metadata_v2_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe CreateRoutingTableForBuildsMetadataV2, :migration do - let_it_be(:migration) { described_class.new } + let!(:migration) { described_class.new } describe '#up' do context 'when the table is already partitioned' do diff --git a/spec/migrations/20221115173607_ensure_work_item_type_backfill_migration_finished_spec.rb b/spec/migrations/20221115173607_ensure_work_item_type_backfill_migration_finished_spec.rb index 70cac5ce2f3..b6f53ba2e4d 100644 --- a/spec/migrations/20221115173607_ensure_work_item_type_backfill_migration_finished_spec.rb +++ b/spec/migrations/20221115173607_ensure_work_item_type_backfill_migration_finished_spec.rb @@ -9,7 +9,7 @@ RSpec.describe EnsureWorkItemTypeBackfillMigrationFinished, :migration do let(:batch_failed_status) { 2 } let(:batch_finalized_status) { 3 } - let_it_be(:migration_class) { described_class::MIGRATION } + let!(:migration_class) { described_class::MIGRATION } describe '#up', :redis do context 'when migration is missing' do diff --git a/spec/migrations/20221122132812_schedule_prune_stale_project_export_jobs_spec.rb b/spec/migrations/20221122132812_schedule_prune_stale_project_export_jobs_spec.rb index 72ae080f859..5a5bc42a37b 100644 --- a/spec/migrations/20221122132812_schedule_prune_stale_project_export_jobs_spec.rb +++ b/spec/migrations/20221122132812_schedule_prune_stale_project_export_jobs_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe SchedulePruneStaleProjectExportJobs, category: :importers do - let_it_be(:batched_migration) { described_class::MIGRATION } + let!(:batched_migration) { described_class::MIGRATION } it 'schedules a new batched migration' do reversible_migration do |migration| diff --git a/spec/migrations/20221123133054_queue_reset_status_on_container_repositories_spec.rb b/spec/migrations/20221123133054_queue_reset_status_on_container_repositories_spec.rb index 79094a2b8d0..2951b738243 100644 --- a/spec/migrations/20221123133054_queue_reset_status_on_container_repositories_spec.rb +++ b/spec/migrations/20221123133054_queue_reset_status_on_container_repositories_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe QueueResetStatusOnContainerRepositories, feature_category: :container_registry do - let_it_be(:batched_migration) { described_class::MIGRATION } + let!(:batched_migration) { described_class::MIGRATION } before do stub_container_registry_config( diff --git a/spec/migrations/add_okr_hierarchy_restrictions_spec.rb b/spec/migrations/add_okr_hierarchy_restrictions_spec.rb index 9923795925d..ace581c7e3c 100644 --- a/spec/migrations/add_okr_hierarchy_restrictions_spec.rb +++ b/spec/migrations/add_okr_hierarchy_restrictions_spec.rb @@ -6,8 +6,8 @@ require_migration! RSpec.describe AddOkrHierarchyRestrictions, :migration, feature_category: :portfolio_management do include MigrationHelpers::WorkItemTypesHelper - let_it_be(:restrictions) { table(:work_item_hierarchy_restrictions) } - let_it_be(:work_item_types) { table(:work_item_types) } + let!(:restrictions) { table(:work_item_hierarchy_restrictions) } + let!(:work_item_types) { table(:work_item_types) } it 'creates default restrictions' do restrictions.delete_all diff --git a/spec/migrations/add_web_hook_calls_to_plan_limits_paid_tiers_spec.rb b/spec/migrations/add_web_hook_calls_to_plan_limits_paid_tiers_spec.rb index 63ad9367503..90d8c91c047 100644 --- a/spec/migrations/add_web_hook_calls_to_plan_limits_paid_tiers_spec.rb +++ b/spec/migrations/add_web_hook_calls_to_plan_limits_paid_tiers_spec.rb @@ -4,8 +4,8 @@ require 'spec_helper' require_migration! RSpec.describe AddWebHookCallsToPlanLimitsPaidTiers do - let_it_be(:plans) { table(:plans) } - let_it_be(:plan_limits) { table(:plan_limits) } + let!(:plans) { table(:plans) } + let!(:plan_limits) { table(:plan_limits) } context 'when on Gitlab.com' do let(:free_plan) { plans.create!(name: 'free') } diff --git a/spec/migrations/backfill_all_project_namespaces_spec.rb b/spec/migrations/backfill_all_project_namespaces_spec.rb index 1bcaad783b2..bc968ee905e 100644 --- a/spec/migrations/backfill_all_project_namespaces_spec.rb +++ b/spec/migrations/backfill_all_project_namespaces_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe BackfillAllProjectNamespaces, :migration do - let_it_be(:migration) { described_class::MIGRATION } + let!(:migration) { described_class::MIGRATION } let(:projects) { table(:projects) } let(:namespaces) { table(:namespaces) } diff --git a/spec/migrations/backfill_escalation_policies_for_oncall_schedules_spec.rb b/spec/migrations/backfill_escalation_policies_for_oncall_schedules_spec.rb index 87855285203..413e88d633d 100644 --- a/spec/migrations/backfill_escalation_policies_for_oncall_schedules_spec.rb +++ b/spec/migrations/backfill_escalation_policies_for_oncall_schedules_spec.rb @@ -4,47 +4,47 @@ require 'spec_helper' require_migration! RSpec.describe BackfillEscalationPoliciesForOncallSchedules do - let_it_be(:projects) { table(:projects) } - let_it_be(:schedules) { table(:incident_management_oncall_schedules) } - let_it_be(:policies) { table(:incident_management_escalation_policies) } - let_it_be(:rules) { table(:incident_management_escalation_rules) } + let!(:projects) { table(:projects) } + let!(:schedules) { table(:incident_management_oncall_schedules) } + let!(:policies) { table(:incident_management_escalation_policies) } + let!(:rules) { table(:incident_management_escalation_rules) } # Project with no schedules - let_it_be(:namespace) { table(:namespaces).create!(name: 'gitlab', path: 'gitlab') } - let_it_be(:project_a) { projects.create!(namespace_id: namespace.id) } + let!(:namespace) { table(:namespaces).create!(name: 'gitlab', path: 'gitlab') } + let!(:project_a) { projects.create!(namespace_id: namespace.id) } context 'with backfill-able schedules' do # Project with one schedule - let_it_be(:project_b) { projects.create!(namespace_id: namespace.id) } - let_it_be(:schedule_b1) { schedules.create!(project_id: project_b.id, iid: 1, name: 'Schedule B1') } + let!(:project_b) { projects.create!(namespace_id: namespace.id) } + let!(:schedule_b1) { schedules.create!(project_id: project_b.id, iid: 1, name: 'Schedule B1') } # Project with multiple schedules - let_it_be(:project_c) { projects.create!(namespace_id: namespace.id) } - let_it_be(:schedule_c1) { schedules.create!(project_id: project_c.id, iid: 1, name: 'Schedule C1') } - let_it_be(:schedule_c2) { schedules.create!(project_id: project_c.id, iid: 2, name: 'Schedule C2') } + let!(:project_c) { projects.create!(namespace_id: namespace.id) } + let!(:schedule_c1) { schedules.create!(project_id: project_c.id, iid: 1, name: 'Schedule C1') } + let!(:schedule_c2) { schedules.create!(project_id: project_c.id, iid: 2, name: 'Schedule C2') } # Project with a single schedule which already has a policy - let_it_be(:project_d) { projects.create!(namespace_id: namespace.id) } - let_it_be(:schedule_d1) { schedules.create!(project_id: project_d.id, iid: 1, name: 'Schedule D1') } - let_it_be(:policy_d1) { policies.create!(project_id: project_d.id, name: 'Policy D1') } - let_it_be(:rule_d1) { rules.create!(policy_id: policy_d1.id, oncall_schedule_id: schedule_d1.id, status: 2, elapsed_time_seconds: 60) } + let!(:project_d) { projects.create!(namespace_id: namespace.id) } + let!(:schedule_d1) { schedules.create!(project_id: project_d.id, iid: 1, name: 'Schedule D1') } + let!(:policy_d1) { policies.create!(project_id: project_d.id, name: 'Policy D1') } + let!(:rule_d1) { rules.create!(policy_id: policy_d1.id, oncall_schedule_id: schedule_d1.id, status: 2, elapsed_time_seconds: 60) } # Project with a multiple schedule, one of which already has a policy - let_it_be(:project_e) { projects.create!(namespace_id: namespace.id) } - let_it_be(:schedule_e1) { schedules.create!(project_id: project_e.id, iid: 1, name: 'Schedule E1') } - let_it_be(:schedule_e2) { schedules.create!(project_id: project_e.id, iid: 2, name: 'Schedule E2') } - let_it_be(:policy_e1) { policies.create!(project_id: project_e.id, name: 'Policy E1') } - let_it_be(:rule_e1) { rules.create!(policy_id: policy_e1.id, oncall_schedule_id: schedule_e2.id, status: 2, elapsed_time_seconds: 60) } + let!(:project_e) { projects.create!(namespace_id: namespace.id) } + let!(:schedule_e1) { schedules.create!(project_id: project_e.id, iid: 1, name: 'Schedule E1') } + let!(:schedule_e2) { schedules.create!(project_id: project_e.id, iid: 2, name: 'Schedule E2') } + let!(:policy_e1) { policies.create!(project_id: project_e.id, name: 'Policy E1') } + let!(:rule_e1) { rules.create!(policy_id: policy_e1.id, oncall_schedule_id: schedule_e2.id, status: 2, elapsed_time_seconds: 60) } # Project with a multiple schedule, with multiple policies - let_it_be(:project_f) { projects.create!(namespace_id: namespace.id) } - let_it_be(:schedule_f1) { schedules.create!(project_id: project_f.id, iid: 1, name: 'Schedule F1') } - let_it_be(:schedule_f2) { schedules.create!(project_id: project_f.id, iid: 2, name: 'Schedule F2') } - let_it_be(:policy_f1) { policies.create!(project_id: project_f.id, name: 'Policy F1') } - let_it_be(:rule_f1) { rules.create!(policy_id: policy_f1.id, oncall_schedule_id: schedule_f1.id, status: 2, elapsed_time_seconds: 60) } - let_it_be(:rule_f2) { rules.create!(policy_id: policy_f1.id, oncall_schedule_id: schedule_f2.id, status: 2, elapsed_time_seconds: 60) } - let_it_be(:policy_f2) { policies.create!(project_id: project_f.id, name: 'Policy F2') } - let_it_be(:rule_f3) { rules.create!(policy_id: policy_f2.id, oncall_schedule_id: schedule_f2.id, status: 1, elapsed_time_seconds: 10) } + let!(:project_f) { projects.create!(namespace_id: namespace.id) } + let!(:schedule_f1) { schedules.create!(project_id: project_f.id, iid: 1, name: 'Schedule F1') } + let!(:schedule_f2) { schedules.create!(project_id: project_f.id, iid: 2, name: 'Schedule F2') } + let!(:policy_f1) { policies.create!(project_id: project_f.id, name: 'Policy F1') } + let!(:rule_f1) { rules.create!(policy_id: policy_f1.id, oncall_schedule_id: schedule_f1.id, status: 2, elapsed_time_seconds: 60) } + let!(:rule_f2) { rules.create!(policy_id: policy_f1.id, oncall_schedule_id: schedule_f2.id, status: 2, elapsed_time_seconds: 60) } + let!(:policy_f2) { policies.create!(project_id: project_f.id, name: 'Policy F2') } + let!(:rule_f3) { rules.create!(policy_id: policy_f2.id, oncall_schedule_id: schedule_f2.id, status: 1, elapsed_time_seconds: 10) } it 'backfills escalation policies correctly' do expect { migrate! } diff --git a/spec/migrations/backfill_integrations_enable_ssl_verification_spec.rb b/spec/migrations/backfill_integrations_enable_ssl_verification_spec.rb index 28578a3d79a..84e58227f07 100644 --- a/spec/migrations/backfill_integrations_enable_ssl_verification_spec.rb +++ b/spec/migrations/backfill_integrations_enable_ssl_verification_spec.rb @@ -4,8 +4,8 @@ require 'spec_helper' require_migration! RSpec.describe BackfillIntegrationsEnableSslVerification do - let_it_be(:migration) { described_class::MIGRATION } - let_it_be(:integrations) { described_class::Integration } + let!(:migration) { described_class::MIGRATION } + let!(:integrations) { described_class::Integration } before do stub_const("#{described_class.name}::BATCH_SIZE", 2) diff --git a/spec/migrations/backfill_integrations_type_new_spec.rb b/spec/migrations/backfill_integrations_type_new_spec.rb index 5b8fbf6f555..1614fd74b1c 100644 --- a/spec/migrations/backfill_integrations_type_new_spec.rb +++ b/spec/migrations/backfill_integrations_type_new_spec.rb @@ -4,8 +4,8 @@ require 'spec_helper' require_migration! RSpec.describe BackfillIntegrationsTypeNew do - let_it_be(:migration) { described_class::MIGRATION } - let_it_be(:integrations) { table(:integrations) } + let!(:migration) { described_class::MIGRATION } + let!(:integrations) { table(:integrations) } before do integrations.create!(id: 1) diff --git a/spec/migrations/backfill_member_namespace_id_for_group_members_spec.rb b/spec/migrations/backfill_member_namespace_id_for_group_members_spec.rb index 0c0acf85d41..c583d82e4ac 100644 --- a/spec/migrations/backfill_member_namespace_id_for_group_members_spec.rb +++ b/spec/migrations/backfill_member_namespace_id_for_group_members_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe BackfillMemberNamespaceIdForGroupMembers do - let_it_be(:migration) { described_class::MIGRATION } + let!(:migration) { described_class::MIGRATION } describe '#up' do it 'schedules background jobs for each batch of group members' do diff --git a/spec/migrations/backfill_namespace_id_for_namespace_routes_spec.rb b/spec/migrations/backfill_namespace_id_for_namespace_routes_spec.rb index 913ec404795..e2d799bcac5 100644 --- a/spec/migrations/backfill_namespace_id_for_namespace_routes_spec.rb +++ b/spec/migrations/backfill_namespace_id_for_namespace_routes_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe BackfillNamespaceIdForNamespaceRoutes do - let_it_be(:migration) { described_class::MIGRATION } + let!(:migration) { described_class::MIGRATION } describe '#up' do it 'schedules background jobs for each batch of routes' do diff --git a/spec/migrations/backfill_project_import_level_spec.rb b/spec/migrations/backfill_project_import_level_spec.rb index c24ddac0730..2e78e205a13 100644 --- a/spec/migrations/backfill_project_import_level_spec.rb +++ b/spec/migrations/backfill_project_import_level_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe BackfillProjectImportLevel do - let_it_be(:batched_migration) { described_class::MIGRATION } + let!(:batched_migration) { described_class::MIGRATION } describe '#up' do it 'schedules background jobs for each batch of namespaces' do diff --git a/spec/migrations/backfill_project_namespaces_for_group_spec.rb b/spec/migrations/backfill_project_namespaces_for_group_spec.rb index 0d34d19d42a..c039e8e0a58 100644 --- a/spec/migrations/backfill_project_namespaces_for_group_spec.rb +++ b/spec/migrations/backfill_project_namespaces_for_group_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe BackfillProjectNamespacesForGroup do - let_it_be(:migration) { described_class::MIGRATION } + let!(:migration) { described_class::MIGRATION } let(:projects) { table(:projects) } let(:namespaces) { table(:namespaces) } diff --git a/spec/migrations/backfill_user_namespace_spec.rb b/spec/migrations/backfill_user_namespace_spec.rb index 094aec82e9c..2f1fce78373 100644 --- a/spec/migrations/backfill_user_namespace_spec.rb +++ b/spec/migrations/backfill_user_namespace_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe BackfillUserNamespace do - let_it_be(:migration) { described_class::MIGRATION } + let!(:migration) { described_class::MIGRATION } describe '#up' do it 'schedules background jobs for each batch of namespaces' do diff --git a/spec/migrations/cleanup_vulnerability_state_transitions_with_same_from_state_to_state_spec.rb b/spec/migrations/cleanup_vulnerability_state_transitions_with_same_from_state_to_state_spec.rb index 92ece81ffc8..d91f69d68ad 100644 --- a/spec/migrations/cleanup_vulnerability_state_transitions_with_same_from_state_to_state_spec.rb +++ b/spec/migrations/cleanup_vulnerability_state_transitions_with_same_from_state_to_state_spec.rb @@ -4,9 +4,9 @@ require 'spec_helper' require_migration! RSpec.describe CleanupVulnerabilityStateTransitionsWithSameFromStateToState, :migration do - let_it_be(:namespace) { table(:namespaces).create!(name: 'namespace', type: 'Group', path: 'namespace') } - let_it_be(:user) { table(:users).create!(email: 'author@example.com', username: 'author', projects_limit: 10) } - let_it_be(:project) do + let!(:namespace) { table(:namespaces).create!(name: 'namespace', type: 'Group', path: 'namespace') } + let!(:user) { table(:users).create!(email: 'author@example.com', username: 'author', projects_limit: 10) } + let!(:project) do table(:projects).create!( path: 'project', namespace_id: namespace.id, @@ -14,7 +14,7 @@ RSpec.describe CleanupVulnerabilityStateTransitionsWithSameFromStateToState, :mi ) end - let_it_be(:vulnerability) do + let!(:vulnerability) do table(:vulnerabilities).create!( project_id: project.id, author_id: user.id, @@ -25,7 +25,7 @@ RSpec.describe CleanupVulnerabilityStateTransitionsWithSameFromStateToState, :mi ) end - let_it_be(:state_transitions) { table(:vulnerability_state_transitions) } + let!(:state_transitions) { table(:vulnerability_state_transitions) } let!(:state_transition_with_no_state_change) do state_transitions.create!( diff --git a/spec/migrations/finalize_invalid_member_cleanup_spec.rb b/spec/migrations/finalize_invalid_member_cleanup_spec.rb index a29a89c2396..2362ee7095f 100644 --- a/spec/migrations/finalize_invalid_member_cleanup_spec.rb +++ b/spec/migrations/finalize_invalid_member_cleanup_spec.rb @@ -6,7 +6,7 @@ require_migration! RSpec.describe FinalizeInvalidMemberCleanup, :migration do let(:batched_migrations) { table(:batched_background_migrations) } - let_it_be(:migration) { described_class::MIGRATION } + let!(:migration) { described_class::MIGRATION } describe '#up' do shared_examples 'finalizes the migration' do diff --git a/spec/migrations/finalize_orphaned_routes_cleanup_spec.rb b/spec/migrations/finalize_orphaned_routes_cleanup_spec.rb index dfc95ed9e63..bb08a08b2ee 100644 --- a/spec/migrations/finalize_orphaned_routes_cleanup_spec.rb +++ b/spec/migrations/finalize_orphaned_routes_cleanup_spec.rb @@ -6,7 +6,7 @@ require_migration! RSpec.describe FinalizeOrphanedRoutesCleanup, :migration do let(:batched_migrations) { table(:batched_background_migrations) } - let_it_be(:migration) { described_class::MIGRATION } + let!(:migration) { described_class::MIGRATION } describe '#up' do shared_examples 'finalizes the migration' do diff --git a/spec/migrations/finalize_project_namespaces_backfill_spec.rb b/spec/migrations/finalize_project_namespaces_backfill_spec.rb index 56f3b0f6ba5..cbd0c19f482 100644 --- a/spec/migrations/finalize_project_namespaces_backfill_spec.rb +++ b/spec/migrations/finalize_project_namespaces_backfill_spec.rb @@ -6,7 +6,7 @@ require_migration! RSpec.describe FinalizeProjectNamespacesBackfill, :migration do let(:batched_migrations) { table(:batched_background_migrations) } - let_it_be(:migration) { described_class::MIGRATION } + let!(:migration) { described_class::MIGRATION } describe '#up' do shared_examples 'finalizes the migration' do diff --git a/spec/migrations/finalize_routes_backfilling_for_projects_spec.rb b/spec/migrations/finalize_routes_backfilling_for_projects_spec.rb index 2bb740d0c2f..192cceb41d2 100644 --- a/spec/migrations/finalize_routes_backfilling_for_projects_spec.rb +++ b/spec/migrations/finalize_routes_backfilling_for_projects_spec.rb @@ -6,7 +6,7 @@ require_migration! RSpec.describe FinalizeRoutesBackfillingForProjects, :migration do let(:batched_migrations) { table(:batched_background_migrations) } - let_it_be(:migration) { described_class::MIGRATION } + let!(:migration) { described_class::MIGRATION } describe '#up' do shared_examples 'finalizes the migration' do diff --git a/spec/migrations/insert_ci_daily_pipeline_schedule_triggers_plan_limits_spec.rb b/spec/migrations/insert_ci_daily_pipeline_schedule_triggers_plan_limits_spec.rb index 1b6cb6a86a0..028e230af3e 100644 --- a/spec/migrations/insert_ci_daily_pipeline_schedule_triggers_plan_limits_spec.rb +++ b/spec/migrations/insert_ci_daily_pipeline_schedule_triggers_plan_limits_spec.rb @@ -4,8 +4,8 @@ require 'spec_helper' require_migration! RSpec.describe InsertCiDailyPipelineScheduleTriggersPlanLimits do - let_it_be(:plans) { table(:plans) } - let_it_be(:plan_limits) { table(:plan_limits) } + let!(:plans) { table(:plans) } + let!(:plan_limits) { table(:plan_limits) } context 'when on Gitlab.com' do let(:free_plan) { plans.create!(name: 'free') } diff --git a/spec/migrations/queue_backfill_project_feature_package_registry_access_level_spec.rb b/spec/migrations/queue_backfill_project_feature_package_registry_access_level_spec.rb index 487d94b82a1..d0223bf4f9d 100644 --- a/spec/migrations/queue_backfill_project_feature_package_registry_access_level_spec.rb +++ b/spec/migrations/queue_backfill_project_feature_package_registry_access_level_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe QueueBackfillProjectFeaturePackageRegistryAccessLevel do - let_it_be(:batched_migration) { described_class::MIGRATION } + let!(:batched_migration) { described_class::MIGRATION } it 'schedules a new batched migration' do reversible_migration do |migration| diff --git a/spec/migrations/queue_backfill_user_details_fields_spec.rb b/spec/migrations/queue_backfill_user_details_fields_spec.rb index 388ac6d1bce..d379318c368 100644 --- a/spec/migrations/queue_backfill_user_details_fields_spec.rb +++ b/spec/migrations/queue_backfill_user_details_fields_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe QueueBackfillUserDetailsFields do - let_it_be(:batched_migration) { described_class::MIGRATION } + let!(:batched_migration) { described_class::MIGRATION } it 'schedules a new batched migration' do reversible_migration do |migration| diff --git a/spec/migrations/queue_populate_projects_star_count_spec.rb b/spec/migrations/queue_populate_projects_star_count_spec.rb index 848136d8005..2897ba69a33 100644 --- a/spec/migrations/queue_populate_projects_star_count_spec.rb +++ b/spec/migrations/queue_populate_projects_star_count_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe QueuePopulateProjectsStarCount do - let_it_be(:batched_migration) { described_class::MIGRATION } + let!(:batched_migration) { described_class::MIGRATION } it 'schedules a new batched migration' do reversible_migration do |migration| diff --git a/spec/migrations/remove_duplicate_dast_site_tokens_spec.rb b/spec/migrations/remove_duplicate_dast_site_tokens_spec.rb index fed9941b2a4..a37a2ab964c 100644 --- a/spec/migrations/remove_duplicate_dast_site_tokens_spec.rb +++ b/spec/migrations/remove_duplicate_dast_site_tokens_spec.rb @@ -15,7 +15,7 @@ RSpec.describe RemoveDuplicateDastSiteTokens do context 'when duplicate dast site tokens exists' do # create duplicate dast site token - let_it_be(:duplicate_url) { 'https://about.gitlab.com' } + let!(:duplicate_url) { 'https://about.gitlab.com' } let!(:project2) { projects.create!(id: 2, namespace_id: namespace.id, path: 'project2') } let!(:dast_site_token2) { dast_site_tokens.create!(project_id: project2.id, url: duplicate_url, token: SecureRandom.uuid) } diff --git a/spec/migrations/remove_duplicate_dast_site_tokens_with_same_token_spec.rb b/spec/migrations/remove_duplicate_dast_site_tokens_with_same_token_spec.rb index 57d677af5cf..6f860558dd7 100644 --- a/spec/migrations/remove_duplicate_dast_site_tokens_with_same_token_spec.rb +++ b/spec/migrations/remove_duplicate_dast_site_tokens_with_same_token_spec.rb @@ -15,8 +15,8 @@ RSpec.describe RemoveDuplicateDastSiteTokensWithSameToken do context 'when duplicate dast site tokens exists' do # create duplicate dast site token - let_it_be(:duplicate_token) { 'duplicate_token' } - let_it_be(:other_duplicate_token) { 'other_duplicate_token' } + let!(:duplicate_token) { 'duplicate_token' } + let!(:other_duplicate_token) { 'other_duplicate_token' } let!(:project2) { projects.create!(id: 2, namespace_id: namespace.id, path: 'project2') } let!(:dast_site_token2) { dast_site_tokens.create!(project_id: project2.id, url: 'https://gitlab2.com', token: duplicate_token) } diff --git a/spec/migrations/reschedule_backfill_imported_issue_search_data_spec.rb b/spec/migrations/reschedule_backfill_imported_issue_search_data_spec.rb index 8d4a559b45f..a59ddec20c4 100644 --- a/spec/migrations/reschedule_backfill_imported_issue_search_data_spec.rb +++ b/spec/migrations/reschedule_backfill_imported_issue_search_data_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe RescheduleBackfillImportedIssueSearchData do - let_it_be(:reschedule_migration) { described_class::MIGRATION } + let!(:reschedule_migration) { described_class::MIGRATION } def create_batched_migration(max_value:) Gitlab::Database::BackgroundMigration::BatchedMigration @@ -55,8 +55,8 @@ RSpec.describe RescheduleBackfillImportedIssueSearchData do end context 'when an issue is available' do - let_it_be(:namespaces_table) { table(:namespaces) } - let_it_be(:projects_table) { table(:projects) } + let!(:namespaces_table) { table(:namespaces) } + let!(:projects_table) { table(:projects) } let(:namespace) { namespaces_table.create!(name: 'gitlab-org', path: 'gitlab-org') } diff --git a/spec/migrations/reschedule_issue_work_item_type_id_backfill_spec.rb b/spec/migrations/reschedule_issue_work_item_type_id_backfill_spec.rb index 126d49790a5..105144cbe5b 100644 --- a/spec/migrations/reschedule_issue_work_item_type_id_backfill_spec.rb +++ b/spec/migrations/reschedule_issue_work_item_type_id_backfill_spec.rb @@ -4,10 +4,10 @@ require 'spec_helper' require_migration! RSpec.describe RescheduleIssueWorkItemTypeIdBackfill, :migration do - let_it_be(:migration) { described_class::MIGRATION } - let_it_be(:interval) { 2.minutes } - let_it_be(:issue_type_enum) { { issue: 0, incident: 1, test_case: 2, requirement: 3, task: 4 } } - let_it_be(:base_work_item_type_ids) do + let!(:migration) { described_class::MIGRATION } + let!(:interval) { 2.minutes } + let!(:issue_type_enum) { { issue: 0, incident: 1, test_case: 2, requirement: 3, task: 4 } } + let!(:base_work_item_type_ids) do table(:work_item_types).where(namespace_id: nil).order(:base_type).each_with_object({}) do |type, hash| hash[type.base_type] = type.id end diff --git a/spec/migrations/retry_backfill_traversal_ids_spec.rb b/spec/migrations/retry_backfill_traversal_ids_spec.rb index 910be9f2c69..4c93fea65cb 100644 --- a/spec/migrations/retry_backfill_traversal_ids_spec.rb +++ b/spec/migrations/retry_backfill_traversal_ids_spec.rb @@ -6,7 +6,7 @@ require_migration! RSpec.describe RetryBackfillTraversalIds, :migration do include ReloadHelpers - let_it_be(:namespaces_table) { table(:namespaces) } + let!(:namespaces_table) { table(:namespaces) } context 'when BackfillNamespaceTraversalIdsRoots jobs are pending' do before do diff --git a/spec/migrations/schedule_backfill_cluster_agents_has_vulnerabilities_spec.rb b/spec/migrations/schedule_backfill_cluster_agents_has_vulnerabilities_spec.rb index 675cc332e69..bcedc890d4f 100644 --- a/spec/migrations/schedule_backfill_cluster_agents_has_vulnerabilities_spec.rb +++ b/spec/migrations/schedule_backfill_cluster_agents_has_vulnerabilities_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require_migration! RSpec.describe ScheduleBackfillClusterAgentsHasVulnerabilities do - let_it_be(:batched_migration) { described_class::MIGRATION } + let!(:batched_migration) { described_class::MIGRATION } it 'schedules background jobs for each batch of cluster agents' do reversible_migration do |migration| diff --git a/spec/migrations/schedule_backfilling_the_namespace_id_for_vulnerability_reads_spec.rb b/spec/migrations/schedule_backfilling_the_namespace_id_for_vulnerability_reads_spec.rb index e03096de98d..a3478729b89 100644 --- a/spec/migrations/schedule_backfilling_the_namespace_id_for_vulnerability_reads_spec.rb +++ b/spec/migrations/schedule_backfilling_the_namespace_id_for_vulnerability_reads_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' require_migration! RSpec.describe ScheduleBackfillingTheNamespaceIdForVulnerabilityReads do - let_it_be(:migration) { described_class::MIGRATION_NAME } + let!(:migration) { described_class::MIGRATION_NAME } describe '#up' do it 'schedules background jobs for each batch of vulnerabilities' do diff --git a/spec/migrations/schedule_disable_expiration_policies_linked_to_no_container_images_spec.rb b/spec/migrations/schedule_disable_expiration_policies_linked_to_no_container_images_spec.rb index 888d306f893..1032c2c3d68 100644 --- a/spec/migrations/schedule_disable_expiration_policies_linked_to_no_container_images_spec.rb +++ b/spec/migrations/schedule_disable_expiration_policies_linked_to_no_container_images_spec.rb @@ -5,21 +5,21 @@ require 'spec_helper' require_migration! RSpec.describe ScheduleDisableExpirationPoliciesLinkedToNoContainerImages do - let_it_be(:projects) { table(:projects) } - let_it_be(:container_expiration_policies) { table(:container_expiration_policies) } - let_it_be(:container_repositories) { table(:container_repositories) } - let_it_be(:namespaces) { table(:namespaces) } - let_it_be(:namespace) { namespaces.create!(name: 'test', path: 'test') } - - let_it_be(:policy1) { create_expiration_policy(id: 1, enabled: true) } - let_it_be(:policy2) { create_expiration_policy(id: 2, enabled: false) } - let_it_be(:policy3) { create_expiration_policy(id: 3, enabled: false) } - let_it_be(:policy4) { create_expiration_policy(id: 4, enabled: true) } - let_it_be(:policy5) { create_expiration_policy(id: 5, enabled: false) } - let_it_be(:policy6) { create_expiration_policy(id: 6, enabled: false) } - let_it_be(:policy7) { create_expiration_policy(id: 7, enabled: true) } - let_it_be(:policy8) { create_expiration_policy(id: 8, enabled: true) } - let_it_be(:policy9) { create_expiration_policy(id: 9, enabled: true) } + let!(:projects) { table(:projects) } + let!(:container_expiration_policies) { table(:container_expiration_policies) } + let!(:container_repositories) { table(:container_repositories) } + let!(:namespaces) { table(:namespaces) } + let!(:namespace) { namespaces.create!(name: 'test', path: 'test') } + + let!(:policy1) { create_expiration_policy(id: 1, enabled: true) } + let!(:policy2) { create_expiration_policy(id: 2, enabled: false) } + let!(:policy3) { create_expiration_policy(id: 3, enabled: false) } + let!(:policy4) { create_expiration_policy(id: 4, enabled: true) } + let!(:policy5) { create_expiration_policy(id: 5, enabled: false) } + let!(:policy6) { create_expiration_policy(id: 6, enabled: false) } + let!(:policy7) { create_expiration_policy(id: 7, enabled: true) } + let!(:policy8) { create_expiration_policy(id: 8, enabled: true) } + let!(:policy9) { create_expiration_policy(id: 9, enabled: true) } it 'schedules background migrations', :aggregate_failures do stub_const("#{described_class}::BATCH_SIZE", 2) diff --git a/spec/migrations/schedule_purging_stale_security_scans_spec.rb b/spec/migrations/schedule_purging_stale_security_scans_spec.rb index b5a38634b58..d8a729783f1 100644 --- a/spec/migrations/schedule_purging_stale_security_scans_spec.rb +++ b/spec/migrations/schedule_purging_stale_security_scans_spec.rb @@ -3,17 +3,17 @@ require 'spec_helper' require_migration! -RSpec.describe SchedulePurgingStaleSecurityScans do - let_it_be(:namespaces) { table(:namespaces) } - let_it_be(:projects) { table(:projects) } - let_it_be(:pipelines) { table(:ci_pipelines) } - let_it_be(:builds) { table(:ci_builds) } - let_it_be(:security_scans) { table(:security_scans) } - - let_it_be(:namespace) { namespaces.create!(name: "foo", path: "bar") } - let_it_be(:project) { projects.create!(namespace_id: namespace.id, project_namespace_id: namespace.id) } - let_it_be(:pipeline) { pipelines.create!(project_id: project.id, ref: 'master', sha: 'adf43c3a', status: 'success') } - let_it_be(:ci_build) { builds.create!(commit_id: pipeline.id, retried: false, type: 'Ci::Build') } +RSpec.describe SchedulePurgingStaleSecurityScans, :suppress_gitlab_schemas_validate_connection do + let!(:namespaces) { table(:namespaces) } + let!(:projects) { table(:projects) } + let!(:pipelines) { table(:ci_pipelines) } + let!(:builds) { table(:ci_builds) } + let!(:security_scans) { table(:security_scans) } + + let!(:namespace) { namespaces.create!(name: "foo", path: "bar") } + let!(:project) { projects.create!(namespace_id: namespace.id, project_namespace_id: namespace.id) } + let!(:pipeline) { pipelines.create!(project_id: project.id, ref: 'master', sha: 'adf43c3a', status: 'success') } + let!(:ci_build) { builds.create!(commit_id: pipeline.id, retried: false, type: 'Ci::Build') } let!(:security_scan_1) { security_scans.create!(build_id: ci_build.id, scan_type: 1, created_at: 92.days.ago) } let!(:security_scan_2) { security_scans.create!(build_id: ci_build.id, scan_type: 2, created_at: 91.days.ago) } diff --git a/spec/migrations/schedule_recalculate_vulnerability_finding_signatures_for_findings_spec.rb b/spec/migrations/schedule_recalculate_vulnerability_finding_signatures_for_findings_spec.rb index 9b62dd79e08..9eb09e0215a 100644 --- a/spec/migrations/schedule_recalculate_vulnerability_finding_signatures_for_findings_spec.rb +++ b/spec/migrations/schedule_recalculate_vulnerability_finding_signatures_for_findings_spec.rb @@ -20,21 +20,21 @@ RSpec.describe ScheduleRecalculateVulnerabilityFindingSignaturesForFindings, :mi context 'when the Gitlab instance is EE' do let(:ee?) { true } - let_it_be(:namespaces) { table(:namespaces) } - let_it_be(:projects) { table(:projects) } - let_it_be(:findings) { table(:vulnerability_occurrences) } - let_it_be(:scanners) { table(:vulnerability_scanners) } - let_it_be(:identifiers) { table(:vulnerability_identifiers) } - let_it_be(:vulnerability_finding_signatures) { table(:vulnerability_finding_signatures) } + let!(:namespaces) { table(:namespaces) } + let!(:projects) { table(:projects) } + let!(:findings) { table(:vulnerability_occurrences) } + let!(:scanners) { table(:vulnerability_scanners) } + let!(:identifiers) { table(:vulnerability_identifiers) } + let!(:vulnerability_finding_signatures) { table(:vulnerability_finding_signatures) } - let_it_be(:namespace) { namespaces.create!(name: 'test', path: 'test') } - let_it_be(:project) { projects.create!(namespace_id: namespace.id, name: 'gitlab', path: 'gitlab') } + let!(:namespace) { namespaces.create!(name: 'test', path: 'test') } + let!(:project) { projects.create!(namespace_id: namespace.id, name: 'gitlab', path: 'gitlab') } - let_it_be(:scanner) do + let!(:scanner) do scanners.create!(project_id: project.id, external_id: 'trivy', name: 'Security Scanner') end - let_it_be(:identifier) do + let!(:identifier) do identifiers.create!(project_id: project.id, fingerprint: 'd432c2ad2953e8bd587a3a43b3ce309b5b0154c123', external_type: 'SECURITY_ID', @@ -42,14 +42,14 @@ RSpec.describe ScheduleRecalculateVulnerabilityFindingSignaturesForFindings, :mi name: 'SECURITY_IDENTIFIER 0') end - let_it_be(:finding1) { findings.create!(finding_params) } - let_it_be(:signature1) { vulnerability_finding_signatures.create!(finding_id: finding1.id, algorithm_type: 0, signature_sha: ::Digest::SHA1.digest(SecureRandom.hex(50))) } + let!(:finding1) { findings.create!(finding_params) } + let!(:signature1) { vulnerability_finding_signatures.create!(finding_id: finding1.id, algorithm_type: 0, signature_sha: ::Digest::SHA1.digest(SecureRandom.hex(50))) } - let_it_be(:finding2) { findings.create!(finding_params) } - let_it_be(:signature2) { vulnerability_finding_signatures.create!(finding_id: finding2.id, algorithm_type: 0, signature_sha: ::Digest::SHA1.digest(SecureRandom.hex(50))) } + let!(:finding2) { findings.create!(finding_params) } + let!(:signature2) { vulnerability_finding_signatures.create!(finding_id: finding2.id, algorithm_type: 0, signature_sha: ::Digest::SHA1.digest(SecureRandom.hex(50))) } - let_it_be(:finding3) { findings.create!(finding_params) } - let_it_be(:signature3) { vulnerability_finding_signatures.create!(finding_id: finding3.id, algorithm_type: 0, signature_sha: ::Digest::SHA1.digest(SecureRandom.hex(50))) } + let!(:finding3) { findings.create!(finding_params) } + let!(:signature3) { vulnerability_finding_signatures.create!(finding_id: finding3.id, algorithm_type: 0, signature_sha: ::Digest::SHA1.digest(SecureRandom.hex(50))) } # this migration is now a no-op it 'does not schedule the background jobs', :aggregate_failure do diff --git a/spec/migrations/schedule_set_correct_vulnerability_state_spec.rb b/spec/migrations/schedule_set_correct_vulnerability_state_spec.rb index 08dccf1f37a..9f2b2cd6b2a 100644 --- a/spec/migrations/schedule_set_correct_vulnerability_state_spec.rb +++ b/spec/migrations/schedule_set_correct_vulnerability_state_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' require_migration! RSpec.describe ScheduleSetCorrectVulnerabilityState do - let_it_be(:migration) { described_class::MIGRATION_NAME } + let!(:migration) { described_class::MIGRATION_NAME } describe '#up' do it 'schedules background jobs for each batch of vulnerabilities' do diff --git a/spec/migrations/schedule_update_timelogs_null_spent_at_spec.rb b/spec/migrations/schedule_update_timelogs_null_spent_at_spec.rb index a81059518e6..8ab2e3179b7 100644 --- a/spec/migrations/schedule_update_timelogs_null_spent_at_spec.rb +++ b/spec/migrations/schedule_update_timelogs_null_spent_at_spec.rb @@ -4,17 +4,17 @@ require 'spec_helper' require_migration! RSpec.describe ScheduleUpdateTimelogsNullSpentAt do - let_it_be(:namespace) { table(:namespaces).create!(name: 'namespace', path: 'namespace') } - let_it_be(:project) { table(:projects).create!(namespace_id: namespace.id) } - let_it_be(:issue) { table(:issues).create!(project_id: project.id) } - let_it_be(:merge_request) { table(:merge_requests).create!(target_project_id: project.id, source_branch: 'master', target_branch: 'feature') } - let_it_be(:timelog1) { create_timelog!(merge_request_id: merge_request.id) } - let_it_be(:timelog2) { create_timelog!(merge_request_id: merge_request.id) } - let_it_be(:timelog3) { create_timelog!(merge_request_id: merge_request.id) } - let_it_be(:timelog4) { create_timelog!(issue_id: issue.id) } - let_it_be(:timelog5) { create_timelog!(issue_id: issue.id) } - - before_all do + let!(:namespace) { table(:namespaces).create!(name: 'namespace', path: 'namespace') } + let!(:project) { table(:projects).create!(namespace_id: namespace.id) } + let!(:issue) { table(:issues).create!(project_id: project.id) } + let!(:merge_request) { table(:merge_requests).create!(target_project_id: project.id, source_branch: 'master', target_branch: 'feature') } + let!(:timelog1) { create_timelog!(merge_request_id: merge_request.id) } + let!(:timelog2) { create_timelog!(merge_request_id: merge_request.id) } + let!(:timelog3) { create_timelog!(merge_request_id: merge_request.id) } + let!(:timelog4) { create_timelog!(issue_id: issue.id) } + let!(:timelog5) { create_timelog!(issue_id: issue.id) } + + before do table(:timelogs).where.not(id: timelog3.id).update_all(spent_at: nil) end diff --git a/spec/migrations/update_application_settings_protected_paths_spec.rb b/spec/migrations/update_application_settings_protected_paths_spec.rb index 21879995f1b..b24eef2fcfc 100644 --- a/spec/migrations/update_application_settings_protected_paths_spec.rb +++ b/spec/migrations/update_application_settings_protected_paths_spec.rb @@ -6,9 +6,9 @@ require_migration! RSpec.describe UpdateApplicationSettingsProtectedPaths, :aggregate_failures do subject(:migration) { described_class.new } - let_it_be(:application_settings) { table(:application_settings) } - let_it_be(:oauth_paths) { %w[/oauth/authorize /oauth/token] } - let_it_be(:custom_paths) { %w[/foo /bar] } + let!(:application_settings) { table(:application_settings) } + let!(:oauth_paths) { %w[/oauth/authorize /oauth/token] } + let!(:custom_paths) { %w[/foo /bar] } let(:default_paths) { application_settings.column_defaults.fetch('protected_paths') } diff --git a/spec/support/before_all_adapter.rb b/spec/support/before_all_adapter.rb index 890bdd6a2c4..f4946ff271f 100644 --- a/spec/support/before_all_adapter.rb +++ b/spec/support/before_all_adapter.rb @@ -1,27 +1,44 @@ # frozen_string_literal: true -class BeforeAllAdapter # rubocop:disable Gitlab/NamespacedClass - def self.all_connection_classes - @all_connection_classes ||= [ActiveRecord::Base] + ActiveRecord::Base.descendants.select(&:connection_class?) # rubocop: disable Database/MultipleDatabases - end - - def self.begin_transaction - self.all_connection_classes.each do |connection_class| - connection_class.connection.begin_transaction(joinable: false) +module TestProfBeforeAllAdapter + module MultipleDatabaseAdapter + def self.all_connection_classes + @all_connection_classes ||= [ActiveRecord::Base] + ActiveRecord::Base.descendants.select(&:connection_class?) # rubocop: disable Database/MultipleDatabases end - end - def self.rollback_transaction - self.all_connection_classes.each do |connection_class| - if connection_class.connection.open_transactions.zero? - warn "!!! before_all transaction has been already rollbacked and " \ - "could work incorrectly" - next + def self.begin_transaction + self.all_connection_classes.each do |connection_class| + connection_class.connection.begin_transaction(joinable: false) end + end - connection_class.connection.rollback_transaction + def self.rollback_transaction + self.all_connection_classes.each do |connection_class| + if connection_class.connection.open_transactions.zero? + warn "!!! before_all transaction has been already rollbacked and " \ + "could work incorrectly" + next + end + + connection_class.connection.rollback_transaction + end end end + + # This class is required so we can disable transactions on migration specs + module NoTransactionAdapter + def self.begin_transaction; end + + def self.rollback_transaction; end + end + + def self.default_adapter + MultipleDatabaseAdapter + end + + def self.no_transaction_adapter + NoTransactionAdapter + end end -TestProf::BeforeAll.adapter = ::BeforeAllAdapter +TestProf::BeforeAll.adapter = ::TestProfBeforeAllAdapter.default_adapter diff --git a/spec/support/db_cleaner.rb b/spec/support/db_cleaner.rb index 24cdbe04fc2..6c5de61c6de 100644 --- a/spec/support/db_cleaner.rb +++ b/spec/support/db_cleaner.rb @@ -2,7 +2,7 @@ module DbCleaner def all_connection_classes - ::BeforeAllAdapter.all_connection_classes + ::TestProfBeforeAllAdapter::MultipleDatabaseAdapter.all_connection_classes end def delete_from_all_tables!(except: []) diff --git a/spec/support/migration.rb b/spec/support/migration.rb index 4d4a293e9ff..b1e75d9c9e2 100644 --- a/spec/support/migration.rb +++ b/spec/support/migration.rb @@ -20,6 +20,14 @@ RSpec.configure do |config| Gitlab::CurrentSettings.clear_in_memory_application_settings! end + config.prepend_before(:all, :migration) do + TestProf::BeforeAll.adapter = ::TestProfBeforeAllAdapter.no_transaction_adapter + end + + config.append_after(:all, :migration) do + TestProf::BeforeAll.adapter = ::TestProfBeforeAllAdapter.default_adapter + end + config.append_after(:context, :migration) do recreate_databases_and_seed_if_needed || ensure_schema_and_empty_tables end diff --git a/yarn.lock b/yarn.lock index 2a95e1f2a1f..df8c4e54def 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1111,6 +1111,11 @@ resolved "https://registry.yarnpkg.com/@gitlab/favicon-overlay/-/favicon-overlay-2.0.0.tgz#2f32d0b6a4d5b8ac44e2927083d9ab478a78c984" integrity sha512-GNcORxXJ98LVGzOT9dDYKfbheqH6lNgPDD72lyXRnQIH7CjgGyos8i17aSBPq1f4s3zF3PyedFiAR4YEZbva2Q== +"@gitlab/fonts@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@gitlab/fonts/-/fonts-1.0.0.tgz#dceabce78519aeb96682f80afa3f03ec0bb05b4f" + integrity sha512-RKbAxFHB3n2x6cAxM9x2hSvOEhJjiXFfKXEFVERinPefCKgMOG6AkWm54sNUfmm3HVEcFMcHwdaRV/DVwVdykg== + "@gitlab/stylelint-config@4.1.0": version "4.1.0" resolved "https://registry.yarnpkg.com/@gitlab/stylelint-config/-/stylelint-config-4.1.0.tgz#bd431406c8f8725afba353652f08e42c3301a982" |