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>2023-05-05 12:12:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-05 12:12:42 +0300
commit2a134be97dafb4743eee8fc908463136ddf23b1f (patch)
tree43ce3854f0a69a5938db1a56abc20cdce3517a52 /spec
parent7c0c3a7dc95668d20ec8f4bbc2d505f373b6032a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/config/mail_room_spec.rb21
-rw-r--r--spec/controllers/import/gitlab_controller_spec.rb313
-rw-r--r--spec/controllers/projects/merge_requests/conflicts_controller_spec.rb4
-rw-r--r--spec/controllers/projects/merge_requests/diffs_controller_spec.rb2
-rw-r--r--spec/features/merge_request/user_sees_versions_spec.rb2
-rw-r--r--spec/features/projects/integrations/user_activates_mattermost_slash_command_spec.rb2
-rw-r--r--spec/features/projects/new_project_spec.rb21
-rw-r--r--spec/frontend/lib/utils/datetime/date_format_utility_spec.js17
-rw-r--r--spec/frontend/lib/utils/datetime_utility_spec.js40
-rw-r--r--spec/lib/gitlab/gitlab_import/client_spec.rb111
-rw-r--r--spec/lib/gitlab/gitlab_import/importer_spec.rb57
-rw-r--r--spec/lib/gitlab/gitlab_import/project_creator_spec.rb37
-rw-r--r--spec/lib/gitlab/import_sources_spec.rb7
-rw-r--r--spec/lib/gitlab/kas/client_spec.rb29
-rw-r--r--spec/lib/gitlab/redis/cache_spec.rb1
-rw-r--r--spec/lib/gitlab/redis/queues_spec.rb1
-rw-r--r--spec/lib/gitlab/redis/shared_state_spec.rb1
-rw-r--r--spec/lib/gitlab/redis/sidekiq_status_spec.rb1
-rw-r--r--spec/lib/gitlab/usage_data_spec.rb8
-rw-r--r--spec/models/application_setting_spec.rb2
-rw-r--r--spec/routing/import_routing_spec.rb26
-rw-r--r--spec/support/capybara.rb56
-rw-r--r--spec/support/rspec_order_todo.yml4
-rw-r--r--spec/support/shared_examples/features/content_editor_shared_examples.rb1
-rw-r--r--spec/support/shared_examples/redis/redis_new_instance_shared_examples.rb27
-rw-r--r--spec/support/shared_examples/redis/redis_shared_examples.rb28
-rw-r--r--spec/tooling/danger/database_dictionary_spec.rb152
27 files changed, 312 insertions, 659 deletions
diff --git a/spec/config/mail_room_spec.rb b/spec/config/mail_room_spec.rb
index ace8bf5aa24..a3806fb3cb6 100644
--- a/spec/config/mail_room_spec.rb
+++ b/spec/config/mail_room_spec.rb
@@ -7,13 +7,12 @@ RSpec.describe 'mail_room.yml', feature_category: :service_desk do
let(:mailroom_config_path) { 'config/mail_room.yml' }
let(:gitlab_config_path) { 'config/mail_room.yml' }
- let(:queues_config_source_path) { 'config/redis.queues.yml' }
let(:queues_config_path) { 'config/redis.queues.yml' }
- let(:queue_config_tmp_path) { 'config/redis.queues.yml.tmp' }
let(:configuration) do
vars = {
- 'MAIL_ROOM_GITLAB_CONFIG_FILE' => absolute_path(gitlab_config_path)
+ 'MAIL_ROOM_GITLAB_CONFIG_FILE' => absolute_path(gitlab_config_path),
+ 'GITLAB_REDIS_QUEUES_CONFIG_FILE' => absolute_path(queues_config_path)
}
cmd = "puts ERB.new(File.read(#{absolute_path(mailroom_config_path).inspect})).result"
@@ -26,16 +25,8 @@ RSpec.describe 'mail_room.yml', feature_category: :service_desk do
YAML.safe_load(output, permitted_classes: [Symbol])
end
- around do |example|
- # put aside config/redis.queues.yml if it exists
- FileUtils.mv(queues_config_path, queue_config_tmp_path) if File.file?(queues_config_path)
-
- # set config/redis.queues.yml
- FileUtils.cp(queues_config_source_path, queues_config_path) if queues_config_source_path != queues_config_path
-
- example.run
-
- FileUtils.mv(queue_config_tmp_path, queues_config_path) if File.file?(queue_config_tmp_path)
+ before do
+ stub_env('GITLAB_REDIS_QUEUES_CONFIG_FILE', absolute_path(queues_config_path))
end
context 'when incoming email is disabled' do
@@ -48,7 +39,7 @@ RSpec.describe 'mail_room.yml', feature_category: :service_desk do
context 'when both incoming email and service desk email are enabled' do
let(:gitlab_config_path) { 'spec/fixtures/config/mail_room_enabled.yml' }
- let(:queues_config_source_path) { 'spec/fixtures/config/redis_new_format_host.yml' }
+ let(:queues_config_path) { 'spec/fixtures/config/redis_new_format_host.yml' }
let(:gitlab_redis_queues) { Gitlab::Redis::Queues.new(Rails.env) }
it 'contains the intended configuration' do
@@ -78,7 +69,7 @@ RSpec.describe 'mail_room.yml', feature_category: :service_desk do
context 'when both incoming email and service desk email are enabled for Microsoft Graph' do
let(:gitlab_config_path) { 'spec/fixtures/config/mail_room_enabled_ms_graph.yml' }
- let(:queues_config_source_path) { 'spec/fixtures/config/redis_new_format_host.yml' }
+ let(:queues_config_path) { 'spec/fixtures/config/redis_new_format_host.yml' }
let(:gitlab_redis_queues) { Gitlab::Redis::Queues.new(Rails.env) }
it 'contains the intended configuration' do
diff --git a/spec/controllers/import/gitlab_controller_spec.rb b/spec/controllers/import/gitlab_controller_spec.rb
deleted file mode 100644
index 2c09f8c010e..00000000000
--- a/spec/controllers/import/gitlab_controller_spec.rb
+++ /dev/null
@@ -1,313 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Import::GitlabController, feature_category: :importers do
- include ImportSpecHelper
-
- let(:user) { create(:user) }
- let(:token) { "asdasd12345" }
- let(:access_params) { { gitlab_access_token: token } }
-
- def assign_session_token
- session[:gitlab_access_token] = token
- end
-
- before do
- sign_in(user)
- allow(controller).to receive(:gitlab_import_enabled?).and_return(true)
- end
-
- describe "GET callback" do
- it "updates access token" do
- allow_next_instance_of(Gitlab::GitlabImport::Client) do |instance|
- allow(instance).to receive(:get_token).and_return(token)
- end
- stub_omniauth_provider('gitlab')
-
- get :callback
-
- expect(session[:gitlab_access_token]).to eq(token)
- expect(controller).to redirect_to(status_import_gitlab_url)
- end
-
- it "importable_repos should return an array" do
- allow_next_instance_of(Gitlab::GitlabImport::Client) do |instance|
- allow(instance).to receive(:projects).and_return([{ "id": 1 }].to_enum)
- end
-
- expect(controller.send(:importable_repos)).to be_an_instance_of(Array)
- end
-
- it "passes namespace_id query param to status if provided" do
- namespace_id = 30
-
- allow_next_instance_of(Gitlab::GitlabImport::Client) do |instance|
- allow(instance).to receive(:get_token).and_return(token)
- end
-
- get :callback, params: { namespace_id: namespace_id }
-
- expect(controller).to redirect_to(status_import_gitlab_url(namespace_id: namespace_id))
- end
- end
-
- describe "GET status" do
- let(:repo_fake) { Struct.new(:id, :path, :path_with_namespace, :web_url, keyword_init: true) }
- let(:repo) { repo_fake.new(id: 1, path: 'vim', path_with_namespace: 'asd/vim', web_url: 'https://gitlab.com/asd/vim') }
-
- context 'when session contains access token' do
- before do
- assign_session_token
- end
-
- it_behaves_like 'import controller status' do
- let(:repo_id) { repo.id }
- let(:import_source) { repo.path_with_namespace }
- let(:provider_name) { 'gitlab' }
- let(:client_repos_field) { :projects }
- end
- end
-
- it 'redirects to auth if session does not contain access token' do
- remote_gitlab_url = 'https://test.host/auth/gitlab'
-
- allow(Gitlab::GitlabImport::Client)
- .to receive(:new)
- .and_return(double(authorize_url: remote_gitlab_url))
-
- get :status
-
- expect(response).to redirect_to(remote_gitlab_url)
- end
- end
-
- describe "POST create" do
- let(:project) { create(:project) }
- let(:gitlab_username) { user.username }
- let(:gitlab_user) do
- { username: gitlab_username }.with_indifferent_access
- end
-
- let(:gitlab_repo) do
- {
- path: 'vim',
- path_with_namespace: "#{gitlab_username}/vim",
- owner: { name: gitlab_username },
- namespace: { path: gitlab_username }
- }.with_indifferent_access
- end
-
- before do
- stub_client(user: gitlab_user, project: gitlab_repo)
- assign_session_token
- end
-
- it 'returns 200 response when the project is imported successfully' do
- allow(Gitlab::GitlabImport::ProjectCreator)
- .to receive(:new).with(gitlab_repo, user.namespace, user, access_params)
- .and_return(double(execute: project))
-
- post :create, format: :json
-
- expect(response).to have_gitlab_http_status(:ok)
- end
-
- it 'returns 422 response when the project could not be imported' do
- allow(Gitlab::GitlabImport::ProjectCreator)
- .to receive(:new).with(gitlab_repo, user.namespace, user, access_params)
- .and_return(double(execute: build(:project)))
-
- post :create, format: :json
-
- expect(response).to have_gitlab_http_status(:unprocessable_entity)
- end
-
- context "when the repository owner is the GitLab.com user" do
- context "when the GitLab.com user and GitLab server user's usernames match" do
- it "takes the current user's namespace" do
- expect(Gitlab::GitlabImport::ProjectCreator)
- .to receive(:new).with(gitlab_repo, user.namespace, user, access_params)
- .and_return(double(execute: project))
-
- post :create, format: :json
- end
- end
-
- context "when the GitLab.com user and GitLab server user's usernames don't match" do
- let(:gitlab_username) { "someone_else" }
-
- it "takes the current user's namespace" do
- expect(Gitlab::GitlabImport::ProjectCreator)
- .to receive(:new).with(gitlab_repo, user.namespace, user, access_params)
- .and_return(double(execute: project))
-
- post :create, format: :json
- end
- end
- end
-
- context "when the repository owner is not the GitLab.com user" do
- let(:other_username) { "someone_else" }
-
- before do
- gitlab_repo["namespace"]["path"] = other_username
- assign_session_token
- end
-
- context "when a namespace with the GitLab.com user's username already exists" do
- let!(:existing_namespace) { create(:group, name: other_username) }
-
- context "when the namespace is owned by the GitLab server user" do
- before do
- existing_namespace.add_owner(user)
- end
-
- it "takes the existing namespace" do
- expect(Gitlab::GitlabImport::ProjectCreator)
- .to receive(:new).with(gitlab_repo, existing_namespace, user, access_params)
- .and_return(double(execute: project))
-
- post :create, format: :json
- end
- end
-
- context "when the namespace is not owned by the GitLab server user" do
- it "doesn't create a project" do
- expect(Gitlab::GitlabImport::ProjectCreator)
- .not_to receive(:new)
-
- post :create, format: :json
- end
- end
- end
-
- context "when a namespace with the GitLab.com user's username doesn't exist" do
- context "when current user can create namespaces" do
- it "creates the namespace" do
- expect(Gitlab::GitlabImport::ProjectCreator)
- .to receive(:new).and_return(double(execute: project))
-
- expect { post :create, format: :json }.to change(Namespace, :count).by(1)
- end
-
- it "takes the new namespace" do
- expect(Gitlab::GitlabImport::ProjectCreator)
- .to receive(:new).with(gitlab_repo, an_instance_of(Group), user, access_params)
- .and_return(double(execute: project))
-
- post :create, format: :json
- end
- end
-
- context "when current user can't create namespaces" do
- before do
- user.update_attribute(:can_create_group, false)
- end
-
- it "doesn't create the namespace" do
- expect(Gitlab::GitlabImport::ProjectCreator)
- .to receive(:new).and_return(double(execute: project))
-
- expect { post :create, format: :json }.not_to change(Namespace, :count)
- end
-
- it "takes the current user's namespace" do
- expect(Gitlab::GitlabImport::ProjectCreator)
- .to receive(:new).with(gitlab_repo, user.namespace, user, access_params)
- .and_return(double(execute: project))
-
- post :create, format: :json
- end
- end
- end
-
- context 'user has chosen an existing nested namespace for the project' do
- let(:parent_namespace) { create(:group, name: 'foo') }
- let(:nested_namespace) { create(:group, name: 'bar', parent: parent_namespace) }
-
- before do
- parent_namespace.add_owner(user)
- nested_namespace.add_owner(user)
- end
-
- it 'takes the selected namespace and name' do
- expect(Gitlab::GitlabImport::ProjectCreator)
- .to receive(:new).with(gitlab_repo, nested_namespace, user, access_params)
- .and_return(double(execute: project))
-
- post :create, params: { target_namespace: nested_namespace.full_path }, format: :json
- end
- end
-
- context 'user has chosen a non-existent nested namespaces for the project' do
- let(:test_name) { 'test_name' }
-
- it 'takes the selected namespace and name' do
- expect(Gitlab::GitlabImport::ProjectCreator)
- .to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params)
- .and_return(double(execute: project))
-
- post :create, params: { target_namespace: 'foo/bar' }, format: :json
- end
-
- it 'creates the namespaces' do
- allow(Gitlab::GitlabImport::ProjectCreator)
- .to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params)
- .and_return(double(execute: project))
-
- expect { post :create, params: { target_namespace: 'foo/bar' }, format: :json }
- .to change { Namespace.count }.by(2)
- end
-
- it 'new namespace has the right parent' do
- allow(Gitlab::GitlabImport::ProjectCreator)
- .to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params)
- .and_return(double(execute: project))
-
- post :create, params: { target_namespace: 'foo/bar' }, format: :json
-
- expect(Namespace.find_by_path_or_name('bar').parent.path).to eq('foo')
- end
- end
-
- context 'user has chosen existent and non-existent nested namespaces and name for the project' do
- let(:test_name) { 'test_name' }
- let!(:parent_namespace) { create(:group, name: 'foo') }
-
- before do
- parent_namespace.add_owner(user)
- end
-
- it 'takes the selected namespace and name' do
- expect(Gitlab::GitlabImport::ProjectCreator)
- .to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params)
- .and_return(double(execute: project))
-
- post :create, params: { target_namespace: 'foo/foobar/bar' }, format: :json
- end
-
- it 'creates the namespaces' do
- allow(Gitlab::GitlabImport::ProjectCreator)
- .to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params)
- .and_return(double(execute: project))
-
- expect { post :create, params: { target_namespace: 'foo/foobar/bar' }, format: :json }
- .to change { Namespace.count }.by(2)
- end
- end
-
- context 'when user can not create projects in the chosen namespace' do
- it 'returns 422 response' do
- other_namespace = create(:group, name: 'other_namespace')
-
- post :create, params: { target_namespace: other_namespace.name }, format: :json
-
- expect(response).to have_gitlab_http_status(:unprocessable_entity)
- end
- end
-
- it_behaves_like 'project import rate limiter'
- end
- end
-end
diff --git a/spec/controllers/projects/merge_requests/conflicts_controller_spec.rb b/spec/controllers/projects/merge_requests/conflicts_controller_spec.rb
index 356741fc4e2..926cd7ea681 100644
--- a/spec/controllers/projects/merge_requests/conflicts_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests/conflicts_controller_spec.rb
@@ -85,7 +85,7 @@ RSpec.describe Projects::MergeRequests::ConflictsController do
end
it 'includes each file that has conflicts' do
- filenames = json_response['files'].map { |file| file['new_path'] }
+ filenames = json_response['files'].pluck('new_path')
expect(filenames).to contain_exactly('files/ruby/popen.rb', 'files/ruby/regex.rb')
end
@@ -114,7 +114,7 @@ RSpec.describe Projects::MergeRequests::ConflictsController do
it 'has unique section IDs across files' do
section_ids = json_response['files'].flat_map do |file|
- file['sections'].map { |section| section['id'] }.compact
+ file['sections'].pluck('id').compact
end
expect(section_ids.uniq).to eq(section_ids)
diff --git a/spec/controllers/projects/merge_requests/diffs_controller_spec.rb b/spec/controllers/projects/merge_requests/diffs_controller_spec.rb
index a5dc351201d..3b562b4c151 100644
--- a/spec/controllers/projects/merge_requests/diffs_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests/diffs_controller_spec.rb
@@ -341,7 +341,7 @@ RSpec.describe Projects::MergeRequests::DiffsController, feature_category: :code
it 'only renders the diffs for the path given' do
diff_for_path(old_path: existing_path, new_path: existing_path)
- paths = json_response['diff_files'].map { |file| file['new_path'] }
+ paths = json_response['diff_files'].pluck('new_path')
expect(paths).to include(existing_path)
end
diff --git a/spec/features/merge_request/user_sees_versions_spec.rb b/spec/features/merge_request/user_sees_versions_spec.rb
index f94b288300a..91f8fd13681 100644
--- a/spec/features/merge_request/user_sees_versions_spec.rb
+++ b/spec/features/merge_request/user_sees_versions_spec.rb
@@ -232,7 +232,7 @@ RSpec.describe 'Merge request > User sees versions', :js, feature_category: :cod
end
it 'only shows diffs from the commit' do
- diff_commit_ids = find_all('.diff-file [data-commit-id]').map { |diff| diff['data-commit-id'] }
+ diff_commit_ids = find_all('.diff-file [data-commit-id]').pluck('data-commit-id')
expect(diff_commit_ids).not_to be_empty
expect(diff_commit_ids).to all(eq(params[:commit_id]))
diff --git a/spec/features/projects/integrations/user_activates_mattermost_slash_command_spec.rb b/spec/features/projects/integrations/user_activates_mattermost_slash_command_spec.rb
index 07cb138c414..c2370f38faa 100644
--- a/spec/features/projects/integrations/user_activates_mattermost_slash_command_spec.rb
+++ b/spec/features/projects/integrations/user_activates_mattermost_slash_command_spec.rb
@@ -79,7 +79,7 @@ RSpec.describe 'Set up Mattermost slash commands', :js, feature_category: :integ
select_element = find('#mattermost_team_id')
- expect(select_element['disabled']).to be_falsey
+ expect(select_element['disabled']).to eq('false')
expect(select_element.all('option').count).to eq(3)
end
diff --git a/spec/features/projects/new_project_spec.rb b/spec/features/projects/new_project_spec.rb
index b87f8ab667f..12a97dee710 100644
--- a/spec/features/projects/new_project_spec.rb
+++ b/spec/features/projects/new_project_spec.rb
@@ -85,7 +85,6 @@ RSpec.describe 'New project', :js, feature_category: :projects do
expect(page).to have_link('GitHub')
expect(page).to have_link('Bitbucket')
- expect(page).to have_link('GitLab.com')
expect(page).to have_button('Repository by URL')
expect(page).to have_link('GitLab export')
end
@@ -136,7 +135,6 @@ RSpec.describe 'New project', :js, feature_category: :projects do
'github': :new_import_github_path,
'bitbucket': :status_import_bitbucket_path,
'bitbucket server': :status_import_bitbucket_server_path,
- 'gitlab.com': :status_import_gitlab_path,
'fogbugz': :new_import_fogbugz_path,
'gitea': :new_import_gitea_path,
'manifest': :new_import_manifest_path
@@ -572,25 +570,6 @@ RSpec.describe 'New project', :js, feature_category: :projects do
end
end
- context 'from GitLab.com', :js do
- let(:target_link) { 'GitLab.com' }
- let(:provider) { :gitlab }
-
- context 'as a user' do
- let(:user) { create(:user) }
- let(:oauth_config_instructions) { 'To enable importing projects from GitLab.com, ask your GitLab administrator to configure OAuth integration' }
-
- it_behaves_like 'has instructions to enable OAuth'
- end
-
- context 'as an admin', :do_not_mock_admin_mode_setting do
- let(:user) { create(:admin) }
- let(:oauth_config_instructions) { 'To enable importing projects from GitLab.com, as administrator you need to configure OAuth integration' }
-
- it_behaves_like 'has instructions to enable OAuth'
- end
- end
-
describe 'sidebar' do
let_it_be(:user) { create(:user) }
let_it_be(:parent_group) { create(:group) }
diff --git a/spec/frontend/lib/utils/datetime/date_format_utility_spec.js b/spec/frontend/lib/utils/datetime/date_format_utility_spec.js
index 6b515e9f96a..e7a6367eeac 100644
--- a/spec/frontend/lib/utils/datetime/date_format_utility_spec.js
+++ b/spec/frontend/lib/utils/datetime/date_format_utility_spec.js
@@ -134,23 +134,6 @@ describe('formatTimeAsSummary', () => {
});
});
-describe('durationTimeFormatted', () => {
- it.each`
- duration | expectedOutput
- ${0} | ${'00:00:00'}
- ${12} | ${'00:00:12'}
- ${60} | ${'00:01:00'}
- ${60 + 27} | ${'00:01:27'}
- ${120 + 21} | ${'00:02:21'}
- ${4 * 60 * 60 + 25 * 60 + 37} | ${'04:25:37'}
- ${35 * 60 * 60 + 3 * 60 + 7} | ${'35:03:07'}
- ${-60} | ${'-00:01:00'}
- ${-(35 * 60 * 60 + 3 * 60 + 7)} | ${'-35:03:07'}
- `('returns $expectedOutput when provided $duration', ({ duration, expectedOutput }) => {
- expect(utils.durationTimeFormatted(duration)).toBe(expectedOutput);
- });
-});
-
describe('formatUtcOffset', () => {
it.each`
offset | expected
diff --git a/spec/frontend/lib/utils/datetime_utility_spec.js b/spec/frontend/lib/utils/datetime_utility_spec.js
index 8d989350173..330bfca7029 100644
--- a/spec/frontend/lib/utils/datetime_utility_spec.js
+++ b/spec/frontend/lib/utils/datetime_utility_spec.js
@@ -276,19 +276,35 @@ describe('getTimeframeWindowFrom', () => {
});
describe('formatTime', () => {
- const expectedTimestamps = [
- [0, '00:00:00'],
- [1000, '00:00:01'],
- [42000, '00:00:42'],
- [121000, '00:02:01'],
- [10921000, '03:02:01'],
- [108000000, '30:00:00'],
- ];
+ it.each`
+ milliseconds | expected
+ ${0} | ${'00:00:00'}
+ ${1} | ${'00:00:00'}
+ ${499} | ${'00:00:00'}
+ ${500} | ${'00:00:01'}
+ ${1000} | ${'00:00:01'}
+ ${42 * 1000} | ${'00:00:42'}
+ ${60 * 1000} | ${'00:01:00'}
+ ${(60 + 1) * 1000} | ${'00:01:01'}
+ ${(3 * 60 * 60 + 2 * 60 + 1) * 1000} | ${'03:02:01'}
+ ${(11 * 60 * 60 + 59 * 60 + 59) * 1000} | ${'11:59:59'}
+ ${30 * 60 * 60 * 1000} | ${'30:00:00'}
+ ${(35 * 60 * 60 + 3 * 60 + 7) * 1000} | ${'35:03:07'}
+ ${240 * 60 * 60 * 1000} | ${'240:00:00'}
+ ${1000 * 60 * 60 * 1000} | ${'1000:00:00'}
+ `(`formats $milliseconds ms as $expected`, ({ milliseconds, expected }) => {
+ expect(datetimeUtility.formatTime(milliseconds)).toBe(expected);
+ });
- expectedTimestamps.forEach(([milliseconds, expectedTimestamp]) => {
- it(`formats ${milliseconds}ms as ${expectedTimestamp}`, () => {
- expect(datetimeUtility.formatTime(milliseconds)).toBe(expectedTimestamp);
- });
+ it.each`
+ milliseconds | expected
+ ${-1} | ${'00:00:00'}
+ ${-499} | ${'00:00:00'}
+ ${-1000} | ${'-00:00:01'}
+ ${-60 * 1000} | ${'-00:01:00'}
+ ${-(35 * 60 * 60 + 3 * 60 + 7) * 1000} | ${'-35:03:07'}
+ `(`when negative, formats $milliseconds ms as $expected`, ({ milliseconds, expected }) => {
+ expect(datetimeUtility.formatTime(milliseconds)).toBe(expected);
});
});
diff --git a/spec/lib/gitlab/gitlab_import/client_spec.rb b/spec/lib/gitlab/gitlab_import/client_spec.rb
deleted file mode 100644
index 7f57d5fbf1b..00000000000
--- a/spec/lib/gitlab/gitlab_import/client_spec.rb
+++ /dev/null
@@ -1,111 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::GitlabImport::Client do
- include ImportSpecHelper
-
- let(:token) { '123456' }
- let(:client) { described_class.new(token) }
-
- before do
- stub_omniauth_provider('gitlab')
- end
-
- it 'all OAuth2 client options are symbols' do
- expect(client.client.options.keys).to all(be_kind_of(Symbol))
- end
-
- it 'uses membership and simple flags' do
- stub_request('/api/v4/projects?membership=true&page=1&per_page=100&simple=true')
-
- expect_next_instance_of(OAuth2::Response) do |instance|
- expect(instance).to receive(:parsed).and_return([])
- end
-
- expect(client.projects.to_a).to eq []
- end
-
- shared_examples 'pagination params' do
- before do
- allow_next_instance_of(OAuth2::Response) do |instance|
- allow(instance).to receive(:parsed).and_return([])
- end
- end
-
- it 'allows page_limit param' do
- allow_next_instance_of(OAuth2::Response) do |instance|
- allow(instance).to receive(:parsed).and_return(element_list)
- end
-
- expect(client).to receive(:lazy_page_iterator).with(hash_including(page_limit: 2)).and_call_original
-
- client.send(method, *args, page_limit: 2, per_page: 1).to_a
- end
-
- it 'allows per_page param' do
- expect(client).to receive(:lazy_page_iterator).with(hash_including(per_page: 2)).and_call_original
-
- client.send(method, *args, per_page: 2).to_a
- end
-
- it 'allows starting_page param' do
- expect(client).to receive(:lazy_page_iterator).with(hash_including(starting_page: 3)).and_call_original
-
- client.send(method, *args, starting_page: 3).to_a
- end
- end
-
- describe '#projects' do
- subject(:method) { :projects }
-
- let(:args) { [] }
- let(:element_list) { build_list(:project, 2) }
-
- before do
- stub_request('/api/v4/projects?membership=true&page=1&per_page=1&simple=true')
- stub_request('/api/v4/projects?membership=true&page=2&per_page=1&simple=true')
- stub_request('/api/v4/projects?membership=true&page=1&per_page=2&simple=true')
- stub_request('/api/v4/projects?membership=true&page=3&per_page=100&simple=true')
- end
-
- it_behaves_like 'pagination params'
- end
-
- describe '#issues' do
- subject(:method) { :issues }
-
- let(:args) { [1] }
- let(:element_list) { build_list(:issue, 2) }
-
- before do
- stub_request('/api/v4/projects/1/issues?page=1&per_page=1')
- stub_request('/api/v4/projects/1/issues?page=2&per_page=1')
- stub_request('/api/v4/projects/1/issues?page=1&per_page=2')
- stub_request('/api/v4/projects/1/issues?page=3&per_page=100')
- end
-
- it_behaves_like 'pagination params'
- end
-
- describe '#issue_comments' do
- subject(:method) { :issue_comments }
-
- let(:args) { [1, 1] }
- let(:element_list) { build_list(:note_on_issue, 2) }
-
- before do
- stub_request('/api/v4/projects/1/issues/1/notes?page=1&per_page=1')
- stub_request('/api/v4/projects/1/issues/1/notes?page=2&per_page=1')
- stub_request('/api/v4/projects/1/issues/1/notes?page=1&per_page=2')
- stub_request('/api/v4/projects/1/issues/1/notes?page=3&per_page=100')
- end
-
- it_behaves_like 'pagination params'
- end
-
- def stub_request(path)
- WebMock.stub_request(:get, "https://gitlab.com#{path}")
- .to_return(status: 200)
- end
-end
diff --git a/spec/lib/gitlab/gitlab_import/importer_spec.rb b/spec/lib/gitlab/gitlab_import/importer_spec.rb
deleted file mode 100644
index 984c690add6..00000000000
--- a/spec/lib/gitlab/gitlab_import/importer_spec.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::GitlabImport::Importer do
- include ImportSpecHelper
-
- describe '#execute' do
- before do
- stub_omniauth_provider('gitlab')
- stub_request('issues', [
- {
- 'id' => 2579857,
- 'iid' => 3,
- 'title' => 'Issue',
- 'description' => 'Lorem ipsum',
- 'state' => 'opened',
- 'confidential' => true,
- 'author' => {
- 'id' => 283999,
- 'name' => 'John Doe'
- }
- }
- ].to_json)
- stub_request('issues/3/notes', [].to_json)
- end
-
- it 'persists issues' do
- project = create(:project, import_source: 'asd/vim')
- project.build_import_data(credentials: { password: 'password' })
-
- subject = described_class.new(project)
- subject.execute
-
- expected_attributes = {
- iid: 3,
- title: 'Issue',
- description: "*Created by: John Doe*\n\nLorem ipsum",
- state: 'opened',
- confidential: true,
- author_id: project.creator_id
- }
-
- expect(project.issues.first).to have_attributes(expected_attributes)
- end
-
- def stub_request(path, body)
- url = "https://gitlab.com/api/v4/projects/asd%2Fvim/#{path}?page=1&per_page=100"
-
- WebMock.stub_request(:get, url)
- .to_return(
- headers: { 'Content-Type' => 'application/json' },
- body: body
- )
- end
- end
-end
diff --git a/spec/lib/gitlab/gitlab_import/project_creator_spec.rb b/spec/lib/gitlab/gitlab_import/project_creator_spec.rb
deleted file mode 100644
index 59a98987f7d..00000000000
--- a/spec/lib/gitlab/gitlab_import/project_creator_spec.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::GitlabImport::ProjectCreator do
- let(:user) { create(:user) }
- let(:repo) do
- {
- name: 'vim',
- path: 'vim',
- visibility_level: Gitlab::VisibilityLevel::PRIVATE,
- path_with_namespace: 'asd/vim',
- http_url_to_repo: "https://gitlab.com/asd/vim.git",
- owner: { name: "john" }
- }.with_indifferent_access
- end
-
- let(:namespace) { create(:group) }
- let(:token) { "asdffg" }
- let(:access_params) { { gitlab_access_token: token } }
-
- before do
- namespace.add_owner(user)
- end
-
- it 'creates project' do
- allow_next_instance_of(Project) do |project|
- allow(project).to receive(:add_import_job)
- end
-
- project_creator = described_class.new(repo, namespace, user, access_params)
- project = project_creator.execute
-
- expect(project.import_url).to eq("https://oauth2:asdffg@gitlab.com/asd/vim.git")
- expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE)
- end
-end
diff --git a/spec/lib/gitlab/import_sources_spec.rb b/spec/lib/gitlab/import_sources_spec.rb
index 16d22dab5bb..f1ea5f3e85e 100644
--- a/spec/lib/gitlab/import_sources_spec.rb
+++ b/spec/lib/gitlab/import_sources_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Gitlab::ImportSources do
+RSpec.describe Gitlab::ImportSources, feature_category: :importers do
describe '.options' do
it 'returns a hash' do
expected =
@@ -10,7 +10,6 @@ RSpec.describe Gitlab::ImportSources do
'GitHub' => 'github',
'Bitbucket Cloud' => 'bitbucket',
'Bitbucket Server' => 'bitbucket_server',
- 'GitLab.com' => 'gitlab',
'FogBugz' => 'fogbugz',
'Repository by URL' => 'git',
'GitLab export' => 'gitlab_project',
@@ -29,7 +28,6 @@ RSpec.describe Gitlab::ImportSources do
github
bitbucket
bitbucket_server
- gitlab
fogbugz
git
gitlab_project
@@ -48,7 +46,6 @@ RSpec.describe Gitlab::ImportSources do
github
bitbucket
bitbucket_server
- gitlab
fogbugz
gitlab_project
gitea
@@ -63,7 +60,6 @@ RSpec.describe Gitlab::ImportSources do
'github' => Gitlab::GithubImport::ParallelImporter,
'bitbucket' => Gitlab::BitbucketImport::Importer,
'bitbucket_server' => Gitlab::BitbucketServerImport::Importer,
- 'gitlab' => Gitlab::GitlabImport::Importer,
'fogbugz' => Gitlab::FogbugzImport::Importer,
'git' => nil,
'gitlab_project' => Gitlab::ImportExport::Importer,
@@ -83,7 +79,6 @@ RSpec.describe Gitlab::ImportSources do
'github' => 'GitHub',
'bitbucket' => 'Bitbucket Cloud',
'bitbucket_server' => 'Bitbucket Server',
- 'gitlab' => 'GitLab.com',
'fogbugz' => 'FogBugz',
'git' => 'Repository by URL',
'gitlab_project' => 'GitLab export',
diff --git a/spec/lib/gitlab/kas/client_spec.rb b/spec/lib/gitlab/kas/client_spec.rb
index 9a0fa6c4067..5668c265611 100644
--- a/spec/lib/gitlab/kas/client_spec.rb
+++ b/spec/lib/gitlab/kas/client_spec.rb
@@ -109,6 +109,35 @@ RSpec.describe Gitlab::Kas::Client do
it { expect(subject).to eq(agent_configurations) }
end
+ describe '#send_git_push_event' do
+ let(:stub) { instance_double(Gitlab::Agent::Notifications::Rpc::Notifications::Stub) }
+ let(:request) { instance_double(Gitlab::Agent::Notifications::Rpc::GitPushEventRequest) }
+ let(:project_param) { instance_double(Gitlab::Agent::Notifications::Rpc::Project) }
+ let(:response) { double(Gitlab::Agent::Notifications::Rpc::GitPushEventResponse) }
+
+ subject { described_class.new.send_git_push_event(project: project) }
+
+ before do
+ expect(Gitlab::Agent::Notifications::Rpc::Notifications::Stub).to receive(:new)
+ .with('example.kas.internal', :this_channel_is_insecure, timeout: described_class::TIMEOUT)
+ .and_return(stub)
+
+ expect(Gitlab::Agent::Notifications::Rpc::Project).to receive(:new)
+ .with(id: project.id, full_path: project.full_path)
+ .and_return(project_param)
+
+ expect(Gitlab::Agent::Notifications::Rpc::GitPushEventRequest).to receive(:new)
+ .with(project: project_param)
+ .and_return(request)
+
+ expect(stub).to receive(:git_push_event)
+ .with(request, metadata: { 'authorization' => 'bearer test-token' })
+ .and_return(response)
+ end
+
+ it { expect(subject).to eq(response) }
+ end
+
describe 'with grpcs' do
let(:stub) { instance_double(Gitlab::Agent::ConfigurationProject::Rpc::ConfigurationProject::Stub) }
let(:credentials) { instance_double(GRPC::Core::ChannelCredentials) }
diff --git a/spec/lib/gitlab/redis/cache_spec.rb b/spec/lib/gitlab/redis/cache_spec.rb
index b7b4ba0eb2f..30770a47b84 100644
--- a/spec/lib/gitlab/redis/cache_spec.rb
+++ b/spec/lib/gitlab/redis/cache_spec.rb
@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe Gitlab::Redis::Cache do
let(:instance_specific_config_file) { "config/redis.cache.yml" }
+ let(:environment_config_file_name) { "GITLAB_REDIS_CACHE_CONFIG_FILE" }
include_examples "redis_shared_examples"
diff --git a/spec/lib/gitlab/redis/queues_spec.rb b/spec/lib/gitlab/redis/queues_spec.rb
index 62b30431f6f..ec324f86cab 100644
--- a/spec/lib/gitlab/redis/queues_spec.rb
+++ b/spec/lib/gitlab/redis/queues_spec.rb
@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe Gitlab::Redis::Queues do
let(:instance_specific_config_file) { "config/redis.queues.yml" }
+ let(:environment_config_file_name) { "GITLAB_REDIS_QUEUES_CONFIG_FILE" }
include_examples "redis_shared_examples"
diff --git a/spec/lib/gitlab/redis/shared_state_spec.rb b/spec/lib/gitlab/redis/shared_state_spec.rb
index a5247903d50..76b60440b2c 100644
--- a/spec/lib/gitlab/redis/shared_state_spec.rb
+++ b/spec/lib/gitlab/redis/shared_state_spec.rb
@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe Gitlab::Redis::SharedState do
let(:instance_specific_config_file) { "config/redis.shared_state.yml" }
+ let(:environment_config_file_name) { "GITLAB_REDIS_SHARED_STATE_CONFIG_FILE" }
include_examples "redis_shared_examples"
end
diff --git a/spec/lib/gitlab/redis/sidekiq_status_spec.rb b/spec/lib/gitlab/redis/sidekiq_status_spec.rb
index 45578030ca8..cbd2c05ce23 100644
--- a/spec/lib/gitlab/redis/sidekiq_status_spec.rb
+++ b/spec/lib/gitlab/redis/sidekiq_status_spec.rb
@@ -7,6 +7,7 @@ RSpec.describe Gitlab::Redis::SidekiqStatus do
# to move away from `Sidekiq.redis` for sidekiq status data. Thus, we use the
# same store configuration as the former.
let(:instance_specific_config_file) { "config/redis.shared_state.yml" }
+ let(:environment_config_file_name) { "GITLAB_REDIS_SHARED_STATE_CONFIG_FILE" }
include_examples "redis_shared_examples"
diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb
index e0640f10a03..a35c9c5e526 100644
--- a/spec/lib/gitlab/usage_data_spec.rb
+++ b/spec/lib/gitlab/usage_data_spec.rb
@@ -263,7 +263,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures, feature_category: :servic
for_defined_days_back do
user = create(:user)
- %w(gitlab_project gitlab github bitbucket bitbucket_server gitea git manifest fogbugz).each do |type|
+ %w(gitlab_project github bitbucket bitbucket_server gitea git manifest fogbugz).each do |type|
create(:project, import_type: type, creator_id: user.id)
end
@@ -292,11 +292,10 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures, feature_category: :servic
git: 2,
gitea: 2,
github: 2,
- gitlab: 2,
gitlab_migration: 2,
gitlab_project: 2,
manifest: 2,
- total: 18
+ total: 16
},
issue_imports: {
jira: 2,
@@ -320,11 +319,10 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures, feature_category: :servic
git: 1,
gitea: 1,
github: 1,
- gitlab: 1,
gitlab_migration: 1,
gitlab_project: 1,
manifest: 1,
- total: 9
+ total: 8
},
issue_imports: {
jira: 1,
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb
index 288eedffe1c..9f292b0a294 100644
--- a/spec/models/application_setting_spec.rb
+++ b/spec/models/application_setting_spec.rb
@@ -334,7 +334,7 @@ RSpec.describe ApplicationSetting, feature_category: :shared, type: :model do
it 'removes phabricator as an import source' do
subject.validate
- expect(subject.import_sources).to eq(%w[github bitbucket gitlab git gitlab_project gitea manifest])
+ expect(subject.import_sources).to eq(%w[github bitbucket git gitlab_project gitea manifest])
end
end
diff --git a/spec/routing/import_routing_spec.rb b/spec/routing/import_routing_spec.rb
index cdc266437e8..8254d79e994 100644
--- a/spec/routing/import_routing_spec.rb
+++ b/spec/routing/import_routing_spec.rb
@@ -62,7 +62,7 @@ end
# realtime_changes_import_github GET /import/github/realtime_changes(.:format) import/github#jobs
# import_github POST /import/github(.:format) import/github#create
# new_import_github GET /import/github/new(.:format) import/github#new
-RSpec.describe Import::GithubController, 'routing' do
+RSpec.describe Import::GithubController, 'routing', feature_category: :importers do
it_behaves_like 'importer routing' do
let(:provider) { 'github' }
let(:is_realtime) { true }
@@ -86,7 +86,7 @@ end
# realtime_changes_import_gitea GET /import/gitea/realtime_changes(.:format) import/gitea#jobs
# import_gitea POST /import/gitea(.:format) import/gitea#create
# new_import_gitea GET /import/gitea/new(.:format) import/gitea#new
-RSpec.describe Import::GiteaController, 'routing' do
+RSpec.describe Import::GiteaController, 'routing', feature_category: :importers do
it_behaves_like 'importer routing' do
let(:except_actions) { [:callback] }
let(:provider) { 'gitea' }
@@ -98,23 +98,11 @@ RSpec.describe Import::GiteaController, 'routing' do
end
end
-# status_import_gitlab GET /import/gitlab/status(.:format) import/gitlab#status
-# callback_import_gitlab GET /import/gitlab/callback(.:format) import/gitlab#callback
-# realtime_changes_import_gitlab GET /import/gitlab/realtime_changes(.:format) import/gitlab#realtime_changes
-# import_gitlab POST /import/gitlab(.:format) import/gitlab#create
-RSpec.describe Import::GitlabController, 'routing' do
- it_behaves_like 'importer routing' do
- let(:except_actions) { [:new] }
- let(:provider) { 'gitlab' }
- let(:is_realtime) { true }
- end
-end
-
# status_import_bitbucket GET /import/bitbucket/status(.:format) import/bitbucket#status
# callback_import_bitbucket GET /import/bitbucket/callback(.:format) import/bitbucket#callback
# realtime_changes_import_bitbucket GET /import/bitbucket/realtime_changes(.:format) import/bitbucket#realtime_changes
# import_bitbucket POST /import/bitbucket(.:format) import/bitbucket#create
-RSpec.describe Import::BitbucketController, 'routing' do
+RSpec.describe Import::BitbucketController, 'routing', feature_category: :importers do
it_behaves_like 'importer routing' do
let(:except_actions) { [:new] }
let(:provider) { 'bitbucket' }
@@ -127,7 +115,7 @@ end
# realtime_changes_import_bitbucket_server GET /import/bitbucket_server/realtime_changes(.:format) import/bitbucket_server#realtime_changes
# new_import_bitbucket_server GET /import/bitbucket_server/new(.:format) import/bitbucket_server#new
# import_bitbucket_server POST /import/bitbucket_server(.:format) import/bitbucket_server#create
-RSpec.describe Import::BitbucketServerController, 'routing' do
+RSpec.describe Import::BitbucketServerController, 'routing', feature_category: :importers do
it_behaves_like 'importer routing' do
let(:provider) { 'bitbucket_server' }
let(:is_realtime) { true }
@@ -141,7 +129,7 @@ end
# create_user_map_import_fogbugz POST /import/fogbugz/user_map(.:format) import/fogbugz#create_user_map
# import_fogbugz POST /import/fogbugz(.:format) import/fogbugz#create
# new_import_fogbugz GET /import/fogbugz/new(.:format) import/fogbugz#new
-RSpec.describe Import::FogbugzController, 'routing' do
+RSpec.describe Import::FogbugzController, 'routing', feature_category: :importers do
it_behaves_like 'importer routing' do
let(:except_actions) { [:callback] }
let(:provider) { 'fogbugz' }
@@ -164,7 +152,7 @@ end
# import_gitlab_project POST /import/gitlab_project(.:format) import/gitlab_projects#create
# POST /import/gitlab_project(.:format) import/gitlab_projects#create
# new_import_gitlab_project GET /import/gitlab_project/new(.:format) import/gitlab_projects#new
-RSpec.describe Import::GitlabProjectsController, 'routing' do
+RSpec.describe Import::GitlabProjectsController, 'routing', feature_category: :importers do
it 'to #create' do
expect(post('/import/gitlab_project')).to route_to('import/gitlab_projects#create')
end
@@ -175,7 +163,7 @@ RSpec.describe Import::GitlabProjectsController, 'routing' do
end
# status_import_github_group GET /import/github_group/status(.:format) import/github_groups#status
-RSpec.describe Import::GithubGroupsController, 'routing' do
+RSpec.describe Import::GithubGroupsController, 'routing', feature_category: :importers do
it 'to #status' do
expect(get('/import/github_group/status')).to route_to('import/github_groups#status')
end
diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb
index f06a8cfe937..d909a190d19 100644
--- a/spec/support/capybara.rb
+++ b/spec/support/capybara.rb
@@ -24,7 +24,15 @@ JS_CONSOLE_FILTER = Regexp.union(
'Download the Vue Devtools extension',
'Download the Apollo DevTools',
"Unrecognized feature: 'interest-cohort'",
- 'Does this page need fixes or improvements?'
+ 'Does this page need fixes or improvements?',
+
+ # Needed after https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60933
+ # which opts out gitlab from FloC by default
+ # see https://web.dev/floc/ for more info on FloC
+ "Origin trial controlled feature not enabled: 'interest-cohort'",
+
+ # ERR_CONNECTION error could happen due to automated test session disabling browser network request
+ 'net::ERR_CONNECTION'
]
)
@@ -34,6 +42,9 @@ SCREENSHOT_FILENAME_LENGTH = ENV['CI'] || ENV['CI_SERVER'] ? 255 : 99
@blackhole_tcp_server = nil
+chrome_options = Selenium::WebDriver::Chrome::Options.chrome
+chromedriver_path = File.dirname(Selenium::WebDriver::SeleniumManager.driver_path(chrome_options))
+
# Run Workhorse on the given host and port, proxying to Puma on a UNIX socket,
# for a closer-to-production experience
Capybara.register_server :puma_via_workhorse do |app, port, host, **options|
@@ -42,21 +53,14 @@ Capybara.register_server :puma_via_workhorse do |app, port, host, **options|
file.close! # We just want the filename
TestEnv.with_workhorse(host, port, socket_path) do
+ # In cases of multiple installations of chromedriver, prioritize the version installed by SeleniumManager
+ ENV['PATH'] = "#{chromedriver_path}:#{ENV['PATH']}" # rubocop:disable RSpec/EnvAssignment
+
Capybara.servers[:puma].call(app, nil, socket_path, **options)
end
end
Capybara.register_driver :chrome do |app|
- capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
- # This enables access to logs with `page.driver.manage.get_log(:browser)`
- loggingPrefs: {
- browser: "ALL",
- client: "ALL",
- driver: "ALL",
- server: "ALL"
- }
- )
-
options = Selenium::WebDriver::Chrome::Options.new
# Force the browser's scale factor to prevent inconsistencies on high-res devices
@@ -82,9 +86,6 @@ Capybara.register_driver :chrome do |app|
options.add_preference("download.prompt_for_download", false)
end
- # Chrome 75 defaults to W3C mode which doesn't allow console log access
- options.add_option(:w3c, false)
-
# Set up a proxy server to block all external traffic.
@blackhole_tcp_server = TCPServer.new(0)
Thread.new do
@@ -99,18 +100,11 @@ Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
- desired_capabilities: capabilities,
options: options
)
end
Capybara.register_driver :firefox do |app|
- capabilities = Selenium::WebDriver::Remote::Capabilities.firefox(
- log: {
- level: :trace
- }
- )
-
options = Selenium::WebDriver::Firefox::Options.new(log_level: :trace)
options.add_argument("--window-size=#{CAPYBARA_WINDOW_SIZE.join(',')}")
@@ -121,7 +115,6 @@ Capybara.register_driver :firefox do |app|
Capybara::Selenium::Driver.new(
app,
browser: :firefox,
- desired_capabilities: capabilities,
options: options
)
end
@@ -213,20 +206,11 @@ RSpec.configure do |config|
# fixed. If we raised the `JSException` the fixed test would be marked as
# failed again.
if example.exception && !example.exception.is_a?(RSpec::Core::Pending::PendingExampleFixedError)
- begin
- console = page.driver.browser.manage.logs.get(:browser)&.reject { |log| log.message =~ JS_CONSOLE_FILTER }
-
- if console.present?
- message = "Unexpected browser console output:\n" + console.map(&:message).join("\n")
- raise JSConsoleError, message
- end
- rescue Selenium::WebDriver::Error::WebDriverError => error
- if error.message =~ %r{unknown command: session/[0-9a-zA-Z]+(?:/se)?/log}
- message = "Unable to access Chrome javascript console logs. You may be using an outdated version of ChromeDriver."
- raise JSConsoleError, message
- else
- raise error
- end
+ console = page.driver.browser.logs.get(:browser)&.reject { |log| log.message =~ JS_CONSOLE_FILTER }
+
+ if console.present?
+ message = "Unexpected browser console output:\n" + console.map(&:message).join("\n")
+ raise JSConsoleError, message
end
end
diff --git a/spec/support/rspec_order_todo.yml b/spec/support/rspec_order_todo.yml
index 7d7b05b4ecb..7346ba59cbe 100644
--- a/spec/support/rspec_order_todo.yml
+++ b/spec/support/rspec_order_todo.yml
@@ -6468,9 +6468,6 @@
- './spec/lib/gitlab/github_import_spec.rb'
- './spec/lib/gitlab/github_import/user_finder_spec.rb'
- './spec/lib/gitlab/git/keep_around_spec.rb'
-- './spec/lib/gitlab/gitlab_import/client_spec.rb'
-- './spec/lib/gitlab/gitlab_import/importer_spec.rb'
-- './spec/lib/gitlab/gitlab_import/project_creator_spec.rb'
- './spec/lib/gitlab/git/lfs_changes_spec.rb'
- './spec/lib/gitlab/git/lfs_pointer_file_spec.rb'
- './spec/lib/gitlab/git/merge_base_spec.rb'
@@ -7002,6 +6999,7 @@
- './spec/lib/gitlab/sidekiq_config/worker_matcher_spec.rb'
- './spec/lib/gitlab/sidekiq_config/worker_router_spec.rb'
- './spec/lib/gitlab/sidekiq_config/worker_spec.rb'
+- './spec/lib/gitlab/sidekiq_daemon/memory_killer_spec.rb'
- './spec/lib/gitlab/sidekiq_daemon/monitor_spec.rb'
- './spec/lib/gitlab/sidekiq_death_handler_spec.rb'
- './spec/lib/gitlab/sidekiq_logging/deduplication_logger_spec.rb'
diff --git a/spec/support/shared_examples/features/content_editor_shared_examples.rb b/spec/support/shared_examples/features/content_editor_shared_examples.rb
index 8b97797038d..c3ef4e8afb7 100644
--- a/spec/support/shared_examples/features/content_editor_shared_examples.rb
+++ b/spec/support/shared_examples/features/content_editor_shared_examples.rb
@@ -22,7 +22,6 @@ RSpec.shared_examples 'edits content using the content editor' do
begin
refresh
rescue Selenium::WebDriver::Error::UnexpectedAlertOpenError
- page.driver.browser.switch_to.alert.dismiss
end
expect(page).to have_text('Typing text in the content editor')
diff --git a/spec/support/shared_examples/redis/redis_new_instance_shared_examples.rb b/spec/support/shared_examples/redis/redis_new_instance_shared_examples.rb
index 4a3732efe13..4c3aad95a56 100644
--- a/spec/support/shared_examples/redis/redis_new_instance_shared_examples.rb
+++ b/spec/support/shared_examples/redis/redis_new_instance_shared_examples.rb
@@ -6,6 +6,7 @@ RSpec.shared_examples "redis_new_instance_shared_examples" do |name, fallback_cl
include TmpdirHelper
let(:instance_specific_config_file) { "config/redis.#{name}.yml" }
+ let(:environment_config_file_name) { "GITLAB_REDIS_#{name.upcase}_CONFIG_FILE" }
let(:fallback_config_file) { nil }
let(:rails_root) { mktmpdir }
@@ -15,6 +16,32 @@ RSpec.shared_examples "redis_new_instance_shared_examples" do |name, fallback_cl
it_behaves_like "redis_shared_examples"
+ describe '.config_file_name' do
+ subject { described_class.config_file_name }
+
+ before do
+ # Undo top-level stub of config_file_name because we are testing that method now.
+ allow(described_class).to receive(:config_file_name).and_call_original
+
+ allow(described_class).to receive(:rails_root).and_return(rails_root)
+ FileUtils.mkdir_p(File.join(rails_root, 'config'))
+ end
+
+ context 'and there is a global env override' do
+ before do
+ stub_env('GITLAB_REDIS_CONFIG_FILE', 'global override')
+ end
+
+ it { expect(subject).to eq('global override') }
+
+ context "and #{fallback_class.name.demodulize} has a different config file" do
+ let(:fallback_config_file) { 'fallback config file' }
+
+ it { expect(subject).to eq('fallback config file') }
+ end
+ end
+ end
+
describe '#fetch_config' do
subject { described_class.new('test').send(:fetch_config) }
diff --git a/spec/support/shared_examples/redis/redis_shared_examples.rb b/spec/support/shared_examples/redis/redis_shared_examples.rb
index 9224e01b1fe..7cd41390bf4 100644
--- a/spec/support/shared_examples/redis/redis_shared_examples.rb
+++ b/spec/support/shared_examples/redis/redis_shared_examples.rb
@@ -39,6 +39,34 @@ RSpec.shared_examples "redis_shared_examples" do
context 'when there is no config file anywhere' do
it { expect(subject).to be_nil }
+
+ context 'and there is a global env override' do
+ before do
+ stub_env('GITLAB_REDIS_CONFIG_FILE', 'global override')
+ end
+
+ it { expect(subject).to eq('global override') }
+
+ context 'and there is an instance specific config file' do
+ before do
+ FileUtils.touch(File.join(rails_root, instance_specific_config_file))
+ end
+
+ it { expect(subject).to eq("#{rails_root}/#{instance_specific_config_file}") }
+
+ it 'returns a path that exists' do
+ expect(File.file?(subject)).to eq(true)
+ end
+
+ context 'and there is a specific env override' do
+ before do
+ stub_env(environment_config_file_name, 'instance specific override')
+ end
+
+ it { expect(subject).to eq('instance specific override') }
+ end
+ end
+ end
end
end
diff --git a/spec/tooling/danger/database_dictionary_spec.rb b/spec/tooling/danger/database_dictionary_spec.rb
new file mode 100644
index 00000000000..1a771a6cec0
--- /dev/null
+++ b/spec/tooling/danger/database_dictionary_spec.rb
@@ -0,0 +1,152 @@
+# frozen_string_literal: true
+
+require 'gitlab-dangerfiles'
+require 'gitlab/dangerfiles/spec_helper'
+
+require_relative '../../../tooling/danger/database_dictionary'
+
+RSpec.describe Tooling::Danger::DatabaseDictionary, feature_category: :shared do
+ include_context "with dangerfile"
+
+ let(:fake_danger) { DangerSpecHelper.fake_danger.include(described_class) }
+
+ subject(:database_dictionary) { fake_danger.new(helper: fake_helper) }
+
+ describe '#database_dictionary_files' do
+ let(:database_dictionary_files) do
+ [
+ 'db/docs/ci_pipelines.yml',
+ 'db/docs/projects.yml'
+ ]
+ end
+
+ let(:other_files) do
+ [
+ 'app/models/model.rb',
+ 'app/assets/javascripts/file.js'
+ ]
+ end
+
+ shared_examples 'an array of Found objects' do |change_type|
+ it 'returns an array of Found objects' do
+ expect(database_dictionary.database_dictionary_files(change_type: change_type))
+ .to contain_exactly(
+ an_instance_of(described_class::Found),
+ an_instance_of(described_class::Found)
+ )
+
+ expect(database_dictionary.database_dictionary_files(change_type: change_type).map(&:path))
+ .to eq(database_dictionary_files)
+ end
+ end
+
+ shared_examples 'an empty array' do |change_type|
+ it 'returns an array of Found objects' do
+ expect(database_dictionary.database_dictionary_files(change_type: change_type)).to be_empty
+ end
+ end
+
+ describe 'retrieves added database dictionary files' do
+ context 'with added added database dictionary files' do
+ let(:added_files) { database_dictionary_files }
+
+ include_examples 'an array of Found objects', :added
+ end
+
+ context 'without added added database dictionary files' do
+ let(:added_files) { other_files }
+
+ include_examples 'an empty array', :added
+ end
+ end
+
+ describe 'retrieves modified database dictionary files' do
+ context 'with modified modified database dictionary files' do
+ let(:modified_files) { database_dictionary_files }
+
+ include_examples 'an array of Found objects', :modified
+ end
+
+ context 'without modified modified database dictionary files' do
+ let(:modified_files) { other_files }
+
+ include_examples 'an empty array', :modified
+ end
+ end
+
+ describe 'retrieves deleted database dictionary files' do
+ context 'with deleted deleted database dictionary files' do
+ let(:deleted_files) { database_dictionary_files }
+
+ include_examples 'an array of Found objects', :deleted
+ end
+
+ context 'without deleted deleted database dictionary files' do
+ let(:deleted_files) { other_files }
+
+ include_examples 'an empty array', :deleted
+ end
+ end
+ end
+
+ describe described_class::Found do
+ let(:database_dictionary_path) { 'db/docs/ci_pipelines.yml' }
+ let(:gitlab_schema) { 'gitlab_ci' }
+
+ let(:yaml) do
+ {
+
+ 'table_name' => 'ci_pipelines',
+ 'classes' => ['Ci::Pipeline'],
+ 'feature_categories' => ['continuous_integration'],
+ 'description' => 'TODO',
+ 'introduced_by_url' => 'https://gitlab.com/gitlab-org/gitlab/-/commit/c6ae290cea4b88ecaa9cfe0bc9d88e8fd32070c1',
+ 'milestone' => '9.0',
+ 'gitlab_schema' => gitlab_schema
+ }
+ end
+
+ let(:raw_yaml) { YAML.dump(yaml) }
+
+ subject(:found) { described_class.new(database_dictionary_path) }
+
+ before do
+ allow(File).to receive(:read).and_call_original
+ allow(File).to receive(:read).with(database_dictionary_path).and_return(raw_yaml)
+ end
+
+ described_class::ATTRIBUTES.each do |attribute|
+ describe "##{attribute}" do
+ it 'returns value from the YAML' do
+ expect(found.public_send(attribute)).to eq(yaml[attribute])
+ end
+ end
+ end
+
+ describe '#raw' do
+ it 'returns the raw YAML' do
+ expect(found.raw).to eq(raw_yaml)
+ end
+ end
+
+ describe '#ci_schema?' do
+ it { expect(found.ci_schema?).to be_truthy }
+
+ context 'with main schema' do
+ let(:gitlab_schema) { 'gitlab_main' }
+
+ it { expect(found.ci_schema?).to be_falsey }
+ end
+ end
+
+ describe '#main_schema?' do
+ it { expect(found.main_schema?).to be_falsey }
+
+ context 'with main schema' do
+ let(:gitlab_schema) { 'gitlab_main' }
+
+ it { expect(found.main_schema?).to be_truthy }
+ end
+ end
+ end
+end