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-05-17 19:05:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-17 19:05:49 +0300
commit43a25d93ebdabea52f99b05e15b06250cd8f07d7 (patch)
treedceebdc68925362117480a5d672bcff122fb625b /spec/factories
parent20c84b99005abd1c82101dfeff264ac50d2df211 (diff)
Add latest changes from gitlab-org/gitlab@16-0-stable-eev16.0.0-rc42
Diffstat (limited to 'spec/factories')
-rw-r--r--spec/factories/abuse/trust_score.rb10
-rw-r--r--spec/factories/abuse_reports.rb8
-rw-r--r--spec/factories/achievements/user_achievements.rb14
-rw-r--r--spec/factories/airflow/dags.rb8
-rw-r--r--spec/factories/bulk_import/batch_trackers.rb37
-rw-r--r--spec/factories/bulk_import/export_batches.rb24
-rw-r--r--spec/factories/bulk_import/exports.rb4
-rw-r--r--spec/factories/chat_names.rb1
-rw-r--r--spec/factories/ci/builds.rb12
-rw-r--r--spec/factories/ci/catalog/resources.rb7
-rw-r--r--spec/factories/ci/pipelines.rb12
-rw-r--r--spec/factories/ci/processable.rb20
-rw-r--r--spec/factories/ci/reports/security/findings.rb1
-rw-r--r--spec/factories/ci/reports/security/reports.rb13
-rw-r--r--spec/factories/ci/runner_machine_builds.rb8
-rw-r--r--spec/factories/ci/runner_managers.rb (renamed from spec/factories/ci/runner_machines.rb)4
-rw-r--r--spec/factories/ci/runners.rb6
-rw-r--r--spec/factories/clusters/agents/authorizations/ci_access/group_authorizations.rb (renamed from spec/factories/clusters/agents/group_authorizations.rb)2
-rw-r--r--spec/factories/clusters/agents/authorizations/ci_access/project_authorizations.rb (renamed from spec/factories/clusters/agents/project_authorizations.rb)2
-rw-r--r--spec/factories/clusters/agents/authorizations/user_access/group_authorizations.rb10
-rw-r--r--spec/factories/clusters/agents/authorizations/user_access/project_authorizations.rb10
-rw-r--r--spec/factories/clusters/applications/helm.rb124
-rw-r--r--spec/factories/clusters/clusters.rb15
-rw-r--r--spec/factories/container_registry/data_repair_detail.rb20
-rw-r--r--spec/factories/customer_relations/contacts.rb4
-rw-r--r--spec/factories/customer_relations/organizations.rb2
-rw-r--r--spec/factories/design_management/repositories.rb7
-rw-r--r--spec/factories/draft_note.rb4
-rw-r--r--spec/factories/environments.rb27
-rw-r--r--spec/factories/gitlab/database/async_foreign_keys/postgres_async_constraint_validation.rb17
-rw-r--r--spec/factories/gitlab/database/async_foreign_keys/postgres_async_foreign_key_validation.rb9
-rw-r--r--spec/factories/gitlab/database/background_migration/schema_inconsistencies.rb11
-rw-r--r--spec/factories/group_members.rb16
-rw-r--r--spec/factories/import_failures.rb4
-rw-r--r--spec/factories/integrations.rb50
-rw-r--r--spec/factories/issues.rb15
-rw-r--r--spec/factories/member_roles.rb11
-rw-r--r--spec/factories/merge_requests_diff_llm_summary.rb10
-rw-r--r--spec/factories/ml/candidates.rb14
-rw-r--r--spec/factories/notes.rb49
-rw-r--r--spec/factories/notes/notes_metadata.rb8
-rw-r--r--spec/factories/organizations.rb16
-rw-r--r--spec/factories/packages/debian/component_file.rb7
-rw-r--r--spec/factories/packages/debian/distribution.rb6
-rw-r--r--spec/factories/packages/debian/file_metadatum.rb80
-rw-r--r--spec/factories/packages/npm/metadata_cache.rb10
-rw-r--r--spec/factories/packages/package_files.rb30
-rw-r--r--spec/factories/packages/packages.rb7
-rw-r--r--spec/factories/project_error_tracking_settings.rb5
-rw-r--r--spec/factories/project_hooks.rb2
-rw-r--r--spec/factories/project_members.rb6
-rw-r--r--spec/factories/projects.rb38
-rw-r--r--spec/factories/projects/data_transfers.rb4
-rw-r--r--spec/factories/resource_events/abuse_report_events.rb9
-rw-r--r--spec/factories/resource_events/issue_assignment_events.rb9
-rw-r--r--spec/factories/resource_events/merge_request_assignment_events.rb9
-rw-r--r--spec/factories/search_index.rb10
-rw-r--r--spec/factories/serverless/domain.rb11
-rw-r--r--spec/factories/serverless/domain_cluster.rb17
-rw-r--r--spec/factories/service_desk/custom_email_credential.rb11
-rw-r--r--spec/factories/service_desk/custom_email_verification.rb11
-rw-r--r--spec/factories/slack_integrations.rb25
-rw-r--r--spec/factories/u2f_registrations.rb12
-rw-r--r--spec/factories/users.rb17
-rw-r--r--spec/factories/users/banned_users.rb7
-rw-r--r--spec/factories/work_items.rb30
-rw-r--r--spec/factories/work_items/resource_link_events.rb10
67 files changed, 696 insertions, 333 deletions
diff --git a/spec/factories/abuse/trust_score.rb b/spec/factories/abuse/trust_score.rb
new file mode 100644
index 00000000000..a5ea7666945
--- /dev/null
+++ b/spec/factories/abuse/trust_score.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :abuse_trust_score, class: 'Abuse::TrustScore' do
+ user
+ score { 0.1 }
+ source { :spamcheck }
+ correlation_id_value { 'abcdefg' }
+ end
+end
diff --git a/spec/factories/abuse_reports.rb b/spec/factories/abuse_reports.rb
index 355fb142994..699da744fab 100644
--- a/spec/factories/abuse_reports.rb
+++ b/spec/factories/abuse_reports.rb
@@ -7,5 +7,13 @@ FactoryBot.define do
message { 'User sends spam' }
reported_from_url { 'http://gitlab.com' }
links_to_spam { ['https://gitlab.com/issue1', 'https://gitlab.com/issue2'] }
+
+ trait :closed do
+ status { 'closed' }
+ end
+
+ trait :with_screenshot do
+ screenshot { fixture_file_upload('spec/fixtures/dk.png') }
+ end
end
end
diff --git a/spec/factories/achievements/user_achievements.rb b/spec/factories/achievements/user_achievements.rb
new file mode 100644
index 00000000000..a5fd1df38dd
--- /dev/null
+++ b/spec/factories/achievements/user_achievements.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :user_achievement, class: 'Achievements::UserAchievement' do
+ user
+ achievement
+ awarded_by_user factory: :user
+
+ trait :revoked do
+ revoked_by_user factory: :user
+ revoked_at { Time.now }
+ end
+ end
+end
diff --git a/spec/factories/airflow/dags.rb b/spec/factories/airflow/dags.rb
deleted file mode 100644
index ca4276e2c8f..00000000000
--- a/spec/factories/airflow/dags.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-# frozen_string_literal: true
-FactoryBot.define do
- factory :airflow_dags, class: '::Airflow::Dags' do
- sequence(:dag_name) { |n| "dag_name_#{n}" }
-
- project
- end
-end
diff --git a/spec/factories/bulk_import/batch_trackers.rb b/spec/factories/bulk_import/batch_trackers.rb
new file mode 100644
index 00000000000..427eefc5f3e
--- /dev/null
+++ b/spec/factories/bulk_import/batch_trackers.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :bulk_import_batch_tracker, class: 'BulkImports::BatchTracker' do
+ association :tracker, factory: :bulk_import_tracker
+
+ status { 0 }
+ fetched_objects_count { 1000 }
+ imported_objects_count { 1000 }
+
+ sequence(:batch_number) { |n| n }
+
+ trait :created do
+ status { 0 }
+ end
+
+ trait :started do
+ status { 1 }
+ end
+
+ trait :finished do
+ status { 2 }
+ end
+
+ trait :timeout do
+ status { 3 }
+ end
+
+ trait :failed do
+ status { -1 }
+ end
+
+ trait :skipped do
+ status { -2 }
+ end
+ end
+end
diff --git a/spec/factories/bulk_import/export_batches.rb b/spec/factories/bulk_import/export_batches.rb
new file mode 100644
index 00000000000..f5f12696f5f
--- /dev/null
+++ b/spec/factories/bulk_import/export_batches.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :bulk_import_export_batch, class: 'BulkImports::ExportBatch' do
+ association :export, factory: :bulk_import_export
+
+ upload { association(:bulk_import_export_upload) }
+
+ status { 0 }
+ batch_number { 1 }
+
+ trait :started do
+ status { 0 }
+ end
+
+ trait :finished do
+ status { 1 }
+ end
+
+ trait :failed do
+ status { -1 }
+ end
+ end
+end
diff --git a/spec/factories/bulk_import/exports.rb b/spec/factories/bulk_import/exports.rb
index dd8831ce33a..795a9bbfe20 100644
--- a/spec/factories/bulk_import/exports.rb
+++ b/spec/factories/bulk_import/exports.rb
@@ -20,5 +20,9 @@ FactoryBot.define do
trait :failed do
status { -1 }
end
+
+ trait :batched do
+ batched { true }
+ end
end
end
diff --git a/spec/factories/chat_names.rb b/spec/factories/chat_names.rb
index 56567394bf5..c872694ee64 100644
--- a/spec/factories/chat_names.rb
+++ b/spec/factories/chat_names.rb
@@ -3,7 +3,6 @@
FactoryBot.define do
factory :chat_name, class: 'ChatName' do
user
- integration
team_id { 'T0001' }
team_domain { 'Awesome Team' }
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb
index 224f460488b..dc75e17499c 100644
--- a/spec/factories/ci/builds.rb
+++ b/spec/factories/ci/builds.rb
@@ -415,7 +415,7 @@ FactoryBot.define do
runner factory: :ci_runner
after(:create) do |build|
- build.create_runtime_metadata!
+ ::Ci::RunningBuild.upsert_shared_runner_build!(build)
end
end
@@ -694,7 +694,7 @@ FactoryBot.define do
end
end
- trait :non_public_artifacts do
+ trait :with_private_artifacts_config do
options do
{
artifacts: { public: false }
@@ -702,6 +702,14 @@ FactoryBot.define do
end
end
+ trait :with_public_artifacts_config do
+ options do
+ {
+ artifacts: { public: true }
+ }
+ end
+ end
+
trait :non_playable do
status { 'created' }
self.when { 'manual' }
diff --git a/spec/factories/ci/catalog/resources.rb b/spec/factories/ci/catalog/resources.rb
new file mode 100644
index 00000000000..66c2e58cdd9
--- /dev/null
+++ b/spec/factories/ci/catalog/resources.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :catalog_resource, class: 'Ci::Catalog::Resource' do
+ project factory: :project
+ end
+end
diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb
index d68562c0aa5..2b6bddd2f6d 100644
--- a/spec/factories/ci/pipelines.rb
+++ b/spec/factories/ci/pipelines.rb
@@ -21,6 +21,12 @@ FactoryBot.define do
transient { name { nil } }
+ transient { ci_ref_presence { true } }
+
+ before(:create) do |pipeline, evaluator|
+ pipeline.ensure_ci_ref! if evaluator.ci_ref_presence && pipeline.ci_ref_id.nil?
+ end
+
after(:build) do |pipeline, evaluator|
if evaluator.child_of
pipeline.project = evaluator.child_of.project
@@ -54,12 +60,6 @@ FactoryBot.define do
end
factory :ci_pipeline do
- transient { ci_ref_presence { true } }
-
- before(:create) do |pipeline, evaluator|
- pipeline.ensure_ci_ref! if evaluator.ci_ref_presence && pipeline.ci_ref_id.nil?
- end
-
trait :invalid do
status { :failed }
yaml_errors { 'invalid YAML' }
diff --git a/spec/factories/ci/processable.rb b/spec/factories/ci/processable.rb
index 49e66368f94..49756433713 100644
--- a/spec/factories/ci/processable.rb
+++ b/spec/factories/ci/processable.rb
@@ -26,13 +26,19 @@ FactoryBot.define do
before(:create) do |processable, evaluator|
next if processable.ci_stage
- if ci_stage = processable.pipeline.stages.find_by(name: evaluator.stage)
- processable.ci_stage = ci_stage
- else
- processable.ci_stage = create(:ci_stage, pipeline: processable.pipeline,
- project: processable.project || evaluator.project,
- name: evaluator.stage, position: evaluator.stage_idx, status: 'created')
- end
+ processable.ci_stage =
+ if ci_stage = processable.pipeline.stages.find_by(name: evaluator.stage)
+ ci_stage
+ else
+ create(
+ :ci_stage,
+ pipeline: processable.pipeline,
+ project: processable.project || evaluator.project,
+ name: evaluator.stage,
+ position: evaluator.stage_idx,
+ status: 'created'
+ )
+ end
end
trait :waiting_for_resource do
diff --git a/spec/factories/ci/reports/security/findings.rb b/spec/factories/ci/reports/security/findings.rb
index 78c11210f97..c57a2dd479f 100644
--- a/spec/factories/ci/reports/security/findings.rb
+++ b/spec/factories/ci/reports/security/findings.rb
@@ -27,6 +27,7 @@ FactoryBot.define do
url: "https://crypto.stackexchange.com/questions/31428/pbewithmd5anddes-cipher-does-not-check-for-integrity-first"
}
],
+ raw_source_code_extract: 'AES/ECB/NoPadding',
evidence: {
summary: 'Credit card detected',
request: {
diff --git a/spec/factories/ci/reports/security/reports.rb b/spec/factories/ci/reports/security/reports.rb
index 5699b8fee3e..60d1f4615ac 100644
--- a/spec/factories/ci/reports/security/reports.rb
+++ b/spec/factories/ci/reports/security/reports.rb
@@ -19,6 +19,19 @@ FactoryBot.define do
evaluator.findings.each { |o| report.add_finding(o) }
end
+ factory :dependency_scanning_security_report do
+ type { :dependency_scanning }
+
+ after :create do |report|
+ artifact = report.pipeline.job_artifacts.dependency_scanning.last
+ if artifact.present?
+ content = File.read(artifact.file.path)
+
+ Gitlab::Ci::Parsers::Security::DependencyScanning.parse!(content, report)
+ end
+ end
+ end
+
skip_create
initialize_with do
diff --git a/spec/factories/ci/runner_machine_builds.rb b/spec/factories/ci/runner_machine_builds.rb
new file mode 100644
index 00000000000..34238760112
--- /dev/null
+++ b/spec/factories/ci/runner_machine_builds.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :ci_runner_machine_build, class: 'Ci::RunnerManagerBuild' do
+ build factory: :ci_build, scheduling_type: :dag
+ runner_manager factory: :ci_runner_machine
+ end
+end
diff --git a/spec/factories/ci/runner_machines.rb b/spec/factories/ci/runner_managers.rb
index 9d601caa634..7a2b0c37215 100644
--- a/spec/factories/ci/runner_machines.rb
+++ b/spec/factories/ci/runner_managers.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
FactoryBot.define do
- factory :ci_runner_machine, class: 'Ci::RunnerMachine' do
+ factory :ci_runner_machine, class: 'Ci::RunnerManager' do
runner factory: :ci_runner
system_xid { "r_#{SecureRandom.hex.slice(0, 10)}" }
trait :stale do
created_at { 1.year.ago }
- contacted_at { Ci::RunnerMachine::STALE_TIMEOUT.ago }
+ contacted_at { Ci::RunnerManager::STALE_TIMEOUT.ago }
end
end
end
diff --git a/spec/factories/ci/runners.rb b/spec/factories/ci/runners.rb
index 4758986b47c..f001cecd28e 100644
--- a/spec/factories/ci/runners.rb
+++ b/spec/factories/ci/runners.rb
@@ -66,6 +66,12 @@ FactoryBot.define do
end
end
+ trait :with_runner_manager do
+ after(:build) do |runner, evaluator|
+ runner.runner_managers << build(:ci_runner_machine, runner: runner)
+ end
+ end
+
trait :inactive do
active { false }
end
diff --git a/spec/factories/clusters/agents/group_authorizations.rb b/spec/factories/clusters/agents/authorizations/ci_access/group_authorizations.rb
index abe25794234..659114eef8e 100644
--- a/spec/factories/clusters/agents/group_authorizations.rb
+++ b/spec/factories/clusters/agents/authorizations/ci_access/group_authorizations.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
FactoryBot.define do
- factory :agent_group_authorization, class: 'Clusters::Agents::GroupAuthorization' do
+ factory :agent_ci_access_group_authorization, class: 'Clusters::Agents::Authorizations::CiAccess::GroupAuthorization' do
association :agent, factory: :cluster_agent
group
diff --git a/spec/factories/clusters/agents/project_authorizations.rb b/spec/factories/clusters/agents/authorizations/ci_access/project_authorizations.rb
index eecbfe95bfc..10d4f8fb946 100644
--- a/spec/factories/clusters/agents/project_authorizations.rb
+++ b/spec/factories/clusters/agents/authorizations/ci_access/project_authorizations.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
FactoryBot.define do
- factory :agent_project_authorization, class: 'Clusters::Agents::ProjectAuthorization' do
+ factory :agent_ci_access_project_authorization, class: 'Clusters::Agents::Authorizations::CiAccess::ProjectAuthorization' do
association :agent, factory: :cluster_agent
project
diff --git a/spec/factories/clusters/agents/authorizations/user_access/group_authorizations.rb b/spec/factories/clusters/agents/authorizations/user_access/group_authorizations.rb
new file mode 100644
index 00000000000..203aadbd741
--- /dev/null
+++ b/spec/factories/clusters/agents/authorizations/user_access/group_authorizations.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :agent_user_access_group_authorization,
+ class: 'Clusters::Agents::Authorizations::UserAccess::GroupAuthorization' do
+ association :agent, factory: :cluster_agent
+ config { {} }
+ group
+ end
+end
diff --git a/spec/factories/clusters/agents/authorizations/user_access/project_authorizations.rb b/spec/factories/clusters/agents/authorizations/user_access/project_authorizations.rb
new file mode 100644
index 00000000000..8171607f578
--- /dev/null
+++ b/spec/factories/clusters/agents/authorizations/user_access/project_authorizations.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :agent_user_access_project_authorization,
+ class: 'Clusters::Agents::Authorizations::UserAccess::ProjectAuthorization' do
+ association :agent, factory: :cluster_agent
+ config { {} }
+ project
+ end
+end
diff --git a/spec/factories/clusters/applications/helm.rb b/spec/factories/clusters/applications/helm.rb
deleted file mode 100644
index 0647058d63a..00000000000
--- a/spec/factories/clusters/applications/helm.rb
+++ /dev/null
@@ -1,124 +0,0 @@
-# frozen_string_literal: true
-
-FactoryBot.define do
- factory :clusters_applications_helm, class: 'Clusters::Applications::Helm' do
- cluster factory: %i(cluster provided_by_gcp)
-
- transient do
- helm_installed { true }
- end
-
- before(:create) do |_record, evaluator|
- if evaluator.helm_installed
- stub_method(Gitlab::Kubernetes::Helm::V2::Certificate, :generate_root) do
- OpenStruct.new( # rubocop: disable Style/OpenStructUse
- key_string: File.read(Rails.root.join('spec/fixtures/clusters/sample_key.key')),
- cert_string: File.read(Rails.root.join('spec/fixtures/clusters/sample_cert.pem'))
- )
- end
- end
- end
-
- after(:create) do |_record, evaluator|
- if evaluator.helm_installed
- restore_original_methods(Gitlab::Kubernetes::Helm::V2::Certificate)
- end
- end
-
- trait :not_installable do
- status { -2 }
- end
-
- trait :errored do
- status { -1 }
- status_reason { 'something went wrong' }
- end
-
- trait :installable do
- status { 0 }
- end
-
- trait :scheduled do
- status { 1 }
- end
-
- trait :installing do
- status { 2 }
- end
-
- trait :installed do
- status { 3 }
- end
-
- trait :updating do
- status { 4 }
- end
-
- trait :updated do
- status { 5 }
- end
-
- trait :update_errored do
- status { 6 }
- status_reason { 'something went wrong' }
- end
-
- trait :uninstalling do
- status { 7 }
- end
-
- trait :uninstall_errored do
- status { 8 }
- status_reason { 'something went wrong' }
- end
-
- trait :uninstalled do
- status { 10 }
- end
-
- trait :externally_installed do
- status { 11 }
- end
-
- trait :timed_out do
- installing
- updated_at { ClusterWaitForAppInstallationWorker::TIMEOUT.ago }
- end
-
- # Common trait used by the apps below
- trait :no_helm_installed do
- cluster factory: %i(cluster provided_by_gcp)
-
- transient do
- helm_installed { false }
- end
- end
-
- factory :clusters_applications_ingress, class: 'Clusters::Applications::Ingress' do
- cluster factory: %i(cluster with_installed_helm provided_by_gcp)
- end
-
- factory :clusters_applications_crossplane, class: 'Clusters::Applications::Crossplane' do
- stack { 'gcp' }
- cluster factory: %i(cluster with_installed_helm provided_by_gcp)
- end
-
- factory :clusters_applications_prometheus, class: 'Clusters::Applications::Prometheus' do
- cluster factory: %i(cluster with_installed_helm provided_by_gcp)
- end
-
- factory :clusters_applications_runner, class: 'Clusters::Applications::Runner' do
- cluster factory: %i(cluster with_installed_helm provided_by_gcp)
- end
-
- factory :clusters_applications_knative, class: 'Clusters::Applications::Knative' do
- hostname { 'example.com' }
- cluster factory: %i(cluster with_installed_helm provided_by_gcp)
- end
-
- factory :clusters_applications_jupyter, class: 'Clusters::Applications::Jupyter' do
- oauth_application factory: :oauth_application
- cluster factory: %i(cluster with_installed_helm provided_by_gcp project)
- end
- end
-end
diff --git a/spec/factories/clusters/clusters.rb b/spec/factories/clusters/clusters.rb
index 32cd6beb7ea..2785a8c9946 100644
--- a/spec/factories/clusters/clusters.rb
+++ b/spec/factories/clusters/clusters.rb
@@ -82,25 +82,10 @@ FactoryBot.define do
sequence(:environment_scope) { |n| "production#{n}/*" }
end
- trait :with_installed_helm do
- application_helm factory: %i(clusters_applications_helm installed)
- end
-
trait :with_installed_prometheus do
- application_prometheus factory: %i(clusters_applications_prometheus installed)
integration_prometheus factory: %i(clusters_integrations_prometheus)
end
- trait :with_all_applications do
- application_helm factory: %i(clusters_applications_helm installed)
- application_ingress factory: %i(clusters_applications_ingress installed)
- application_crossplane factory: %i(clusters_applications_crossplane installed)
- application_prometheus factory: %i(clusters_applications_prometheus installed)
- application_runner factory: %i(clusters_applications_runner installed)
- application_jupyter factory: %i(clusters_applications_jupyter installed)
- application_knative factory: %i(clusters_applications_knative installed)
- end
-
trait :with_domain do
domain { 'example.com' }
end
diff --git a/spec/factories/container_registry/data_repair_detail.rb b/spec/factories/container_registry/data_repair_detail.rb
new file mode 100644
index 00000000000..79467c464db
--- /dev/null
+++ b/spec/factories/container_registry/data_repair_detail.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :container_registry_data_repair_detail, class: 'ContainerRegistry::DataRepairDetail' do
+ project
+ updated_at { 1.hour.ago }
+
+ trait :ongoing do
+ status { :ongoing }
+ end
+
+ trait :completed do
+ status { :completed }
+ end
+
+ trait :failed do
+ status { :failed }
+ end
+ end
+end
diff --git a/spec/factories/customer_relations/contacts.rb b/spec/factories/customer_relations/contacts.rb
index 1896510d362..6410e298bc3 100644
--- a/spec/factories/customer_relations/contacts.rb
+++ b/spec/factories/customer_relations/contacts.rb
@@ -8,10 +8,6 @@ FactoryBot.define do
last_name { generate(:name) }
email { generate(:email) }
- trait :with_organization do
- organization
- end
-
trait :inactive do
state { :inactive }
end
diff --git a/spec/factories/customer_relations/organizations.rb b/spec/factories/customer_relations/organizations.rb
index b6efd46f1a4..789099190ac 100644
--- a/spec/factories/customer_relations/organizations.rb
+++ b/spec/factories/customer_relations/organizations.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
FactoryBot.define do
- factory :organization, class: 'CustomerRelations::Organization' do
+ factory :crm_organization, class: 'CustomerRelations::Organization' do
group
name { generate(:name) }
diff --git a/spec/factories/design_management/repositories.rb b/spec/factories/design_management/repositories.rb
new file mode 100644
index 00000000000..d903fd88c13
--- /dev/null
+++ b/spec/factories/design_management/repositories.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :design_management_repository, class: 'DesignManagement::Repository' do
+ project
+ end
+end
diff --git a/spec/factories/draft_note.rb b/spec/factories/draft_note.rb
index cde8831f169..8433271a3c5 100644
--- a/spec/factories/draft_note.rb
+++ b/spec/factories/draft_note.rb
@@ -28,9 +28,7 @@ FactoryBot.define do
end
position do
- association(:image_diff_position,
- file: path,
- diff_refs: diff_refs)
+ association(:image_diff_position, file: path, diff_refs: diff_refs)
end
end
end
diff --git a/spec/factories/environments.rb b/spec/factories/environments.rb
index 34843dab0fe..2df9f482bb9 100644
--- a/spec/factories/environments.rb
+++ b/spec/factories/environments.rb
@@ -46,20 +46,19 @@ FactoryBot.define do
after(:create) do |environment, evaluator|
pipeline = create(:ci_pipeline, project: environment.project)
- deployable = create(:ci_build, :success, name: "#{environment.name}:deploy",
- pipeline: pipeline)
-
- deployment = create(:deployment,
- :success,
- environment: environment,
- project: environment.project,
- deployable: deployable,
- ref: evaluator.ref,
- sha: environment.project.commit(evaluator.ref).id)
-
- teardown_build = create(:ci_build, :manual,
- name: "#{environment.name}:teardown",
- pipeline: pipeline)
+ deployable = create(:ci_build, :success, name: "#{environment.name}:deploy", pipeline: pipeline)
+
+ deployment = create(
+ :deployment,
+ :success,
+ environment: environment,
+ project: environment.project,
+ deployable: deployable,
+ ref: evaluator.ref,
+ sha: environment.project.commit(evaluator.ref).id
+ )
+
+ teardown_build = create(:ci_build, :manual, name: "#{environment.name}:teardown", pipeline: pipeline)
deployment.update_column(:on_stop, teardown_build.name)
environment.update_attribute(:deployments, [deployment])
diff --git a/spec/factories/gitlab/database/async_foreign_keys/postgres_async_constraint_validation.rb b/spec/factories/gitlab/database/async_foreign_keys/postgres_async_constraint_validation.rb
new file mode 100644
index 00000000000..81f67e958c0
--- /dev/null
+++ b/spec/factories/gitlab/database/async_foreign_keys/postgres_async_constraint_validation.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :postgres_async_constraint_validation,
+ class: 'Gitlab::Database::AsyncConstraints::PostgresAsyncConstraintValidation' do
+ sequence(:name) { |n| "fk_users_id_#{n}" }
+ table_name { "users" }
+
+ trait :foreign_key do
+ constraint_type { :foreign_key }
+ end
+
+ trait :check_constraint do
+ constraint_type { :check_constraint }
+ end
+ end
+end
diff --git a/spec/factories/gitlab/database/async_foreign_keys/postgres_async_foreign_key_validation.rb b/spec/factories/gitlab/database/async_foreign_keys/postgres_async_foreign_key_validation.rb
deleted file mode 100644
index a61b5cde7a0..00000000000
--- a/spec/factories/gitlab/database/async_foreign_keys/postgres_async_foreign_key_validation.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-FactoryBot.define do
- factory :postgres_async_foreign_key_validation,
- class: 'Gitlab::Database::AsyncForeignKeys::PostgresAsyncForeignKeyValidation' do
- sequence(:name) { |n| "fk_users_id_#{n}" }
- table_name { "users" }
- end
-end
diff --git a/spec/factories/gitlab/database/background_migration/schema_inconsistencies.rb b/spec/factories/gitlab/database/background_migration/schema_inconsistencies.rb
new file mode 100644
index 00000000000..b71b0971417
--- /dev/null
+++ b/spec/factories/gitlab/database/background_migration/schema_inconsistencies.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :schema_inconsistency, class: '::Gitlab::Database::SchemaValidation::SchemaInconsistency' do
+ issue factory: :issue
+
+ object_name { 'name' }
+ table_name { 'table' }
+ valitador_name { 'validator' }
+ end
+end
diff --git a/spec/factories/group_members.rb b/spec/factories/group_members.rb
index 702db45554e..e1841745cb4 100644
--- a/spec/factories/group_members.rb
+++ b/spec/factories/group_members.rb
@@ -30,6 +30,12 @@ FactoryBot.define do
after(:build) { |group_member, _| group_member.user.block! }
end
+ trait :banned do
+ after(:create) do |member|
+ create(:namespace_ban, namespace: member.member_namespace.root_ancestor, user: member.user) unless member.owner?
+ end
+ end
+
trait :minimal_access do
to_create { |instance| instance.save!(validate: false) }
@@ -54,10 +60,12 @@ FactoryBot.define do
after(:build) do |group_member, evaluator|
if evaluator.tasks_to_be_done.present?
- build(:member_task,
- member: group_member,
- project: build(:project, namespace: group_member.source),
- tasks_to_be_done: evaluator.tasks_to_be_done)
+ build(
+ :member_task,
+ member: group_member,
+ project: build(:project, namespace: group_member.source),
+ tasks_to_be_done: evaluator.tasks_to_be_done
+ )
end
end
end
diff --git a/spec/factories/import_failures.rb b/spec/factories/import_failures.rb
index df0793664f4..b4a7c6c46b1 100644
--- a/spec/factories/import_failures.rb
+++ b/spec/factories/import_failures.rb
@@ -21,5 +21,9 @@ FactoryBot.define do
trait :soft_failure do
retry_count { 1 }
end
+
+ trait :github_import_failure do
+ external_identifiers { { iid: 2, object_type: 'pull_request', title: 'Implement cool feature' } }
+ end
end
end
diff --git a/spec/factories/integrations.rb b/spec/factories/integrations.rb
index 7740b2da911..10568d7f1cd 100644
--- a/spec/factories/integrations.rb
+++ b/spec/factories/integrations.rb
@@ -43,6 +43,29 @@ FactoryBot.define do
end
end
+ factory :gitlab_slack_application_integration, class: 'Integrations::GitlabSlackApplication' do
+ project
+ active { true }
+ type { 'Integrations::GitlabSlackApplication' }
+ slack_integration { association :slack_integration, integration: instance }
+
+ transient do
+ all_channels { true }
+ end
+
+ after(:build) do |integration, evaluator|
+ next unless evaluator.all_channels
+
+ integration.event_channel_names.each do |name|
+ integration.send("#{name}=".to_sym, "##{name}")
+ end
+ end
+
+ trait :all_features_supported do
+ slack_integration { association :slack_integration, :all_features_supported, integration: instance }
+ end
+ end
+
factory :packagist_integration, class: 'Integrations::Packagist' do
project
type { 'Integrations::Packagist' }
@@ -85,9 +108,12 @@ FactoryBot.define do
api_url { '' }
username { 'jira_username' }
password { 'jira_password' }
+ jira_auth_type { 0 }
jira_issue_transition_automatic { false }
jira_issue_transition_id { '56-1' }
issues_enabled { false }
+ jira_issue_prefix { '' }
+ jira_issue_regex { '' }
project_key { nil }
vulnerabilities_enabled { false }
vulnerabilities_issuetype { nil }
@@ -98,6 +124,7 @@ FactoryBot.define do
if evaluator.create_data
integration.jira_tracker_data = build(:jira_tracker_data,
integration: integration, url: evaluator.url, api_url: evaluator.api_url,
+ jira_auth_type: evaluator.jira_auth_type,
jira_issue_transition_automatic: evaluator.jira_issue_transition_automatic,
jira_issue_transition_id: evaluator.jira_issue_transition_id,
username: evaluator.username, password: evaluator.password, issues_enabled: evaluator.issues_enabled,
@@ -199,6 +226,7 @@ FactoryBot.define do
url { 'https://mysite.atlassian.net' }
username { 'jira_user' }
password { 'my-secret-password' }
+ jira_auth_type { 0 }
end
trait :chat_notification do
@@ -261,7 +289,27 @@ FactoryBot.define do
app_store_issuer_id { 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee' }
app_store_key_id { 'ABC1' }
- app_store_private_key { File.read('spec/fixtures/ssl_key.pem') }
+ app_store_private_key_file_name { 'auth_key.p8' }
+ app_store_private_key { File.read('spec/fixtures/auth_key.p8') }
+ end
+
+ factory :google_play_integration, class: 'Integrations::GooglePlay' do
+ project
+ active { true }
+ type { 'Integrations::GooglePlay' }
+
+ package_name { 'com.gitlab.foo.bar' }
+ service_account_key_file_name { 'service_account.json' }
+ service_account_key { File.read('spec/fixtures/service_account.json') }
+ end
+
+ factory :squash_tm_integration, class: 'Integrations::SquashTm' do
+ project
+ active { true }
+ type { 'Integrations::SquashTm' }
+
+ url { 'https://url-to-squash.com' }
+ token { 'squash_tm_token' }
end
# this is for testing storing values inside properties, which is deprecated and will be removed in
diff --git a/spec/factories/issues.rb b/spec/factories/issues.rb
index 70a4a3ec822..67824a10288 100644
--- a/spec/factories/issues.rb
+++ b/spec/factories/issues.rb
@@ -66,6 +66,11 @@ FactoryBot.define do
end
end
+ trait :requirement do
+ issue_type { :requirement }
+ association :work_item_type, :default, :requirement
+ end
+
trait :task do
issue_type { :task }
association :work_item_type, :default, :task
@@ -81,6 +86,16 @@ FactoryBot.define do
association :work_item_type, :default, :key_result
end
+ trait :incident do
+ issue_type { :incident }
+ association :work_item_type, :default, :incident
+ end
+
+ trait :test_case do
+ issue_type { :test_case }
+ association :work_item_type, :default, :test_case
+ end
+
factory :incident do
issue_type { :incident }
association :work_item_type, :default, :incident
diff --git a/spec/factories/member_roles.rb b/spec/factories/member_roles.rb
deleted file mode 100644
index 503438d2521..00000000000
--- a/spec/factories/member_roles.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: true
-
-FactoryBot.define do
- factory :member_role do
- namespace { association(:group) }
- base_access_level { Gitlab::Access::DEVELOPER }
-
- trait(:developer) { base_access_level { Gitlab::Access::DEVELOPER } }
- trait(:guest) { base_access_level { Gitlab::Access::GUEST } }
- end
-end
diff --git a/spec/factories/merge_requests_diff_llm_summary.rb b/spec/factories/merge_requests_diff_llm_summary.rb
new file mode 100644
index 00000000000..c72ce97efcb
--- /dev/null
+++ b/spec/factories/merge_requests_diff_llm_summary.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :merge_request_diff_llm_summary, class: 'MergeRequest::DiffLlmSummary' do
+ association :user, factory: :user
+ association :merge_request_diff, factory: :merge_request_diff
+ provider { 0 }
+ content { 'test' }
+ end
+end
diff --git a/spec/factories/ml/candidates.rb b/spec/factories/ml/candidates.rb
index 1b41e39d711..b9a2320138a 100644
--- a/spec/factories/ml/candidates.rb
+++ b/spec/factories/ml/candidates.rb
@@ -1,9 +1,11 @@
# frozen_string_literal: true
FactoryBot.define do
factory :ml_candidates, class: '::Ml::Candidate' do
- association :experiment, factory: :ml_experiments
+ association :project, factory: :project
association :user
+ experiment { association :ml_experiments, project_id: project.id }
+
trait :with_metrics_and_params do
after(:create) do |candidate|
candidate.metrics = FactoryBot.create_list(:ml_candidate_metrics, 2, candidate: candidate )
@@ -19,10 +21,12 @@ FactoryBot.define do
trait :with_artifact do
after(:create) do |candidate|
- FactoryBot.create(:generic_package,
- name: candidate.package_name,
- version: candidate.package_version,
- project: candidate.project)
+ candidate.package = FactoryBot.create(
+ :generic_package,
+ name: candidate.package_name,
+ version: candidate.package_version,
+ project: candidate.project
+ )
end
end
end
diff --git a/spec/factories/notes.rb b/spec/factories/notes.rb
index 530b4616765..b1e7866f9ce 100644
--- a/spec/factories/notes.rb
+++ b/spec/factories/notes.rb
@@ -12,6 +12,7 @@ FactoryBot.define do
factory :note_on_commit, traits: [:on_commit]
factory :note_on_issue, traits: [:on_issue], aliases: [:votable_note]
+ factory :note_on_work_item, traits: [:on_work_item]
factory :note_on_merge_request, traits: [:on_merge_request]
factory :note_on_project_snippet, traits: [:on_project_snippet]
factory :note_on_personal_snippet, traits: [:on_personal_snippet]
@@ -54,28 +55,34 @@ FactoryBot.define do
end
position do
- association(:text_diff_position,
- file: "files/ruby/popen.rb",
- old_line: nil,
- new_line: line_number,
- diff_refs: diff_refs)
+ association(
+ :text_diff_position,
+ file: "files/ruby/popen.rb",
+ old_line: nil,
+ new_line: line_number,
+ diff_refs: diff_refs
+ )
end
trait :folded_position do
position do
- association(:text_diff_position,
- file: "files/ruby/popen.rb",
- old_line: 1,
- new_line: 1,
- diff_refs: diff_refs)
+ association(
+ :text_diff_position,
+ file: "files/ruby/popen.rb",
+ old_line: 1,
+ new_line: 1,
+ diff_refs: diff_refs
+ )
end
end
factory :image_diff_note_on_merge_request do
position do
- association(:image_diff_position,
- file: "files/images/any_image.png",
- diff_refs: diff_refs)
+ association(
+ :image_diff_position,
+ file: "files/images/any_image.png",
+ diff_refs: diff_refs
+ )
end
end
end
@@ -100,9 +107,11 @@ FactoryBot.define do
factory :diff_note_on_design, parent: :note, traits: [:on_design], class: 'DiffNote' do
position do
- association(:image_diff_position,
- file: noteable.full_path,
- diff_refs: noteable.diff_refs)
+ association(
+ :image_diff_position,
+ file: noteable.full_path,
+ diff_refs: noteable.diff_refs
+ )
end
end
@@ -122,6 +131,10 @@ FactoryBot.define do
noteable { association(:issue, project: project) }
end
+ trait :on_work_item do
+ noteable { association(:work_item, project: project) }
+ end
+
trait :on_merge_request do
noteable { association(:merge_request, source_project: project) }
end
@@ -191,6 +204,10 @@ FactoryBot.define do
confidential { true }
end
+ trait :internal do
+ internal { true }
+ end
+
trait :with_review do
review
end
diff --git a/spec/factories/notes/notes_metadata.rb b/spec/factories/notes/notes_metadata.rb
new file mode 100644
index 00000000000..555debbc0e5
--- /dev/null
+++ b/spec/factories/notes/notes_metadata.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :note_metadata, class: 'Notes::NoteMetadata' do
+ note
+ email_participant { 'email@example.com' }
+ end
+end
diff --git a/spec/factories/organizations.rb b/spec/factories/organizations.rb
new file mode 100644
index 00000000000..7ff0493d140
--- /dev/null
+++ b/spec/factories/organizations.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :organization do
+ sequence(:name) { |n| "Organization ##{n}" }
+
+ trait :default do
+ id { Organization::DEFAULT_ORGANIZATION_ID }
+ name { 'Default' }
+ initialize_with do
+ # Ensure we only use one default organization
+ Organization.find_by(id: Organization::DEFAULT_ORGANIZATION_ID) || new(**attributes)
+ end
+ end
+ end
+end
diff --git a/spec/factories/packages/debian/component_file.rb b/spec/factories/packages/debian/component_file.rb
index a2422e4a126..0a134ee16c4 100644
--- a/spec/factories/packages/debian/component_file.rb
+++ b/spec/factories/packages/debian/component_file.rb
@@ -20,7 +20,6 @@ FactoryBot.define do
component_file.file = fixture_file_upload(evaluator.file_fixture) if evaluator.file_fixture.present?
end
- file_md5 { '12345abcde' }
file_sha256 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' }
trait(:packages) do
@@ -47,5 +46,11 @@ FactoryBot.define do
trait(:object_storage) do
file_store { Packages::PackageFileUploader::Store::REMOTE }
end
+
+ trait(:empty) do
+ file_sha256 { 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' }
+ file_fixture { nil }
+ size { 0 }
+ end
end
end
diff --git a/spec/factories/packages/debian/distribution.rb b/spec/factories/packages/debian/distribution.rb
index 48892d16efb..7a9d8561a9c 100644
--- a/spec/factories/packages/debian/distribution.rb
+++ b/spec/factories/packages/debian/distribution.rb
@@ -4,14 +4,14 @@ FactoryBot.define do
factory :debian_project_distribution, class: 'Packages::Debian::ProjectDistribution' do
container { association(:project) }
- sequence(:codename) { |n| "#{FFaker::Lorem.word}#{n}" }
+ sequence(:codename) { |n| "codename-#{n}" }
factory :debian_group_distribution, class: 'Packages::Debian::GroupDistribution' do
container { association(:group) }
end
trait(:with_suite) do
- sequence(:suite) { |n| "#{FFaker::Lorem.word}#{n}" }
+ sequence(:suite) { |n| "suite-#{n}" }
end
trait(:with_file) do
@@ -24,7 +24,7 @@ FactoryBot.define do
FILESIGNATURE
end
- after(:build) do |distribution, evaluator|
+ after(:build) do |distribution, _evaluator|
distribution.file = fixture_file_upload('spec/fixtures/packages/debian/distribution/Release')
distribution.signed_file = fixture_file_upload('spec/fixtures/packages/debian/distribution/InRelease')
end
diff --git a/spec/factories/packages/debian/file_metadatum.rb b/spec/factories/packages/debian/file_metadatum.rb
index 505b9975f79..6b6cd9c51f3 100644
--- a/spec/factories/packages/debian/file_metadatum.rb
+++ b/spec/factories/packages/debian/file_metadatum.rb
@@ -2,11 +2,18 @@
FactoryBot.define do
factory :debian_file_metadatum, class: 'Packages::Debian::FileMetadatum' do
- package_file { association(:debian_package_file, without_loaded_metadatum: true) }
+ package_file do
+ if file_type == 'unknown'
+ association(:debian_package_file, :unknown, without_loaded_metadatum: true)
+ else
+ association(:debian_package_file, without_loaded_metadatum: true)
+ end
+ end
+
file_type { 'deb' }
component { 'main' }
architecture { 'amd64' }
- fields { { 'a': 'b' } }
+ fields { { 'a' => 'b' } }
trait(:unknown) do
file_type { 'unknown' }
@@ -30,21 +37,23 @@ FactoryBot.define do
{
'Format' => '3.0 (native)',
'Source' => package_file.package.name,
- 'Binary' => 'sample-dev, libsample0, sample-udeb',
+ 'Binary' => 'sample-dev, libsample0, sample-udeb, sample-ddeb',
'Architecture' => 'any',
- 'Version': package_file.package.version,
+ 'Version' => package_file.package.version,
'Maintainer' => "#{FFaker::Name.name} <#{FFaker::Internet.email}>",
'Homepage' => FFaker::Internet.http_url,
'Standards-Version' => '4.5.0',
'Build-Depends' => 'debhelper-compat (= 13)',
- 'Package-List' => <<~EOF.rstrip,
- libsample0 deb libs optional arch=any',
- sample-dev deb libdevel optional arch=any',
- sample-udeb udeb libs optional arch=any',
- EOF
- 'Checksums-Sha1' => "\nc5cfc111ea924842a89a06d5673f07dfd07de8ca 864 sample_1.2.3~alpha2.tar.xz",
- 'Checksums-Sha256' => "\n40e4682bb24a73251ccd7c7798c0094a649091e5625d6a14bcec9b4e7174f3da 864 sample_1.2.3~alpha2.tar.xz",
- 'Files' => "\nd5ca476e4229d135a88f9c729c7606c9 864 sample_1.2.3~alpha2.tar.xz"
+ 'Package-List' => <<~PACKAGELIST.rstrip,
+ libsample0 deb libs optional arch=any
+ sample-ddeb deb libs optional arch=any
+ sample-dev deb libdevel optional arch=any
+ sample-udeb udeb libs optional arch=any
+ PACKAGELIST
+ 'Checksums-Sha1' => "\n4a9cb2a7c77a68dc0fe54ba8ecef133a7c949e9d 964 sample_1.2.3~alpha2.tar.xz",
+ 'Checksums-Sha256' =>
+ "\nc9d05185ca158bb804977fa9d7b922e8a0f644a2da41f99d2787dd61b1e2e2c5 964 sample_1.2.3~alpha2.tar.xz",
+ 'Files' => "\nadc69e57cda38d9bb7c8d59cacfb6869 964 sample_1.2.3~alpha2.tar.xz"
}
end
end
@@ -55,22 +64,22 @@ FactoryBot.define do
architecture { 'amd64' }
fields do
{
- 'Package' => 'libsample0',
- 'Source' => package_file.package.name,
- 'Version' => package_file.package.version,
- 'Architecture' => 'amd64',
- 'Maintainer' => "#{FFaker::Name.name} <#{FFaker::Internet.email}>",
- 'Installed-Size' => '7',
- 'Section' => 'libs',
- 'Priority' => 'optional',
- 'Multi-Arch' => 'same',
- 'Homepage' => FFaker::Internet.http_url,
- 'Description' => <<~EOF.rstrip
- Some mostly empty lib
- Used in GitLab tests.
+ 'Package' => 'libsample0',
+ 'Source' => package_file.package.name,
+ 'Version' => package_file.package.version,
+ 'Architecture' => 'amd64',
+ 'Maintainer' => "#{FFaker::NameCN.name} #{FFaker::Name.name} <#{FFaker::Internet.email}>",
+ 'Installed-Size' => '7',
+ 'Section' => 'libs',
+ 'Priority' => 'optional',
+ 'Multi-Arch' => 'same',
+ 'Homepage' => FFaker::Internet.http_url,
+ 'Description' => <<~DESCRIPTION.rstrip
+ Some mostly empty lib
+ Used in GitLab tests.
- Testing another paragraph.
- EOF
+ Testing another paragraph.
+ DESCRIPTION
}
end
end
@@ -92,12 +101,12 @@ FactoryBot.define do
'Priority' => 'optional',
'Multi-Arch' => 'same',
'Homepage' => FFaker::Internet.http_url,
- 'Description' => <<~EOF.rstrip
+ 'Description' => <<~DESCRIPTION.rstrip
Some mostly empty development files
Used in GitLab tests.
Testing another paragraph.
- EOF
+ DESCRIPTION
}
end
end
@@ -106,21 +115,28 @@ FactoryBot.define do
file_type { 'udeb' }
component { 'main' }
architecture { 'amd64' }
- fields { { 'a': 'b' } }
+ fields { { 'a' => 'b' } }
+ end
+
+ trait(:ddeb) do
+ file_type { 'ddeb' }
+ component { 'main' }
+ architecture { 'amd64' }
+ fields { { 'a' => 'b' } }
end
trait(:buildinfo) do
file_type { 'buildinfo' }
component { 'main' }
architecture { nil }
- fields { { 'Architecture': 'amd64 source' } }
+ fields { { 'Architecture' => 'amd64 source' } }
end
trait(:changes) do
file_type { 'changes' }
component { nil }
architecture { nil }
- fields { { 'Architecture': 'source amd64' } }
+ fields { { 'Architecture' => 'source amd64' } }
end
end
end
diff --git a/spec/factories/packages/npm/metadata_cache.rb b/spec/factories/packages/npm/metadata_cache.rb
new file mode 100644
index 00000000000..e76ddf3c983
--- /dev/null
+++ b/spec/factories/packages/npm/metadata_cache.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :npm_metadata_cache, class: 'Packages::Npm::MetadataCache' do
+ project
+ sequence(:package_name) { |n| "@#{project.root_namespace.path}/package-#{n}" }
+ file { fixture_file_upload('spec/fixtures/packages/npm/metadata.json') }
+ size { 401.bytes }
+ end
+end
diff --git a/spec/factories/packages/package_files.rb b/spec/factories/packages/package_files.rb
index 7d3dd274777..4a2d412832c 100644
--- a/spec/factories/packages/package_files.rb
+++ b/spec/factories/packages/package_files.rb
@@ -131,9 +131,9 @@ FactoryBot.define do
trait(:source) do
file_name { 'sample_1.2.3~alpha2.tar.xz' }
- file_md5 { 'd5ca476e4229d135a88f9c729c7606c9' }
- file_sha1 { 'c5cfc111ea924842a89a06d5673f07dfd07de8ca' }
- file_sha256 { '40e4682bb24a73251ccd7c7798c0094a649091e5625d6a14bcec9b4e7174f3da' }
+ file_md5 { 'adc69e57cda38d9bb7c8d59cacfb6869' }
+ file_sha1 { '4a9cb2a7c77a68dc0fe54ba8ecef133a7c949e9d' }
+ file_sha256 { 'c9d05185ca158bb804977fa9d7b922e8a0f644a2da41f99d2787dd61b1e2e2c5' }
transient do
file_metadatum_trait { :source }
@@ -142,9 +142,9 @@ FactoryBot.define do
trait(:dsc) do
file_name { 'sample_1.2.3~alpha2.dsc' }
- file_md5 { 'ceccb6bb3e45ce6550b24234d4023e0f' }
- file_sha1 { '375ba20ea1789e1e90d469c3454ce49a431d0442' }
- file_sha256 { '81fc156ba937cdb6215362cc4bf6b8dc47be9b4253ba0f1a4ab10c7ea0c4c4e5' }
+ file_md5 { '629921cfc477bfa84adfd2ccaba89783' }
+ file_sha1 { '443c98a4cf4acd21e2259ae8f2d60fc9932de353' }
+ file_sha256 { 'f91070524a59bbb3a1f05a78409e92cb9ee86470b34018bc0b93bd5b2dd3868c' }
transient do
file_metadatum_trait { :dsc }
@@ -184,11 +184,22 @@ FactoryBot.define do
end
end
+ trait(:ddeb) do
+ file_name { 'sample-ddeb_1.2.3~alpha2_amd64.ddeb' }
+ file_md5 { '90d1107471eed48c73ad78b19ac83639' }
+ file_sha1 { '9c5af97cf8dfbe8126c807f540c88757f382b307' }
+ file_sha256 { 'a6bcc8a4b010f99ce0ea566ac69088e1910e754593c77f2b4942e3473e784e4d' }
+
+ transient do
+ file_metadatum_trait { :ddeb }
+ end
+ end
+
trait(:buildinfo) do
file_name { 'sample_1.2.3~alpha2_amd64.buildinfo' }
- file_md5 { '12a5ac4f16ad75f8741327ac23b4c0d7' }
- file_sha1 { '661f7507efa6fdd3763c95581d0baadb978b7ef5' }
- file_sha256 { 'd0c169e9caa5b303a914b27b5adf69768fe6687d4925905b7d0cd9c0f9d4e56c' }
+ file_md5 { 'cc07ff4d741aec132816f9bd67c6875d' }
+ file_sha1 { 'bcc4ca85f17a31066b726cd4e04485ab24a682c6' }
+ file_sha256 { '5a3dac17c4ff0d49fa5f47baa973902b59ad2ee05147062b8ed8f19d196731d1' }
transient do
file_metadatum_trait { :buildinfo }
@@ -204,6 +215,7 @@ FactoryBot.define do
end
trait(:keep) do
+ # do not override attributes
end
end
diff --git a/spec/factories/packages/packages.rb b/spec/factories/packages/packages.rb
index d0fde0a16cd..283df3428db 100644
--- a/spec/factories/packages/packages.rb
+++ b/spec/factories/packages/packages.rb
@@ -78,19 +78,24 @@ FactoryBot.define do
after :build do |package, evaluator|
if evaluator.published_in == :create
- create(:debian_publication, package: package)
+ build(:debian_publication, package: package)
elsif !evaluator.published_in.nil?
create(:debian_publication, package: package, distribution: evaluator.published_in)
end
end
after :create do |package, evaluator|
+ if evaluator.published_in == :create
+ package.debian_publication.save!
+ end
+
unless evaluator.without_package_files
create :debian_package_file, :source, evaluator.file_metadatum_trait, package: package
create :debian_package_file, :dsc, evaluator.file_metadatum_trait, package: package
create :debian_package_file, :deb, evaluator.file_metadatum_trait, package: package
create :debian_package_file, :deb_dev, evaluator.file_metadatum_trait, package: package
create :debian_package_file, :udeb, evaluator.file_metadatum_trait, package: package
+ create :debian_package_file, :ddeb, evaluator.file_metadatum_trait, package: package
create :debian_package_file, :buildinfo, evaluator.file_metadatum_trait, package: package
create :debian_package_file, :changes, evaluator.file_metadatum_trait, package: package
end
diff --git a/spec/factories/project_error_tracking_settings.rb b/spec/factories/project_error_tracking_settings.rb
index a8ad1af6345..dc0277cb58d 100644
--- a/spec/factories/project_error_tracking_settings.rb
+++ b/spec/factories/project_error_tracking_settings.rb
@@ -16,7 +16,12 @@ FactoryBot.define do
end
trait :integrated do
+ api_url { nil }
integrated { true }
+ token { nil }
+ project_name { nil }
+ organization_name { nil }
+ sentry_project_id { nil }
end
end
end
diff --git a/spec/factories/project_hooks.rb b/spec/factories/project_hooks.rb
index d84e287d765..3e70b897df6 100644
--- a/spec/factories/project_hooks.rb
+++ b/spec/factories/project_hooks.rb
@@ -35,7 +35,7 @@ FactoryBot.define do
end
trait :permanently_disabled do
- recent_failures { WebHook::FAILURE_THRESHOLD + 1 }
+ recent_failures { WebHooks::AutoDisabling::FAILURE_THRESHOLD + 1 }
end
end
end
diff --git a/spec/factories/project_members.rb b/spec/factories/project_members.rb
index 57f228650a1..fb62b2ed951 100644
--- a/spec/factories/project_members.rb
+++ b/spec/factories/project_members.rb
@@ -26,6 +26,12 @@ FactoryBot.define do
after(:build) { |project_member, _| project_member.user.block! }
end
+ trait :banned do
+ after(:create) do |member|
+ create(:namespace_ban, namespace: member.member_namespace.root_ancestor, user: member.user) unless member.owner?
+ end
+ end
+
trait :awaiting do
after(:create) do |member|
member.update!(state: ::Member::STATE_AWAITING)
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb
index f113ca2425f..856f0f6cd05 100644
--- a/spec/factories/projects.rb
+++ b/spec/factories/projects.rb
@@ -8,8 +8,8 @@ FactoryBot.define do
# Project does not have bare repository.
# Use this factory if you don't need repository in tests
factory :project, class: 'Project' do
- sequence(:name) { |n| "project#{n}" }
- path { name.downcase.gsub(/\s/, '_') }
+ sequence(:path) { |n| "project-#{n}" }
+ name { "#{path.humanize} Name" }
# Behaves differently to nil due to cache_has_external_* methods.
has_external_issue_tracker { false }
@@ -222,7 +222,7 @@ FactoryBot.define do
# the transient `files` attribute. Each file will be created in its own
# commit, operating against the master branch. So, the following call:
#
- # create(:project, :custom_repo, files: { 'foo/a.txt' => 'foo', 'b.txt' => bar' })
+ # create(:project, :custom_repo, files: { 'foo/a.txt' => 'foo', 'b.txt' => 'bar' })
#
# will create a repository containing two files, and two commits, in master
trait :custom_repo do
@@ -245,6 +245,19 @@ FactoryBot.define do
end
end
+ # A basic repository with a single file 'test.txt'. It also has the HEAD as the default branch.
+ trait :small_repo do
+ custom_repo
+
+ files { { 'test.txt' => 'test' } }
+
+ after(:create) do |project|
+ Sidekiq::Worker.skipping_transaction_check do
+ raise "Failed to assign the repository head!" unless project.change_head(project.default_branch_or_main)
+ end
+ end
+ end
+
# Test repository - https://gitlab.com/gitlab-org/gitlab-test
trait :repository do
test_repo
@@ -354,6 +367,18 @@ FactoryBot.define do
end
end
+ trait :stubbed_commit_count do
+ after(:build) do |project|
+ stub_method(project.repository, :commit_count) { 2 }
+ end
+ end
+
+ trait :stubbed_branch_count do
+ after(:build) do |project|
+ stub_method(project.repository, :branch_count) { 2 }
+ end
+ end
+
trait :wiki_repo do
after(:create) do |project|
stub_feature_flags(main_branch_over_master: false)
@@ -510,4 +535,11 @@ FactoryBot.define do
trait :in_subgroup do
namespace factory: [:group, :nested]
end
+
+ trait :readme do
+ custom_repo
+
+ path { 'gitlab-profile' }
+ files { { 'README.md' => 'Hello World' } }
+ end
end
diff --git a/spec/factories/projects/data_transfers.rb b/spec/factories/projects/data_transfers.rb
index 4184f475663..3c335c876e4 100644
--- a/spec/factories/projects/data_transfers.rb
+++ b/spec/factories/projects/data_transfers.rb
@@ -5,5 +5,9 @@ FactoryBot.define do
project factory: :project
namespace { project.root_namespace }
date { Time.current.utc.beginning_of_month }
+ repository_egress { 1 }
+ artifacts_egress { 2 }
+ packages_egress { 3 }
+ registry_egress { 4 }
end
end
diff --git a/spec/factories/resource_events/abuse_report_events.rb b/spec/factories/resource_events/abuse_report_events.rb
new file mode 100644
index 00000000000..0771a37f01b
--- /dev/null
+++ b/spec/factories/resource_events/abuse_report_events.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :abuse_report_event, class: 'ResourceEvents::AbuseReportEvent' do
+ action { :ban_user }
+ abuse_report
+ user
+ end
+end
diff --git a/spec/factories/resource_events/issue_assignment_events.rb b/spec/factories/resource_events/issue_assignment_events.rb
new file mode 100644
index 00000000000..72319905d0d
--- /dev/null
+++ b/spec/factories/resource_events/issue_assignment_events.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :issue_assignment_event, class: 'ResourceEvents::IssueAssignmentEvent' do
+ action { :add }
+ issue
+ user
+ end
+end
diff --git a/spec/factories/resource_events/merge_request_assignment_events.rb b/spec/factories/resource_events/merge_request_assignment_events.rb
new file mode 100644
index 00000000000..6d388543648
--- /dev/null
+++ b/spec/factories/resource_events/merge_request_assignment_events.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :merge_request_assignment_event, class: 'ResourceEvents::MergeRequestAssignmentEvent' do
+ action { :add }
+ merge_request
+ user
+ end
+end
diff --git a/spec/factories/search_index.rb b/spec/factories/search_index.rb
new file mode 100644
index 00000000000..15d7024dbf1
--- /dev/null
+++ b/spec/factories/search_index.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :search_index, class: 'Search::Index' do
+ initialize_with { type.present? ? type.new : Search::Index.new }
+ sequence(:path) { |n| "index-path-#{n}" }
+ sequence(:bucket_number) { |n| n }
+ type { Search::NoteIndex }
+ end
+end
diff --git a/spec/factories/serverless/domain.rb b/spec/factories/serverless/domain.rb
deleted file mode 100644
index c09af068d19..00000000000
--- a/spec/factories/serverless/domain.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: true
-
-FactoryBot.define do
- factory :serverless_domain, class: '::Serverless::Domain' do
- function_name { 'test-function' }
- serverless_domain_cluster { association(:serverless_domain_cluster) }
- environment { association(:environment) }
-
- skip_create
- end
-end
diff --git a/spec/factories/serverless/domain_cluster.rb b/spec/factories/serverless/domain_cluster.rb
deleted file mode 100644
index e8ff6cf42b2..00000000000
--- a/spec/factories/serverless/domain_cluster.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-FactoryBot.define do
- factory :serverless_domain_cluster, class: '::Serverless::DomainCluster' do
- pages_domain { association(:pages_domain) }
- knative { association(:clusters_applications_knative) }
- creator { association(:user) }
-
- certificate do
- File.read(Rails.root.join('spec/fixtures/', 'ssl_certificate.pem'))
- end
-
- key do
- File.read(Rails.root.join('spec/fixtures/', 'ssl_key.pem'))
- end
- end
-end
diff --git a/spec/factories/service_desk/custom_email_credential.rb b/spec/factories/service_desk/custom_email_credential.rb
new file mode 100644
index 00000000000..da131dd8250
--- /dev/null
+++ b/spec/factories/service_desk/custom_email_credential.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :service_desk_custom_email_credential, class: '::ServiceDesk::CustomEmailCredential' do
+ project
+ smtp_address { "smtp.example.com" }
+ smtp_username { "text@example.com" }
+ smtp_port { 587 }
+ smtp_password { "supersecret" }
+ end
+end
diff --git a/spec/factories/service_desk/custom_email_verification.rb b/spec/factories/service_desk/custom_email_verification.rb
new file mode 100644
index 00000000000..3f3a2ea570d
--- /dev/null
+++ b/spec/factories/service_desk/custom_email_verification.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :service_desk_custom_email_verification, class: '::ServiceDesk::CustomEmailVerification' do
+ state { 'started' }
+ token { 'XXXXXXXXXXXX' }
+ project
+ triggerer factory: :user
+ triggered_at { Time.current }
+ end
+end
diff --git a/spec/factories/slack_integrations.rb b/spec/factories/slack_integrations.rb
new file mode 100644
index 00000000000..a43ba8e7453
--- /dev/null
+++ b/spec/factories/slack_integrations.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :slack_integration do
+ sequence(:team_id) { |n| "T123#{n}" }
+ sequence(:user_id) { |n| "U123#{n}" }
+ sequence(:bot_user_id) { |n| "U123#{n}" }
+ sequence(:bot_access_token) { |n| OpenSSL::Digest::SHA256.hexdigest(n.to_s) }
+ sequence(:team_name) { |n| "team#{n}" }
+ sequence(:alias) { |n| "namespace#{n}/project_name#{n}" }
+
+ integration { association :gitlab_slack_application_integration, slack_integration: instance }
+
+ trait :legacy do
+ bot_user_id { nil }
+ bot_access_token { nil }
+ end
+
+ trait :all_features_supported do
+ after(:build) do |slack_integration, _evaluator|
+ slack_integration.authorized_scope_names = %w[commands chat:write chat:write.public]
+ end
+ end
+ end
+end
diff --git a/spec/factories/u2f_registrations.rb b/spec/factories/u2f_registrations.rb
deleted file mode 100644
index 40ad221415c..00000000000
--- a/spec/factories/u2f_registrations.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-# frozen_string_literal: true
-
-FactoryBot.define do
- factory :u2f_registration do
- user
-
- certificate { FFaker::BaconIpsum.characters(728) }
- key_handle { FFaker::BaconIpsum.characters(86) }
- public_key { FFaker::BaconIpsum.characters(88) }
- counter { 0 }
- end
-end
diff --git a/spec/factories/users.rb b/spec/factories/users.rb
index e641f925758..351583b7ef6 100644
--- a/spec/factories/users.rb
+++ b/spec/factories/users.rb
@@ -10,6 +10,7 @@ FactoryBot.define do
confirmed_at { Time.now }
confirmation_token { nil }
can_create_group { true }
+ color_scheme_id { 1 }
trait :admin do
admin { true }
@@ -59,6 +60,10 @@ FactoryBot.define do
user_type { :project_bot }
end
+ trait :service_account do
+ user_type { :service_account }
+ end
+
trait :migration_bot do
user_type { :migration_bot }
end
@@ -67,6 +72,10 @@ FactoryBot.define do
user_type { :security_bot }
end
+ trait :llm_bot do
+ user_type { :llm_bot }
+ end
+
trait :external do
external { true }
end
@@ -111,14 +120,6 @@ FactoryBot.define do
end
end
- trait :two_factor_via_u2f do
- transient { registrations_count { 5 } }
-
- after(:create) do |user, evaluator|
- create_list(:u2f_registration, evaluator.registrations_count, user: user)
- end
- end
-
trait :two_factor_via_webauthn do
transient { registrations_count { 5 } }
diff --git a/spec/factories/users/banned_users.rb b/spec/factories/users/banned_users.rb
new file mode 100644
index 00000000000..f2b6eb5893a
--- /dev/null
+++ b/spec/factories/users/banned_users.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :banned_user, class: 'Users::BannedUser' do
+ user { association(:user) }
+ end
+end
diff --git a/spec/factories/work_items.rb b/spec/factories/work_items.rb
index cff246d4071..10764457d84 100644
--- a/spec/factories/work_items.rb
+++ b/spec/factories/work_items.rb
@@ -14,6 +14,19 @@ FactoryBot.define do
confidential { true }
end
+ trait :opened do
+ state_id { WorkItem.available_states[:opened] }
+ end
+
+ trait :locked do
+ discussion_locked { true }
+ end
+
+ trait :closed do
+ state_id { WorkItem.available_states[:closed] }
+ closed_at { Time.now }
+ end
+
trait :task do
issue_type { :task }
association :work_item_type, :default, :task
@@ -24,6 +37,16 @@ FactoryBot.define do
association :work_item_type, :default, :incident
end
+ trait :requirement do
+ issue_type { :requirement }
+ association :work_item_type, :default, :requirement
+ end
+
+ trait :test_case do
+ issue_type { :test_case }
+ association :work_item_type, :default, :test_case
+ end
+
trait :last_edited_by_user do
association :last_edited_by, factory: :user
end
@@ -37,5 +60,12 @@ FactoryBot.define do
issue_type { :key_result }
association :work_item_type, :default, :key_result
end
+
+ before(:create, :build) do |work_item, evaluator|
+ if evaluator.namespace.present?
+ work_item.project = nil
+ work_item.namespace = evaluator.namespace
+ end
+ end
end
end
diff --git a/spec/factories/work_items/resource_link_events.rb b/spec/factories/work_items/resource_link_events.rb
new file mode 100644
index 00000000000..696f6dcc43f
--- /dev/null
+++ b/spec/factories/work_items/resource_link_events.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :resource_link_event, class: 'WorkItems::ResourceLinkEvent' do
+ action { :add }
+ issue { association(:issue) }
+ user { issue&.author || association(:user) }
+ child_work_item { association(:work_item, :task) }
+ end
+end