summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-02 03:09:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-02 03:09:42 +0000
commitf50df1c9ff0a0ac5ab53b22c9a8bb5597418fc1f (patch)
tree5e1447d0e13228d9279e9e136d5cfc514442565e
parent2885d70bd4771266b76a2e87bc06b50d5427c69a (diff)
downloadgitlab-ce-f50df1c9ff0a0ac5ab53b22c9a8bb5597418fc1f.tar.gz
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--.rubocop_manual_todo.yml12
-rw-r--r--app/assets/javascripts/environments/components/confirm_rollback_modal.vue42
-rw-r--r--app/assets/javascripts/environments/components/rollback_modal_manager.vue62
-rw-r--r--app/assets/javascripts/environments/init_confirm_rollback_modal.js16
-rw-r--r--app/assets/javascripts/pages/projects/environments/show/index.js2
-rw-r--r--app/views/projects/deployments/_confirm_rollback_modal.html.haml23
-rw-r--r--app/views/projects/deployments/_rollback.haml3
-rw-r--r--lib/api/rubygem_packages.rb2
-rw-r--r--locale/gitlab.pot12
-rw-r--r--qa/qa.rb4
-rw-r--r--qa/qa/page/project/secure/configuration_form.rb31
-rw-r--r--spec/features/admin/dashboard_spec.rb4
-rw-r--r--spec/frontend/environments/confirm_rollback_modal_spec.js118
-rw-r--r--spec/initializers/lograge_spec.rb2
-rw-r--r--spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb2
-rw-r--r--spec/lib/gitlab/import_export/project/tree_saver_spec.rb2
-rw-r--r--spec/lib/gitlab/pagination/keyset/order_spec.rb2
-rw-r--r--spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb2
-rw-r--r--spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb6
-rw-r--r--spec/models/application_setting_spec.rb2
-rw-r--r--spec/requests/api/statistics_spec.rb2
-rw-r--r--spec/views/projects/deployments/_confirm_rollback_modal_spec.html_spec.rb63
22 files changed, 229 insertions, 185 deletions
diff --git a/.rubocop_manual_todo.yml b/.rubocop_manual_todo.yml
index e9e02761665..b2e0bebee3e 100644
--- a/.rubocop_manual_todo.yml
+++ b/.rubocop_manual_todo.yml
@@ -2499,7 +2499,6 @@ Database/MultipleDatabases:
- 'ee/spec/services/ee/merge_requests/update_service_spec.rb'
- 'lib/backup/database.rb'
- 'lib/after_commit_queue.rb'
- - 'lib/api/rubygem_packages.rb'
- 'lib/backup/manager.rb'
- 'lib/gitlab/current_settings.rb'
- 'lib/gitlab/database/load_balancing/load_balancer.rb'
@@ -2535,29 +2534,20 @@ Database/MultipleDatabases:
- 'lib/gitlab/sherlock/query.rb'
- 'lib/system_check/orphans/repository_check.rb'
- 'spec/db/schema_spec.rb'
- - 'spec/features/admin/dashboard_spec.rb'
- 'spec/initializers/database_config_spec.rb'
- - 'spec/initializers/lograge_spec.rb'
- 'spec/lib/backup/manager_spec.rb'
- 'spec/lib/gitlab/current_settings_spec.rb'
- 'spec/lib/gitlab/database_spec.rb'
- - 'spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb'
- - 'spec/lib/gitlab/import_export/project/tree_saver_spec.rb'
- 'spec/lib/gitlab/metrics/subscribers/active_record_spec.rb'
- - 'spec/lib/gitlab/pagination/keyset/order_spec.rb'
- 'spec/lib/gitlab/profiler_spec.rb'
- - 'spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb'
- - 'spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb'
- 'spec/lib/gitlab/usage_data_metrics_spec.rb'
- 'spec/lib/gitlab/usage_data_queries_spec.rb'
- 'spec/lib/gitlab/usage/metrics/names_suggestions/relation_parsers/constraints_spec.rb'
- 'spec/lib/gitlab/usage/metrics/names_suggestions/relation_parsers/joins_spec.rb'
- 'spec/lib/gitlab/usage/metrics/instrumentations/database_metric_spec.rb'
- 'spec/lib/gitlab/utils/usage_data_spec.rb'
- - 'spec/models/application_setting_spec.rb'
- 'spec/models/project_feature_usage_spec.rb'
- 'spec/models/users_statistics_spec.rb'
- - 'spec/requests/api/statistics_spec.rb'
- 'spec/services/users/activity_service_spec.rb'
- 'spec/support/caching.rb'
- 'spec/support/gitlab/usage/metrics_instrumentation_shared_examples.rb'
@@ -2569,5 +2559,3 @@ Database/MultipleDatabases:
- 'spec/support/helpers/usage_data_helpers.rb'
- 'spec/tasks/gitlab/backup_rake_spec.rb'
- 'spec/tasks/gitlab/db_rake_spec.rb'
- - 'spec/workers/analytics/usage_trends/counter_job_worker_spec.rb'
- - 'spec/workers/users/create_statistics_worker_spec.rb'
diff --git a/app/assets/javascripts/environments/components/confirm_rollback_modal.vue b/app/assets/javascripts/environments/components/confirm_rollback_modal.vue
index 76ad74e04d0..58d9c428030 100644
--- a/app/assets/javascripts/environments/components/confirm_rollback_modal.vue
+++ b/app/assets/javascripts/environments/components/confirm_rollback_modal.vue
@@ -16,12 +16,25 @@ export default {
components: {
GlModal,
},
-
+ model: {
+ prop: 'visible',
+ event: 'change',
+ },
props: {
environment: {
type: Object,
required: true,
},
+ visible: {
+ type: Boolean,
+ required: false,
+ default: false,
+ },
+ hasMultipleCommits: {
+ type: Boolean,
+ required: false,
+ default: true,
+ },
},
computed: {
@@ -36,25 +49,28 @@ export default {
},
commitShortSha() {
- const { last_deployment } = this.environment;
- return this.commitData(last_deployment, 'short_id');
+ if (this.hasMultipleCommits) {
+ const { last_deployment } = this.environment;
+ return this.commitData(last_deployment, 'short_id');
+ }
+
+ return this.environment.commitShortSha;
},
commitUrl() {
- const { last_deployment } = this.environment;
- return this.commitData(last_deployment, 'commit_path');
- },
+ if (this.hasMultipleCommits) {
+ const { last_deployment } = this.environment;
+ return this.commitData(last_deployment, 'commit_path');
+ }
- commitTitle() {
- const { last_deployment } = this.environment;
- return this.commitData(last_deployment, 'title');
+ return this.environment.commitUrl;
},
modalText() {
const linkStart = `<a class="commit-sha mr-0" href="${escape(this.commitUrl)}">`;
const commitId = escape(this.commitShortSha);
const linkEnd = '</a>';
- const name = escape(this.name);
+ const name = escape(this.environment.name);
const body = this.environment.isLastDeployment
? s__(
'Environments|This action will relaunch the job for commit %{linkStart}%{commitId}%{linkEnd}, putting the environment in a previous version. Are you sure you want to continue?',
@@ -82,6 +98,10 @@ export default {
},
methods: {
+ handleChange(event) {
+ this.$emit('change', event);
+ },
+
onOk() {
eventHub.$emit('rollbackEnvironment', this.environment);
},
@@ -99,10 +119,12 @@ export default {
<template>
<gl-modal
:title="modalTitle"
+ :visible="visible"
modal-id="confirm-rollback-modal"
:ok-title="modalActionText"
ok-variant="danger"
@ok="onOk"
+ @change="handleChange"
>
<p v-html="modalText"></p>
</gl-modal>
diff --git a/app/assets/javascripts/environments/components/rollback_modal_manager.vue b/app/assets/javascripts/environments/components/rollback_modal_manager.vue
new file mode 100644
index 00000000000..1cd46016fd2
--- /dev/null
+++ b/app/assets/javascripts/environments/components/rollback_modal_manager.vue
@@ -0,0 +1,62 @@
+<script>
+import { parseBoolean } from '~/lib/utils/common_utils';
+import { redirectTo } from '~/lib/utils/url_utility';
+import eventHub from '../event_hub';
+import ConfirmRollbackModal from './confirm_rollback_modal.vue';
+
+export default {
+ components: {
+ ConfirmRollbackModal,
+ },
+ props: {
+ selector: {
+ type: String,
+ required: true,
+ },
+ },
+ data() {
+ return {
+ environment: null,
+ retryPath: '',
+ visible: false,
+ };
+ },
+ mounted() {
+ eventHub.$on('rollbackEnvironment', () => {
+ redirectTo(this.retryPath);
+ });
+
+ document.querySelectorAll(this.selector).forEach((button) => {
+ button.addEventListener('click', (e) => {
+ e.preventDefault();
+ const {
+ environmentName,
+ commitShortSha,
+ commitUrl,
+ isLastDeployment,
+ retryPath,
+ } = button.dataset;
+
+ this.environment = {
+ name: environmentName,
+ commitShortSha,
+ commitUrl,
+ isLastDeployment: parseBoolean(isLastDeployment),
+ };
+ this.retryPath = retryPath;
+ this.visible = true;
+ });
+ });
+ },
+};
+</script>
+
+<template>
+ <confirm-rollback-modal
+ v-if="environment"
+ v-model="visible"
+ :environment="environment"
+ :has-multiple-commits="false"
+ />
+ <div v-else></div>
+</template>
diff --git a/app/assets/javascripts/environments/init_confirm_rollback_modal.js b/app/assets/javascripts/environments/init_confirm_rollback_modal.js
new file mode 100644
index 00000000000..0161bb6078f
--- /dev/null
+++ b/app/assets/javascripts/environments/init_confirm_rollback_modal.js
@@ -0,0 +1,16 @@
+import Vue from 'vue';
+import RollbackModalManager from './components/rollback_modal_manager.vue';
+
+const mountConfirmRollbackModal = (optionalProps) =>
+ new Vue({
+ render(h) {
+ return h(RollbackModalManager, {
+ props: {
+ selector: '.js-confirm-rollback-modal-button',
+ ...optionalProps,
+ },
+ });
+ },
+ }).$mount();
+
+export default (optionalProps = {}) => mountConfirmRollbackModal(optionalProps);
diff --git a/app/assets/javascripts/pages/projects/environments/show/index.js b/app/assets/javascripts/pages/projects/environments/show/index.js
index cd3a0d62bb6..53e48ad8d86 100644
--- a/app/assets/javascripts/pages/projects/environments/show/index.js
+++ b/app/assets/javascripts/pages/projects/environments/show/index.js
@@ -1,3 +1,5 @@
+import initConfirmRollBackModal from '~/environments/init_confirm_rollback_modal';
import { initHeader } from '~/environments/mount_show';
initHeader();
+initConfirmRollBackModal();
diff --git a/app/views/projects/deployments/_confirm_rollback_modal.html.haml b/app/views/projects/deployments/_confirm_rollback_modal.html.haml
deleted file mode 100644
index 23729d6ebf9..00000000000
--- a/app/views/projects/deployments/_confirm_rollback_modal.html.haml
+++ /dev/null
@@ -1,23 +0,0 @@
-- commit_sha = link_to deployment.short_sha, project_commit_path(@project, deployment.sha), class: "commit-sha has-tooltip", title: h(deployment.commit_title)
-.modal.ws-normal.fade{ tabindex: -1, id: "confirm-rollback-modal-#{deployment.id}" }
- .modal-dialog
- .modal-content
- .modal-header
- %h4.modal-title.d-flex.mw-100
- - if deployment.last?
- = s_("Environments|Re-deploy environment %{environment_name}?") % {environment_name: @environment.name}
- - else
- = s_("Environments|Rollback environment %{environment_name}?") % {environment_name: @environment.name}
- .modal-body
- - if deployment.last?
- %p= s_('Environments|This action will relaunch the job for commit %{commit_id}, putting the environment in a previous version. Are you sure you want to continue?').html_safe % {commit_id: commit_sha}
- - else
- %p
- = s_('Environments|This action will run the job defined by %{environment_name} for commit %{commit_id}, putting the environment in a previous version. You can revert it by re-deploying the latest version of your application. Are you sure you want to continue?').html_safe % {commit_id: commit_sha, environment_name: @environment.name}
- .modal-footer
- = button_tag _('Cancel'), type: 'button', class: 'btn gl-button btn-danger', data: { dismiss: 'modal' }
- = link_to [:retry, @project, deployment.deployable], method: :post, class: 'btn gl-button btn-danger' do
- - if deployment.last?
- = s_('Environments|Re-deploy')
- - else
- = s_('Environments|Rollback')
diff --git a/app/views/projects/deployments/_rollback.haml b/app/views/projects/deployments/_rollback.haml
index 78972a5b7b9..a7befabdc96 100644
--- a/app/views/projects/deployments/_rollback.haml
+++ b/app/views/projects/deployments/_rollback.haml
@@ -1,8 +1,7 @@
- if deployment.deployable && can?(current_user, :create_deployment, deployment)
- tooltip = deployment.last? ? s_('Environments|Re-deploy to environment') : s_('Environments|Rollback environment')
- = button_tag class: 'gl-button btn btn-default btn-icon has-tooltip', type: 'button', data: { toggle: 'modal', target: "#confirm-rollback-modal-#{deployment.id}" }, title: tooltip do
+ = button_tag class: 'js-confirm-rollback-modal-button gl-button btn btn-default btn-icon has-tooltip', type: 'button', data: { environment_name: @environment.name, commit_short_sha: deployment.short_sha, commit_url: project_commit_path(@project, deployment.sha), is_last_deployment: deployment.last?.to_s, retry_path: retry_project_job_path(@environment.project, deployment.deployable) }, title: tooltip do
- if deployment.last?
= sprite_icon('repeat', css_class: 'gl-icon')
- else
= sprite_icon('redo', css_class: 'gl-icon')
- = render 'projects/deployments/confirm_rollback_modal', deployment: deployment
diff --git a/lib/api/rubygem_packages.rb b/lib/api/rubygem_packages.rb
index d7f9c584c67..9ef6ec03a41 100644
--- a/lib/api/rubygem_packages.rb
+++ b/lib/api/rubygem_packages.rb
@@ -101,7 +101,7 @@ module API
package_file = nil
- ActiveRecord::Base.transaction do
+ ApplicationRecord.transaction do
package = ::Packages::CreateTemporaryPackageService.new(
user_project, current_user, declared_params.merge(build: current_authenticated_job)
).execute(:rubygems, name: ::Packages::Rubygems::TEMPORARY_PACKAGE_NAME)
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index b84c33a8fec..aedb7f59978 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -12626,9 +12626,6 @@ msgstr ""
msgid "Environments|Re-deploy"
msgstr ""
-msgid "Environments|Re-deploy environment %{environment_name}?"
-msgstr ""
-
msgid "Environments|Re-deploy environment %{name}?"
msgstr ""
@@ -12641,9 +12638,6 @@ msgstr ""
msgid "Environments|Rollback environment"
msgstr ""
-msgid "Environments|Rollback environment %{environment_name}?"
-msgstr ""
-
msgid "Environments|Rollback environment %{name}?"
msgstr ""
@@ -12665,15 +12659,9 @@ msgstr ""
msgid "Environments|There was an error fetching the logs. Please try again."
msgstr ""
-msgid "Environments|This action will relaunch the job for commit %{commit_id}, putting the environment in a previous version. Are you sure you want to continue?"
-msgstr ""
-
msgid "Environments|This action will relaunch the job for commit %{linkStart}%{commitId}%{linkEnd}, putting the environment in a previous version. Are you sure you want to continue?"
msgstr ""
-msgid "Environments|This action will run the job defined by %{environment_name} for commit %{commit_id}, putting the environment in a previous version. You can revert it by re-deploying the latest version of your application. Are you sure you want to continue?"
-msgstr ""
-
msgid "Environments|This action will run the job defined by %{name} for commit %{linkStart}%{commitId}%{linkEnd} putting the environment in a previous version. You can revert it by re-deploying the latest version of your application. Are you sure you want to continue?"
msgstr ""
diff --git a/qa/qa.rb b/qa/qa.rb
index dccb95613f1..d684d7c7651 100644
--- a/qa/qa.rb
+++ b/qa/qa.rb
@@ -423,6 +423,10 @@ module QA
autoload :Show, 'qa/page/project/snippet/show'
autoload :Index, 'qa/page/project/snippet/index'
end
+
+ module Secure
+ autoload :ConfigurationForm, 'qa/page/project/secure/configuration_form'
+ end
end
module Profile
diff --git a/qa/qa/page/project/secure/configuration_form.rb b/qa/qa/page/project/secure/configuration_form.rb
new file mode 100644
index 00000000000..73d1601b61e
--- /dev/null
+++ b/qa/qa/page/project/secure/configuration_form.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+module QA
+ module Page
+ module Project
+ module Secure
+ class ConfigurationForm < QA::Page::Base
+ include QA::Page::Component::Select2
+ include QA::Page::Settings::Common
+
+ view 'app/assets/javascripts/security_configuration/components/feature_card.vue' do
+ element :sast_status, "`${feature.type}_status`" # rubocop:disable QA/ElementWithPattern
+ element :sast_enable_button, "`${feature.type}_enable_button`" # rubocop:disable QA/ElementWithPattern
+ end
+
+ def click_sast_enable_button
+ click_element(:sast_enable_button)
+ end
+
+ def has_sast_status?(status_text)
+ within_element(:sast_status) do
+ has_text?(status_text)
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+QA::Page::Project::Secure::ConfigurationForm.prepend_mod_with('Page::Project::Secure::ConfigurationForm', namespace: QA)
diff --git a/spec/features/admin/dashboard_spec.rb b/spec/features/admin/dashboard_spec.rb
index 618fae3e46b..112dc9e01d8 100644
--- a/spec/features/admin/dashboard_spec.rb
+++ b/spec/features/admin/dashboard_spec.rb
@@ -19,8 +19,8 @@ RSpec.describe 'admin visits dashboard' do
# Make sure the fork_networks & fork_networks reltuples have been updated
# to get a correct count on postgresql
- ActiveRecord::Base.connection.execute('ANALYZE fork_networks')
- ActiveRecord::Base.connection.execute('ANALYZE fork_network_members')
+ ForkNetwork.connection.execute('ANALYZE fork_networks')
+ ForkNetwork.connection.execute('ANALYZE fork_network_members')
visit admin_root_path
diff --git a/spec/frontend/environments/confirm_rollback_modal_spec.js b/spec/frontend/environments/confirm_rollback_modal_spec.js
index 8fb53579f96..d675726b82b 100644
--- a/spec/frontend/environments/confirm_rollback_modal_spec.js
+++ b/spec/frontend/environments/confirm_rollback_modal_spec.js
@@ -6,65 +6,83 @@ import eventHub from '~/environments/event_hub';
describe('Confirm Rollback Modal Component', () => {
let environment;
- beforeEach(() => {
- environment = {
- name: 'test',
- last_deployment: {
- commit: {
- short_id: 'abc0123',
- },
+ const envWithLastDeployment = {
+ name: 'test',
+ last_deployment: {
+ commit: {
+ short_id: 'abc0123',
},
- modalId: 'test',
- };
- });
+ },
+ modalId: 'test',
+ };
- it('should show "Rollback" when isLastDeployment is false', () => {
- const component = shallowMount(ConfirmRollbackModal, {
- propsData: {
- environment: {
- ...environment,
- isLastDeployment: false,
- },
- },
- });
- const modal = component.find(GlModal);
+ const envWithoutLastDeployment = {
+ name: 'test',
+ modalId: 'test',
+ commitShortSha: 'abc0123',
+ commitUrl: 'test/-/commit/abc0123',
+ };
- expect(modal.attributes('title')).toContain('Rollback');
- expect(modal.attributes('title')).toContain('test');
- expect(modal.attributes('ok-title')).toBe('Rollback');
- expect(modal.text()).toContain('commit abc0123');
- expect(modal.text()).toContain('Are you sure you want to continue?');
- });
+ describe.each`
+ hasMultipleCommits | environmentData
+ ${true} | ${envWithLastDeployment}
+ ${false} | ${envWithoutLastDeployment}
+ `('when hasMultipleCommits=$hasMultipleCommits', ({ hasMultipleCommits, environmentData }) => {
+ beforeEach(() => {
+ environment = environmentData;
+ });
- it('should show "Re-deploy" when isLastDeployment is true', () => {
- const component = shallowMount(ConfirmRollbackModal, {
- propsData: {
- environment: {
- ...environment,
- isLastDeployment: true,
+ it('should show "Rollback" when isLastDeployment is false', () => {
+ const component = shallowMount(ConfirmRollbackModal, {
+ propsData: {
+ environment: {
+ ...environment,
+ isLastDeployment: false,
+ },
+ hasMultipleCommits,
},
- },
+ });
+ const modal = component.find(GlModal);
+
+ expect(modal.attributes('title')).toContain('Rollback');
+ expect(modal.attributes('title')).toContain('test');
+ expect(modal.attributes('ok-title')).toBe('Rollback');
+ expect(modal.text()).toContain('commit abc0123');
+ expect(modal.text()).toContain('Are you sure you want to continue?');
});
- const modal = component.find(GlModal);
- expect(modal.attributes('title')).toContain('Re-deploy');
- expect(modal.attributes('title')).toContain('test');
- expect(modal.attributes('ok-title')).toBe('Re-deploy');
- expect(modal.text()).toContain('commit abc0123');
- expect(modal.text()).toContain('Are you sure you want to continue?');
- });
+ it('should show "Re-deploy" when isLastDeployment is true', () => {
+ const component = shallowMount(ConfirmRollbackModal, {
+ propsData: {
+ environment: {
+ ...environment,
+ isLastDeployment: true,
+ },
+ hasMultipleCommits,
+ },
+ });
+ const modal = component.find(GlModal);
- it('should emit the "rollback" event when "ok" is clicked', () => {
- environment = { ...environment, isLastDeployment: true };
- const component = shallowMount(ConfirmRollbackModal, {
- propsData: {
- environment,
- },
+ expect(modal.attributes('title')).toContain('Re-deploy');
+ expect(modal.attributes('title')).toContain('test');
+ expect(modal.attributes('ok-title')).toBe('Re-deploy');
+ expect(modal.text()).toContain('commit abc0123');
+ expect(modal.text()).toContain('Are you sure you want to continue?');
});
- const eventHubSpy = jest.spyOn(eventHub, '$emit');
- const modal = component.find(GlModal);
- modal.vm.$emit('ok');
- expect(eventHubSpy).toHaveBeenCalledWith('rollbackEnvironment', environment);
+ it('should emit the "rollback" event when "ok" is clicked', () => {
+ const env = { ...environmentData, isLastDeployment: true };
+ const component = shallowMount(ConfirmRollbackModal, {
+ propsData: {
+ environment: env,
+ hasMultipleCommits,
+ },
+ });
+ const eventHubSpy = jest.spyOn(eventHub, '$emit');
+ const modal = component.find(GlModal);
+ modal.vm.$emit('ok');
+
+ expect(eventHubSpy).toHaveBeenCalledWith('rollbackEnvironment', env);
+ });
});
});
diff --git a/spec/initializers/lograge_spec.rb b/spec/initializers/lograge_spec.rb
index a1fd9be299b..992520f033f 100644
--- a/spec/initializers/lograge_spec.rb
+++ b/spec/initializers/lograge_spec.rb
@@ -212,7 +212,7 @@ RSpec.describe 'lograge', type: :request do
end
before do
- ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);')
+ ApplicationRecord.connection.execute('SELECT pg_sleep(0.1);')
end
context 'when RequestStore is enabled', :request_store do
diff --git a/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb b/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
index 29b192de809..fc08a13a8bd 100644
--- a/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
+++ b/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
@@ -190,7 +190,7 @@ RSpec.describe Gitlab::ImportExport::FastHashSerializer do
end
it 'does not complain about non UTF-8 characters in MR diff files' do
- ActiveRecord::Base.connection.execute("UPDATE merge_request_diff_files SET diff = '---\n- :diff: !binary |-\n LS0tIC9kZXYvbnVsbAorKysgYi9pbWFnZXMvbnVjb3IucGRmCkBAIC0wLDAg\n KzEsMTY3OSBAQAorJVBERi0xLjUNJeLjz9MNCisxIDAgb2JqDTw8L01ldGFk\n YXR'")
+ MergeRequest.connection.execute("UPDATE merge_request_diff_files SET diff = '---\n- :diff: !binary |-\n LS0tIC9kZXYvbnVsbAorKysgYi9pbWFnZXMvbnVjb3IucGRmCkBAIC0wLDAg\n KzEsMTY3OSBAQAorJVBERi0xLjUNJeLjz9MNCisxIDAgb2JqDTw8L01ldGFk\n YXR'")
expect(subject['merge_requests'].first['merge_request_diff']).not_to be_empty
end
diff --git a/spec/lib/gitlab/import_export/project/tree_saver_spec.rb b/spec/lib/gitlab/import_export/project/tree_saver_spec.rb
index fd6c66a10a7..bee7c59cab0 100644
--- a/spec/lib/gitlab/import_export/project/tree_saver_spec.rb
+++ b/spec/lib/gitlab/import_export/project/tree_saver_spec.rb
@@ -386,7 +386,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do
end
it 'does not complain about non UTF-8 characters in MR diff files' do
- ActiveRecord::Base.connection.execute("UPDATE merge_request_diff_files SET diff = '---\n- :diff: !binary |-\n LS0tIC9kZXYvbnVsbAorKysgYi9pbWFnZXMvbnVjb3IucGRmCkBAIC0wLDAg\n KzEsMTY3OSBAQAorJVBERi0xLjUNJeLjz9MNCisxIDAgb2JqDTw8L01ldGFk\n YXR'")
+ MergeRequestDiffFile.connection.execute("UPDATE merge_request_diff_files SET diff = '---\n- :diff: !binary |-\n LS0tIC9kZXYvbnVsbAorKysgYi9pbWFnZXMvbnVjb3IucGRmCkBAIC0wLDAg\n KzEsMTY3OSBAQAorJVBERi0xLjUNJeLjz9MNCisxIDAgb2JqDTw8L01ldGFk\n YXR'")
expect(project_tree_saver.save).to be true
end
diff --git a/spec/lib/gitlab/pagination/keyset/order_spec.rb b/spec/lib/gitlab/pagination/keyset/order_spec.rb
index 562a9bf4460..a2179b4e902 100644
--- a/spec/lib/gitlab/pagination/keyset/order_spec.rb
+++ b/spec/lib/gitlab/pagination/keyset/order_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Gitlab::Pagination::Keyset::Order do
let(:order) { nil }
def run_query(query)
- ActiveRecord::Base.connection.execute(query).to_a
+ ApplicationRecord.connection.execute(query).to_a
end
def build_query(order:, where_conditions: nil, limit: nil)
diff --git a/spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb b/spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb
index 1ab8e22d6d1..5ccde789a2e 100644
--- a/spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb
+++ b/spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb
@@ -27,7 +27,7 @@ RSpec.describe Gitlab::QueryLimiting::ActiveSupportSubscriber do
context 'when the query is actually a rails cache hit' do
it 'does not increment the number of executed SQL queries' do
- ActiveRecord::Base.connection.cache do
+ User.connection.cache do
User.count
User.count
end
diff --git a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
index 73a5f64186e..a6ebea1bd29 100644
--- a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
+++ b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
@@ -256,7 +256,7 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do
expect(logger).to receive(:info).with(expected_end_payload_with_db).ordered
call_subject(job, 'test_queue') do
- ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);')
+ ApplicationRecord.connection.execute('SELECT pg_sleep(0.1);')
end
end
@@ -267,7 +267,7 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do
expect(logger).to receive(:info).with(expected_end_payload).ordered
call_subject(job.dup, 'test_queue') do
- ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);')
+ ApplicationRecord.connection.execute('SELECT pg_sleep(0.1);')
end
Gitlab::SafeRequestStore.clear!
@@ -298,7 +298,7 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do
allow(Gitlab::Database::LoadBalancing).to receive(:enable?).and_return(true)
end
- let(:db_config_name) { ::Gitlab::Database.db_config_name(ActiveRecord::Base.connection) }
+ let(:db_config_name) { ::Gitlab::Database.db_config_name(ApplicationRecord.connection) }
let(:expected_end_payload_with_db) do
expected_end_payload.merge(
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb
index 80471a09bbd..367995e5477 100644
--- a/spec/models/application_setting_spec.rb
+++ b/spec/models/application_setting_spec.rb
@@ -927,7 +927,7 @@ RSpec.describe ApplicationSetting do
context 'when ApplicationSettings does not have a primary key' do
before do
- allow(ActiveRecord::Base.connection).to receive(:primary_key).with(described_class.table_name).and_return(nil)
+ allow(described_class.connection).to receive(:primary_key).with(described_class.table_name).and_return(nil)
end
it 'raises an exception' do
diff --git a/spec/requests/api/statistics_spec.rb b/spec/requests/api/statistics_spec.rb
index eab97b6916e..baffb2792e9 100644
--- a/spec/requests/api/statistics_spec.rb
+++ b/spec/requests/api/statistics_spec.rb
@@ -63,7 +63,7 @@ RSpec.describe API::Statistics, 'Statistics' do
# Make sure the reltuples have been updated
# to get a correct count on postgresql
tables_to_analyze.each do |table|
- ActiveRecord::Base.connection.execute("ANALYZE #{table}")
+ ApplicationRecord.connection.execute("ANALYZE #{table}")
end
get api(path, admin)
diff --git a/spec/views/projects/deployments/_confirm_rollback_modal_spec.html_spec.rb b/spec/views/projects/deployments/_confirm_rollback_modal_spec.html_spec.rb
deleted file mode 100644
index 2fb7b6187eb..00000000000
--- a/spec/views/projects/deployments/_confirm_rollback_modal_spec.html_spec.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe 'projects/deployments/_confirm_rollback_modal' do
- let(:environment) { create(:environment, :with_review_app) }
- let(:deployments) { environment.deployments }
- let(:project) { environment.project }
-
- before do
- assign(:environment, environment)
- assign(:deployments, deployments)
- assign(:project, project)
- end
-
- context 'when re-deploying last deployment' do
- let(:deployment) { deployments.first }
-
- before do
- allow(view).to receive(:deployment).and_return(deployment)
- end
-
- it 'shows "re-deploy"' do
- render
-
- expect(rendered).to have_selector('h4', text: "Re-deploy environment #{environment.name}?")
- expect(rendered).to have_selector('p', text: "This action will relaunch the job for commit #{deployment.short_sha}, putting the environment in a previous version. Are you sure you want to continue?")
- expect(rendered).to have_selector('a.btn-danger', text: 'Re-deploy')
- end
-
- it 'links to re-deploying the environment' do
- expected_link = retry_project_job_path(environment.project, deployment.deployable)
-
- render
-
- expect(rendered).to have_selector("a[href='#{expected_link}']", text: 'Re-deploy')
- end
- end
-
- context 'when rolling back to previous deployment' do
- let(:deployment) { create(:deployment, environment: environment) }
-
- before do
- allow(view).to receive(:deployment).and_return(deployment)
- end
-
- it 'shows "rollback"' do
- render
-
- expect(rendered).to have_selector('h4', text: "Rollback environment #{environment.name}?")
- expect(rendered).to have_selector('p', text: "This action will run the job defined by #{environment.name} for commit #{deployment.short_sha}, putting the environment in a previous version. You can revert it by re-deploying the latest version of your application. Are you sure you want to continue?")
- expect(rendered).to have_selector('a.btn-danger', text: 'Rollback')
- end
-
- it 'links to re-deploying the environment' do
- expected_link = retry_project_job_path(environment.project, deployment.deployable)
-
- render
-
- expect(rendered).to have_selector("a[href='#{expected_link}']", text: 'Rollback')
- end
- end
-end