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:
Diffstat (limited to 'spec/factories')
-rw-r--r--spec/factories/ci/pipelines.rb6
-rw-r--r--spec/factories/clusters/agents/activity_events.rb13
-rw-r--r--spec/factories/commit_signature/gpg_signature.rb (renamed from spec/factories/gpg_signature.rb)2
-rw-r--r--spec/factories/commit_signature/x509_commit_signature.rb (renamed from spec/factories/x509_commit_signature.rb)2
-rw-r--r--spec/factories/customer_relations/contacts.rb1
-rw-r--r--spec/factories/deployments.rb4
-rw-r--r--spec/factories/gitlab/database/background_migration/batched_migrations.rb8
-rw-r--r--spec/factories/import_failures.rb2
-rw-r--r--spec/factories/issue_emails.rb8
-rw-r--r--spec/factories/namespaces.rb8
-rw-r--r--spec/factories/notes.rb1
-rw-r--r--spec/factories/packages/debian/component_file.rb4
-rw-r--r--spec/factories/packages/package_files.rb8
-rw-r--r--spec/factories/packages/packages.rb6
-rw-r--r--spec/factories/plan_limits.rb1
-rw-r--r--spec/factories/projects.rb2
-rw-r--r--spec/factories/protected_branches.rb16
-rw-r--r--spec/factories/sequences.rb3
-rw-r--r--spec/factories/users/callouts.rb (renamed from spec/factories/user_callouts.rb)2
19 files changed, 82 insertions, 15 deletions
diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb
index 1d25964a4be..b2c1eff6fbd 100644
--- a/spec/factories/ci/pipelines.rb
+++ b/spec/factories/ci/pipelines.rb
@@ -18,15 +18,13 @@ FactoryBot.define do
transient { child_of { nil } }
transient { upstream_of { nil } }
- before(:create) do |pipeline, evaluator|
- pipeline.ensure_project_iid!
- end
-
after(:build) do |pipeline, evaluator|
if evaluator.child_of
pipeline.project = evaluator.child_of.project
pipeline.source = :parent_pipeline
end
+
+ pipeline.ensure_project_iid!
end
after(:create) do |pipeline, evaluator|
diff --git a/spec/factories/clusters/agents/activity_events.rb b/spec/factories/clusters/agents/activity_events.rb
new file mode 100644
index 00000000000..ff73f617964
--- /dev/null
+++ b/spec/factories/clusters/agents/activity_events.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :agent_activity_event, class: 'Clusters::Agents::ActivityEvent' do
+ association :agent, factory: :cluster_agent
+ association :agent_token, factory: :cluster_agent_token
+ user
+
+ kind { :token_created }
+ level { :info }
+ recorded_at { Time.current }
+ end
+end
diff --git a/spec/factories/gpg_signature.rb b/spec/factories/commit_signature/gpg_signature.rb
index 2ab4d190276..50a25291cc7 100644
--- a/spec/factories/gpg_signature.rb
+++ b/spec/factories/commit_signature/gpg_signature.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
FactoryBot.define do
- factory :gpg_signature do
+ factory :gpg_signature, class: 'CommitSignatures::GpgSignature' do
commit_sha { Digest::SHA1.hexdigest(SecureRandom.hex) }
project
gpg_key
diff --git a/spec/factories/x509_commit_signature.rb b/spec/factories/commit_signature/x509_commit_signature.rb
index a342b240690..1de92f56b33 100644
--- a/spec/factories/x509_commit_signature.rb
+++ b/spec/factories/commit_signature/x509_commit_signature.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
FactoryBot.define do
- factory :x509_commit_signature do
+ factory :x509_commit_signature, class: 'CommitSignatures::X509CommitSignature' do
commit_sha { Digest::SHA1.hexdigest(SecureRandom.hex) }
project
x509_certificate
diff --git a/spec/factories/customer_relations/contacts.rb b/spec/factories/customer_relations/contacts.rb
index 437f8feea48..821c45d7514 100644
--- a/spec/factories/customer_relations/contacts.rb
+++ b/spec/factories/customer_relations/contacts.rb
@@ -6,6 +6,7 @@ FactoryBot.define do
first_name { generate(:name) }
last_name { generate(:name) }
+ email { generate(:email) }
trait :with_organization do
organization
diff --git a/spec/factories/deployments.rb b/spec/factories/deployments.rb
index 2aab9764560..ab1b794632a 100644
--- a/spec/factories/deployments.rb
+++ b/spec/factories/deployments.rb
@@ -55,6 +55,10 @@ FactoryBot.define do
status { :created }
end
+ trait :blocked do
+ status { :blocked }
+ end
+
# This trait hooks the state maechine's events
trait :succeed do
after(:create) do |deployment, evaluator|
diff --git a/spec/factories/gitlab/database/background_migration/batched_migrations.rb b/spec/factories/gitlab/database/background_migration/batched_migrations.rb
index de57e0c1565..79b4447b76e 100644
--- a/spec/factories/gitlab/database/background_migration/batched_migrations.rb
+++ b/spec/factories/gitlab/database/background_migration/batched_migrations.rb
@@ -12,5 +12,13 @@ FactoryBot.define do
sequence(:job_arguments) { |n| [["column_#{n}"], ["column_#{n}_convert_to_bigint"]] }
total_tuple_count { 10_000 }
pause_ms { 100 }
+
+ trait :finished do
+ status { :finished }
+ end
+
+ trait :failed do
+ status { :failed }
+ end
end
end
diff --git a/spec/factories/import_failures.rb b/spec/factories/import_failures.rb
index 376b2ff39e2..df0793664f4 100644
--- a/spec/factories/import_failures.rb
+++ b/spec/factories/import_failures.rb
@@ -10,6 +10,8 @@ FactoryBot.define do
exception_class { 'RuntimeError' }
exception_message { 'Something went wrong' }
source { 'method_call' }
+ relation_key { 'issues' }
+ relation_index { 1 }
correlation_id_value { SecureRandom.uuid }
trait :hard_failure do
diff --git a/spec/factories/issue_emails.rb b/spec/factories/issue_emails.rb
new file mode 100644
index 00000000000..edf07aab0cd
--- /dev/null
+++ b/spec/factories/issue_emails.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :issue_email, class: 'Issue::Email' do
+ issue
+ email_message_id { generate(:short_text) }
+ end
+end
diff --git a/spec/factories/namespaces.rb b/spec/factories/namespaces.rb
index 959183f227d..2b3dabc07d8 100644
--- a/spec/factories/namespaces.rb
+++ b/spec/factories/namespaces.rb
@@ -1,12 +1,14 @@
# frozen_string_literal: true
FactoryBot.define do
- factory :namespace do
+ # This factory is called :namespace but actually maps (and always has) to User type
+ # See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74152#note_730034103 for context
+ factory :namespace, class: 'Namespaces::UserNamespace' do
sequence(:name) { |n| "namespace#{n}" }
+ type { Namespaces::UserNamespace.sti_name }
+
path { name.downcase.gsub(/\s/, '_') }
- # TODO: can this be moved into the :user_namespace factory?
- # evaluate in issue https://gitlab.com/gitlab-org/gitlab/-/issues/341070
owner { association(:user, strategy: :build, namespace: instance, username: path) }
trait :with_aggregation_schedule do
diff --git a/spec/factories/notes.rb b/spec/factories/notes.rb
index c15ec91d2ce..2159f5b2dc1 100644
--- a/spec/factories/notes.rb
+++ b/spec/factories/notes.rb
@@ -8,6 +8,7 @@ FactoryBot.define do
note { generate(:title) }
author { project&.creator || association(:user) }
on_issue
+ updated_by { author }
factory :note_on_commit, traits: [:on_commit]
factory :note_on_issue, traits: [:on_issue], aliases: [:votable_note]
diff --git a/spec/factories/packages/debian/component_file.rb b/spec/factories/packages/debian/component_file.rb
index 9aee91b0973..eeba64ba5d2 100644
--- a/spec/factories/packages/debian/component_file.rb
+++ b/spec/factories/packages/debian/component_file.rb
@@ -27,8 +27,8 @@ FactoryBot.define do
file_type { :packages }
end
- trait(:source) do
- file_type { :source }
+ trait(:sources) do
+ file_type { :sources }
architecture { nil }
end
diff --git a/spec/factories/packages/package_files.rb b/spec/factories/packages/package_files.rb
index d9afbac1048..845fd882beb 100644
--- a/spec/factories/packages/package_files.rb
+++ b/spec/factories/packages/package_files.rb
@@ -323,6 +323,14 @@ FactoryBot.define do
size { 1149.bytes }
end
+ trait(:generic_zip) do
+ package
+ file_fixture { 'spec/fixtures/packages/generic/myfile.zip' }
+ file_name { "#{package.name}.zip" }
+ file_sha256 { '3559e770bd493b326e8ec5e6242f7206d3fbf94fa47c16f82d34a037daa113e5' }
+ size { 3989.bytes }
+ end
+
trait(:object_storage) do
file_store { Packages::PackageFileUploader::Store::REMOTE }
end
diff --git a/spec/factories/packages/packages.rb b/spec/factories/packages/packages.rb
index bb9aa95fe08..153518f4cd3 100644
--- a/spec/factories/packages/packages.rb
+++ b/spec/factories/packages/packages.rb
@@ -247,6 +247,12 @@ FactoryBot.define do
sequence(:name) { |n| "generic-package-#{n}" }
version { '1.0.0' }
package_type { :generic }
+
+ trait(:with_zip_file) do
+ after :create do |package|
+ create :package_file, :generic_zip, package: package
+ end
+ end
end
end
end
diff --git a/spec/factories/plan_limits.rb b/spec/factories/plan_limits.rb
index b5921c1b311..ad10629af05 100644
--- a/spec/factories/plan_limits.rb
+++ b/spec/factories/plan_limits.rb
@@ -12,6 +12,7 @@ FactoryBot.define do
trait :with_package_file_sizes do
conan_max_file_size { 100 }
+ helm_max_file_size { 100 }
maven_max_file_size { 100 }
npm_max_file_size { 100 }
nuget_max_file_size { 100 }
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb
index fb86f4672bc..981f10e8260 100644
--- a/spec/factories/projects.rb
+++ b/spec/factories/projects.rb
@@ -190,7 +190,7 @@ FactoryBot.define do
end
after :create do |project, evaluator|
- raise "Failed to create repository!" unless project.create_repository
+ raise "Failed to create repository!" unless project.repository.exists? || project.create_repository
evaluator.files.each do |filename, content|
project.repository.create_file(
diff --git a/spec/factories/protected_branches.rb b/spec/factories/protected_branches.rb
index 2d3abc77350..bac1cf21596 100644
--- a/spec/factories/protected_branches.rb
+++ b/spec/factories/protected_branches.rb
@@ -2,7 +2,7 @@
FactoryBot.define do
factory :protected_branch do
- name
+ sequence(:name) { |n| "protected_branch_#{n}" }
project
transient do
@@ -11,6 +11,20 @@ FactoryBot.define do
default_access_level { true }
end
+ trait :create_branch_on_repository do
+ association :project, factory: [:project, :repository]
+
+ transient do
+ repository_branch_name { name }
+ end
+
+ after(:create) do |protected_branch, evaluator|
+ project = protected_branch.project
+
+ project.repository.create_branch(evaluator.repository_branch_name, project.default_branch_or_main)
+ end
+ end
+
trait :developers_can_push do
transient do
default_push_level { false }
diff --git a/spec/factories/sequences.rb b/spec/factories/sequences.rb
index 0edc2b6027d..893865962d8 100644
--- a/spec/factories/sequences.rb
+++ b/spec/factories/sequences.rb
@@ -2,7 +2,7 @@
FactoryBot.define do
sequence(:username) { |n| "user#{n}" }
- sequence(:name) { |n| "John Doe#{n}" }
+ sequence(:name) { |n| "Sidney Jones#{n}" }
sequence(:email) { |n| "user#{n}@example.org" }
sequence(:email_alias) { |n| "user.alias#{n}@example.org" }
sequence(:title) { |n| "My title #{n}" }
@@ -21,4 +21,5 @@ FactoryBot.define do
sequence(:jira_branch) { |n| "feature/PROJ-#{n}" }
sequence(:job_name) { |n| "job #{n}" }
sequence(:work_item_type_name) { |n| "bug#{n}" }
+ sequence(:short_text) { |n| "someText#{n}" }
end
diff --git a/spec/factories/user_callouts.rb b/spec/factories/users/callouts.rb
index cedc6efd8d7..d9f142fee6f 100644
--- a/spec/factories/user_callouts.rb
+++ b/spec/factories/users/callouts.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
FactoryBot.define do
- factory :user_callout do
+ factory :callout, class: 'Users::Callout' do
feature_name { :gke_cluster_integration }
user