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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-02-21 00:11:36 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-21 00:11:36 +0300
commit61a1cd3b8389a7f5553bae90655710ed9b39ddff (patch)
tree52b9e65c4dbf1baf63a8ef52edc79f3eedfbf0d1 /spec/models
parent72c050db64bd61ae767f47c4fa2bc97b94a67592 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/application_setting_spec.rb5
-rw-r--r--spec/models/ci/runner_machine_build_spec.rb12
-rw-r--r--spec/models/container_repository_spec.rb3
-rw-r--r--spec/models/namespace_spec.rb56
-rw-r--r--spec/models/user_spec.rb1
5 files changed, 68 insertions, 9 deletions
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb
index 5b99c68ec80..762b613a585 100644
--- a/spec/models/application_setting_spec.rb
+++ b/spec/models/application_setting_spec.rb
@@ -1124,6 +1124,11 @@ RSpec.describe ApplicationSetting, feature_category: :not_owned, type: :model do
it { is_expected.to allow_value(*Gitlab::I18n.available_locales).for(:default_preferred_language) }
it { is_expected.not_to allow_value(nil, '', 'invalid_locale').for(:default_preferred_language) }
end
+
+ context 'for default_syntax_highlighting_theme' do
+ it { is_expected.to allow_value(*Gitlab::ColorSchemes.valid_ids).for(:default_syntax_highlighting_theme) }
+ it { is_expected.not_to allow_value(nil, 0, Gitlab::ColorSchemes.available_schemes.size + 1).for(:default_syntax_highlighting_theme) }
+ end
end
context 'restrict creating duplicates' do
diff --git a/spec/models/ci/runner_machine_build_spec.rb b/spec/models/ci/runner_machine_build_spec.rb
index cf62731a551..b15d232cbb5 100644
--- a/spec/models/ci/runner_machine_build_spec.rb
+++ b/spec/models/ci/runner_machine_build_spec.rb
@@ -35,4 +35,16 @@ RSpec.describe Ci::RunnerMachineBuild, model: true, feature_category: :runner_fl
end
end
end
+
+ describe 'ci_sliding_list partitioning' do
+ let(:connection) { described_class.connection }
+ let(:partition_manager) { Gitlab::Database::Partitioning::PartitionManager.new(described_class) }
+
+ let(:partitioning_strategy) { described_class.partitioning_strategy }
+
+ it { expect(partitioning_strategy.missing_partitions).to be_empty }
+ it { expect(partitioning_strategy.extra_partitions).to be_empty }
+ it { expect(partitioning_strategy.current_partitions).to include partitioning_strategy.initial_partition }
+ it { expect(partitioning_strategy.active_partition).to be_present }
+ end
end
diff --git a/spec/models/container_repository_spec.rb b/spec/models/container_repository_spec.rb
index da7b54644bd..ef9ff145cfa 100644
--- a/spec/models/container_repository_spec.rb
+++ b/spec/models/container_repository_spec.rb
@@ -23,6 +23,9 @@ RSpec.describe ContainerRepository, :aggregate_failures, feature_category: :cont
status: 200,
body: Gitlab::Json.dump(tags: ['test_tag']),
headers: { 'Content-Type' => 'application/json' })
+
+ # for the user callback: namespace_move_dir_allowed
+ allow(ContainerRegistry::GitlabApiClient).to receive(:one_project_with_container_registry_tag).and_return(nil)
end
it_behaves_like 'having unique enum values'
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb
index a0698ac30f5..3f6d5615164 100644
--- a/spec/models/namespace_spec.rb
+++ b/spec/models/namespace_spec.rb
@@ -713,20 +713,57 @@ RSpec.describe Namespace, feature_category: :subgroups do
let(:container_repository) { create(:container_repository) }
let!(:project) { create(:project, namespace: namespace, container_repositories: [container_repository]) }
- before do
- stub_container_registry_config(enabled: true)
- end
+ context 'not on gitlab.com' do
+ before do
+ stub_container_registry_config(enabled: true)
+ allow(Gitlab).to receive(:com?).and_return(false)
+ end
+
+ it 'returns the project' do
+ stub_container_registry_tags(repository: :any, tags: ['tag'])
+
+ expect(namespace.first_project_with_container_registry_tags).to eq(project)
+ end
- it 'returns the project' do
- stub_container_registry_tags(repository: :any, tags: ['tag'])
+ it 'returns no project' do
+ stub_container_registry_tags(repository: :any, tags: nil)
- expect(namespace.first_project_with_container_registry_tags).to eq(project)
+ expect(namespace.first_project_with_container_registry_tags).to be_nil
+ end
end
- it 'returns no project' do
- stub_container_registry_tags(repository: :any, tags: nil)
+ context 'on gitlab.com' do
+ before do
+ allow(Gitlab).to receive(:com?).and_return(true)
+ stub_container_registry_config(enabled: true, api_url: 'http://container-registry', key: 'spec/fixtures/x509_certificate_pk.key')
+ end
- expect(namespace.first_project_with_container_registry_tags).to be_nil
+ it 'calls and returns GitlabApiClient.one_project_with_container_registry_tag' do
+ expect(ContainerRegistry::GitlabApiClient)
+ .to receive(:one_project_with_container_registry_tag)
+ .with(namespace.full_path)
+ .and_return(project)
+
+ expect(namespace.first_project_with_container_registry_tags).to eq(project)
+ end
+
+ context 'when the feature flag use_sub_repositories_api is disabled' do
+ before do
+ stub_feature_flags(use_sub_repositories_api: false)
+ end
+
+ it 'returns the project' do
+ stub_container_registry_tags(repository: :any, tags: ['tag'])
+
+ expect(namespace.first_project_with_container_registry_tags).to eq(project)
+ end
+
+ it 'returns no project' do
+ stub_container_registry_tags(repository: :any, tags: nil)
+
+ expect(namespace.first_project_with_container_registry_tags).to be_nil
+ end
+ end
end
end
@@ -755,6 +792,7 @@ RSpec.describe Namespace, feature_category: :subgroups do
with_them do
before do
+ allow(ContainerRegistry::GitlabApiClient).to receive(:one_project_with_container_registry_tag).and_return(nil)
stub_container_registry_config(enabled: true, api_url: 'http://container-registry', key: 'spec/fixtures/x509_certificate_pk.key')
allow(Gitlab).to receive(:com?).and_return(true)
allow(ContainerRegistry::GitlabApiClient).to receive(:supports_gitlab_api?).and_return(gitlab_api_supported)
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index e87667d9604..360aee8b531 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -188,6 +188,7 @@ RSpec.describe User, feature_category: :user_profile do
it { expect(user.notified_of_own_activity).to be_falsey }
it { expect(user.preferred_language).to eq(Gitlab::CurrentSettings.default_preferred_language) }
it { expect(user.theme_id).to eq(described_class.gitlab_config.default_theme) }
+ it { expect(user.color_scheme_id).to eq(Gitlab::CurrentSettings.default_syntax_highlighting_theme) }
end
describe '#user_detail' do