Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-12-05 22:40:33 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-05 22:40:33 +0300
commitd7c5be92af9c10cf20e78363c188c1a707a6bb90 (patch)
treedf2d354bc4277c7a0324fb8240bd4e24d58007f2 /spec
parentb28d1361dd1ec63053dbfae475097928c6d01116 (diff)
Add latest changes from gitlab-org/gitlab@15-6-stable-ee
Diffstat (limited to 'spec')
-rw-r--r--spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb3
-rw-r--r--spec/features/profiles/user_edit_profile_spec.rb2
-rw-r--r--spec/features/user_sees_marketing_header_spec.rb31
-rw-r--r--spec/frontend/branches/components/delete_branch_modal_spec.js21
-rw-r--r--spec/helpers/application_helper_spec.rb16
-rw-r--r--spec/lib/gitlab/background_migration/destroy_invalid_members_spec.rb2
-rw-r--r--spec/lib/gitlab/fips_spec.rb2
-rw-r--r--spec/lib/gitlab/memory/watchdog/configurator_spec.rb4
-rw-r--r--spec/migrations/20221002234454_finalize_group_member_namespace_id_migration_spec.rb72
-rw-r--r--spec/support/database_cleaner.rb10
-rw-r--r--spec/support/migration.rb2
11 files changed, 103 insertions, 62 deletions
diff --git a/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb b/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb
index 332426de07e..99f1b1ab1ad 100644
--- a/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb
+++ b/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb
@@ -449,8 +449,11 @@ RSpec.describe 'Merge request > User resolves diff notes and threads', :js do
page.within '.diff-content' do
find('button[data-testid="resolve-discussion-button"]').click
+ wait_for_requests
+
find_field('Reply…').click
+ find('.js-unresolve-checkbox')
find('.js-note-text').set 'testing'
click_button 'Add comment now'
diff --git a/spec/features/profiles/user_edit_profile_spec.rb b/spec/features/profiles/user_edit_profile_spec.rb
index 56a70f37779..1d99f7a8511 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' 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
diff --git a/spec/features/user_sees_marketing_header_spec.rb b/spec/features/user_sees_marketing_header_spec.rb
deleted file mode 100644
index eae964cec02..00000000000
--- a/spec/features/user_sees_marketing_header_spec.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-require "spec_helper"
-
-RSpec.describe 'User sees experimental lmarketing header' do
- let_it_be(:project) { create(:project, :public) }
-
- context 'when not logged in' do
- it 'shows marketing header links', :aggregate_failures do
- visit project_path(project)
-
- expect(page).to have_text "About GitLab"
- expect(page).to have_text "Pricing"
- expect(page).to have_text "Talk to an expert"
- expect(page).to have_text "Sign up now"
- expect(page).to have_text "Login"
- end
- end
-
- context 'when logged in' do
- it 'does not show marketing header links', :aggregate_failures do
- sign_in(create(:user))
-
- visit project_path(project)
-
- expect(page).not_to have_text "About GitLab"
- expect(page).not_to have_text "Pricing"
- expect(page).not_to have_text "Talk to an expert"
- end
- end
-end
diff --git a/spec/frontend/branches/components/delete_branch_modal_spec.js b/spec/frontend/branches/components/delete_branch_modal_spec.js
index 2b8c8d408c4..c977868ca93 100644
--- a/spec/frontend/branches/components/delete_branch_modal_spec.js
+++ b/spec/frontend/branches/components/delete_branch_modal_spec.js
@@ -46,6 +46,7 @@ const findDeleteButton = () => wrapper.findByTestId('delete-branch-confirmation-
const findCancelButton = () => wrapper.findByTestId('delete-branch-cancel-button');
const findFormInput = () => wrapper.findComponent(GlFormInput);
const findForm = () => wrapper.find('form');
+const submitFormSpy = () => jest.spyOn(wrapper.vm.$refs.form, 'submit');
describe('Delete branch modal', () => {
const expectedUnmergedWarning =
@@ -73,12 +74,10 @@ describe('Delete branch modal', () => {
});
it('submits the form when the delete button is clicked', () => {
- const submitFormSpy = jest.spyOn(wrapper.vm.$refs.form, 'submit');
-
findDeleteButton().trigger('click');
expect(findForm().attributes('action')).toBe(deletePath);
- expect(submitFormSpy).toHaveBeenCalled();
+ expect(submitFormSpy()).toHaveBeenCalled();
});
it('calls show on the modal when a `openModal` event is received through the event hub', async () => {
@@ -136,7 +135,18 @@ describe('Delete branch modal', () => {
});
});
- it('opens with the delete button disabled and enables it when branch name is confirmed', async () => {
+ it('opens with the delete button disabled and doesn`t fire submit when clicked or pressed enter', async () => {
+ expect(findDeleteButton().props('disabled')).toBe(true);
+
+ findFormInput().vm.$emit('input', 'hello');
+
+ await waitForPromises();
+
+ findDeleteButton().trigger('click');
+ expect(submitFormSpy()).not.toHaveBeenCalled();
+ });
+
+ it('opens with the delete button disabled and enables it when branch name is confirmed and fires submit', async () => {
expect(findDeleteButton().props('disabled')).toBe(true);
findFormInput().vm.$emit('input', branchName);
@@ -144,6 +154,9 @@ describe('Delete branch modal', () => {
await waitForPromises();
expect(findDeleteButton().props('disabled')).not.toBe(true);
+
+ findDeleteButton().trigger('click');
+ expect(submitFormSpy()).toHaveBeenCalled();
});
});
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 7f838167bd2..261d8c8c302 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -533,25 +533,15 @@ RSpec.describe ApplicationHelper do
end
describe '#page_class' do
- let_it_be(:expected_class) { 'logged-out-marketing-header' }
-
- let(:current_user) { nil }
-
- subject do
+ subject(:page_class) do
helper.page_class.flatten
end
before do
- allow(helper).to receive(:current_user) { current_user }
+ allow(helper).to receive(:current_user).and_return(nil)
end
- it { is_expected.to include(expected_class) }
-
- context 'when a user is logged in' do
- let(:current_user) { create(:user) }
-
- it { is_expected.not_to include(expected_class) }
- end
+ it { is_expected.not_to include('logged-out-marketing-header') }
end
describe '#dispensable_render' do
diff --git a/spec/lib/gitlab/background_migration/destroy_invalid_members_spec.rb b/spec/lib/gitlab/background_migration/destroy_invalid_members_spec.rb
index 9b0cb96b30b..5059ad620aa 100644
--- a/spec/lib/gitlab/background_migration/destroy_invalid_members_spec.rb
+++ b/spec/lib/gitlab/background_migration/destroy_invalid_members_spec.rb
@@ -103,7 +103,7 @@ RSpec.describe Gitlab::BackgroundMigration::DestroyInvalidMembers, :migration, s
members = create_members
member_data = members.map do |m|
- { id: m.id, source_id: m.source_id, source_type: m.source_type }
+ { id: m.id, source_id: m.source_id, source_type: m.source_type, access_level: m.access_level }
end
expect(Gitlab::AppLogger).to receive(:info).with({ message: 'Removing invalid member records',
diff --git a/spec/lib/gitlab/fips_spec.rb b/spec/lib/gitlab/fips_spec.rb
index 4d19a44f617..50ab2889ccf 100644
--- a/spec/lib/gitlab/fips_spec.rb
+++ b/spec/lib/gitlab/fips_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe Gitlab::FIPS do
let(:fips_mode_env_var) { nil }
before do
- expect(OpenSSL).to receive(:fips_mode).and_return(openssl_fips_mode)
+ allow(OpenSSL).to receive(:fips_mode).and_return(openssl_fips_mode)
stub_env("FIPS_MODE", fips_mode_env_var)
end
diff --git a/spec/lib/gitlab/memory/watchdog/configurator_spec.rb b/spec/lib/gitlab/memory/watchdog/configurator_spec.rb
index e6f2d57e9e6..86cbb724cfd 100644
--- a/spec/lib/gitlab/memory/watchdog/configurator_spec.rb
+++ b/spec/lib/gitlab/memory/watchdog/configurator_spec.rb
@@ -165,7 +165,7 @@ RSpec.describe Gitlab::Memory::Watchdog::Configurator do
end
context 'when settings are set via environment variables' do
- let(:memory_limit) { 1300 }
+ let(:memory_limit) { 1300.megabytes }
let(:max_strikes) { 4 }
before do
@@ -177,7 +177,7 @@ RSpec.describe Gitlab::Memory::Watchdog::Configurator do
end
context 'when settings are not set via environment variables' do
- let(:memory_limit) { 1200 }
+ let(:memory_limit) { 1200.megabytes }
let(:max_strikes) { 5 }
it_behaves_like 'as monitor configurator'
diff --git a/spec/migrations/20221002234454_finalize_group_member_namespace_id_migration_spec.rb b/spec/migrations/20221002234454_finalize_group_member_namespace_id_migration_spec.rb
new file mode 100644
index 00000000000..9c27005065d
--- /dev/null
+++ b/spec/migrations/20221002234454_finalize_group_member_namespace_id_migration_spec.rb
@@ -0,0 +1,72 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require_migration!
+
+RSpec.describe FinalizeGroupMemberNamespaceIdMigration, :migration do
+ let(:batched_migrations) { table(:batched_background_migrations) }
+
+ let_it_be(:migration) { described_class::MIGRATION }
+
+ describe '#up' do
+ shared_examples 'finalizes the migration' do
+ it 'finalizes the migration' do
+ allow_next_instance_of(Gitlab::Database::BackgroundMigration::BatchedMigrationRunner) do |runner|
+ expect(runner).to receive(:finalize).with('BackfillMemberNamespaceForGroupMembers', :members, :id, [])
+ end
+ end
+ end
+
+ context 'when migration is missing' do
+ it 'warns migration not found' do
+ expect(Gitlab::AppLogger)
+ .to receive(:warn).with(/Could not find batched background migration for the given configuration:/)
+
+ migrate!
+ end
+ end
+
+ context 'with migration present' do
+ let!(:group_member_namespace_id_backfill) do
+ batched_migrations.create!(
+ job_class_name: 'BackfillMemberNamespaceForGroupMembers',
+ table_name: :members,
+ column_name: :id,
+ job_arguments: [],
+ interval: 2.minutes,
+ min_value: 1,
+ max_value: 2,
+ batch_size: 1000,
+ sub_batch_size: 200,
+ gitlab_schema: :gitlab_main,
+ status: 3 # finished
+ )
+ end
+
+ context 'when migration finished successfully' do
+ it 'does not raise exception' do
+ expect { migrate! }.not_to raise_error
+ end
+ end
+
+ context 'with different migration statuses' do
+ using RSpec::Parameterized::TableSyntax
+
+ where(:status, :description) do
+ 0 | 'paused'
+ 1 | 'active'
+ 4 | 'failed'
+ 5 | 'finalizing'
+ end
+
+ with_them do
+ before do
+ group_member_namespace_id_backfill.update!(status: status)
+ end
+
+ it_behaves_like 'finalizes the migration'
+ end
+ end
+ end
+ end
+end
diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb
index 222cbe9feeb..7bd1f0c5dfa 100644
--- a/spec/support/database_cleaner.rb
+++ b/spec/support/database_cleaner.rb
@@ -22,14 +22,4 @@ RSpec.configure do |config|
self.class.use_transactional_tests = true
end
-
- config.around(:each, :migration) do |example|
- self.class.use_transactional_tests = false
-
- example.run
-
- delete_from_all_tables!(except: deletion_except_tables)
-
- self.class.use_transactional_tests = true
- end
end
diff --git a/spec/support/migration.rb b/spec/support/migration.rb
index 2a69630a29a..4d4a293e9ff 100644
--- a/spec/support/migration.rb
+++ b/spec/support/migration.rb
@@ -45,6 +45,8 @@ RSpec.configure do |config|
example.run
end
+ delete_from_all_tables!(except: deletion_except_tables)
+
self.class.use_transactional_tests = true
end