diff options
Diffstat (limited to 'spec/factories')
34 files changed, 233 insertions, 189 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 9f05d183ba4..699da744fab 100644 --- a/spec/factories/abuse_reports.rb +++ b/spec/factories/abuse_reports.rb @@ -11,5 +11,9 @@ FactoryBot.define do 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/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/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 index 0181def26ba..34238760112 100644 --- a/spec/factories/ci/runner_machine_builds.rb +++ b/spec/factories/ci/runner_machine_builds.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true FactoryBot.define do - factory :ci_runner_machine_build, class: 'Ci::RunnerMachineBuild' do + factory :ci_runner_machine_build, class: 'Ci::RunnerManagerBuild' do build factory: :ci_build, scheduling_type: :dag - runner_machine factory: :ci_runner_machine + 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 a9a637b4284..f001cecd28e 100644 --- a/spec/factories/ci/runners.rb +++ b/spec/factories/ci/runners.rb @@ -66,9 +66,9 @@ FactoryBot.define do end end - trait :with_runner_machine do + trait :with_runner_manager do after(:build) do |runner, evaluator| - runner.runner_machines << build(:ci_runner_machine, runner: runner) + runner.runner_managers << build(:ci_runner_machine, runner: runner) end 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 99110a9b841..00000000000 --- a/spec/factories/clusters/applications/helm.rb +++ /dev/null @@ -1,115 +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_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 d92ee6dcbe7..2785a8c9946 100644 --- a/spec/factories/clusters/clusters.rb +++ b/spec/factories/clusters/clusters.rb @@ -82,22 +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 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_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/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..c8ee52019a4 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) } diff --git a/spec/factories/integrations.rb b/spec/factories/integrations.rb index caeac6e3b92..d765e5562b6 100644 --- a/spec/factories/integrations.rb +++ b/spec/factories/integrations.rb @@ -88,6 +88,8 @@ FactoryBot.define do 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 } @@ -270,6 +272,7 @@ FactoryBot.define do 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 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/ml/candidates.rb b/spec/factories/ml/candidates.rb index 1b41e39d711..9d049987cfd 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,10 @@ 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 2a21bde5436..c58e7bb2e79 100644 --- a/spec/factories/notes.rb +++ b/spec/factories/notes.rb @@ -196,6 +196,10 @@ FactoryBot.define do confidential { true } end + trait :internal do + internal { true } + end + trait :with_review do review end diff --git a/spec/factories/packages/debian/file_metadatum.rb b/spec/factories/packages/debian/file_metadatum.rb index ef6c4e1f222..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' } @@ -32,19 +39,20 @@ FactoryBot.define do 'Source' => package_file.package.name, '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-ddeb deb libs optional arch=any', - sample-dev deb libdevel optional arch=any', - sample-udeb udeb libs optional arch=any', - EOF + '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", + 'Checksums-Sha256' => + "\nc9d05185ca158bb804977fa9d7b922e8a0f644a2da41f99d2787dd61b1e2e2c5 964 sample_1.2.3~alpha2.tar.xz", 'Files' => "\nadc69e57cda38d9bb7c8d59cacfb6869 964 sample_1.2.3~alpha2.tar.xz" } end @@ -56,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 @@ -93,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 @@ -107,28 +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' } } + 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..b06915bcb46 --- /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 { 'unnamed' } + size { 100.kilobytes } + end +end diff --git a/spec/factories/packages/package_files.rb b/spec/factories/packages/package_files.rb index ababa8fa7f5..4a2d412832c 100644 --- a/spec/factories/packages/package_files.rb +++ b/spec/factories/packages/package_files.rb @@ -215,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 1d5119638ca..283df3428db 100644 --- a/spec/factories/packages/packages.rb +++ b/spec/factories/packages/packages.rb @@ -78,13 +78,17 @@ 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 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 299dd165807..c078514514b 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -535,4 +535,11 @@ FactoryBot.define do trait :in_subgroup do namespace factory: [:group, :nested] end + + trait :readme do + custom_repo + + name { '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/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/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/users.rb b/spec/factories/users.rb index 10de7bc3b5b..368623b9aff 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -72,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 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 |