summaryrefslogtreecommitdiff
path: root/spec/factories
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-12-17 11:59:07 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-17 11:59:07 +0000
commit8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch)
tree544930fb309b30317ae9797a9683768705d664c4 /spec/factories
parent4b1de649d0168371549608993deac953eb692019 (diff)
downloadgitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/factories')
-rw-r--r--spec/factories/alert_management/http_integrations.rb4
-rw-r--r--spec/factories/analytics/devops_adoption/segment_selections.rb18
-rw-r--r--spec/factories/analytics/devops_adoption/segments.rb7
-rw-r--r--spec/factories/bulk_import/failures.rb14
-rw-r--r--spec/factories/ci/builds.rb6
-rw-r--r--spec/factories/ci/job_artifacts.rb22
-rw-r--r--spec/factories/ci/pipelines.rb22
-rw-r--r--spec/factories/dependency_proxy.rb7
-rw-r--r--spec/factories/experiment_subjects.rb9
-rw-r--r--spec/factories/experiment_users.rb10
-rw-r--r--spec/factories/exported_protected_branches.rb5
-rw-r--r--spec/factories/gitlab/database/postgres_index.rb19
-rw-r--r--spec/factories/gitlab/database/postgres_index_bloat_estimate.rb10
-rw-r--r--spec/factories/gitlab/database/reindexing/reindex_action.rb14
-rw-r--r--spec/factories/gpg_keys.rb5
-rw-r--r--spec/factories/issues.rb4
-rw-r--r--spec/factories/merge_requests.rb26
-rw-r--r--spec/factories/namespace_onboarding_actions.rb8
-rw-r--r--spec/factories/packages.rb7
-rw-r--r--spec/factories/packages/package_file.rb8
-rw-r--r--spec/factories/personal_access_tokens.rb4
-rw-r--r--spec/factories/project_repository_storage_moves.rb2
-rw-r--r--spec/factories/project_settings.rb7
-rw-r--r--spec/factories/projects.rb17
-rw-r--r--spec/factories/sent_notifications.rb2
-rw-r--r--spec/factories/sequences.rb4
-rw-r--r--spec/factories/services.rb6
-rw-r--r--spec/factories/snippet_repository_storage_moves.rb29
-rw-r--r--spec/factories/terraform/state.rb8
-rw-r--r--spec/factories/usage_data.rb7
-rw-r--r--spec/factories/users.rb8
31 files changed, 248 insertions, 71 deletions
diff --git a/spec/factories/alert_management/http_integrations.rb b/spec/factories/alert_management/http_integrations.rb
index 2b5864c8587..405ec09251f 100644
--- a/spec/factories/alert_management/http_integrations.rb
+++ b/spec/factories/alert_management/http_integrations.rb
@@ -11,6 +11,10 @@ FactoryBot.define do
active { false }
end
+ trait :active do
+ active { true }
+ end
+
trait :legacy do
endpoint_identifier { 'legacy' }
end
diff --git a/spec/factories/analytics/devops_adoption/segment_selections.rb b/spec/factories/analytics/devops_adoption/segment_selections.rb
deleted file mode 100644
index 8f10369ba35..00000000000
--- a/spec/factories/analytics/devops_adoption/segment_selections.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-FactoryBot.define do
- factory :devops_adoption_segment_selection, class: 'Analytics::DevopsAdoption::SegmentSelection' do
- association :segment, factory: :devops_adoption_segment
- project
-
- trait :project do
- group { nil }
- project
- end
-
- trait :group do
- project { nil }
- group
- end
- end
-end
diff --git a/spec/factories/analytics/devops_adoption/segments.rb b/spec/factories/analytics/devops_adoption/segments.rb
deleted file mode 100644
index 367ee01fa18..00000000000
--- a/spec/factories/analytics/devops_adoption/segments.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-FactoryBot.define do
- factory :devops_adoption_segment, class: 'Analytics::DevopsAdoption::Segment' do
- sequence(:name) { |n| "Segment #{n}" }
- end
-end
diff --git a/spec/factories/bulk_import/failures.rb b/spec/factories/bulk_import/failures.rb
new file mode 100644
index 00000000000..1ebdfdd6c42
--- /dev/null
+++ b/spec/factories/bulk_import/failures.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+require 'securerandom'
+
+FactoryBot.define do
+ factory :bulk_import_failure, class: 'BulkImports::Failure' do
+ association :entity, factory: :bulk_import_entity
+
+ pipeline_class { 'BulkImports::TestPipeline' }
+ exception_class { 'StandardError' }
+ exception_message { 'Standard Error Message' }
+ correlation_id_value { SecureRandom.uuid }
+ end
+end
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb
index 11719e40cf2..c3d6e9d7569 100644
--- a/spec/factories/ci/builds.rb
+++ b/spec/factories/ci/builds.rb
@@ -356,6 +356,12 @@ FactoryBot.define do
end
end
+ trait :codequality_reports do
+ after(:build) do |build|
+ build.job_artifacts << create(:ci_job_artifact, :codequality, job: build)
+ end
+ end
+
trait :terraform_reports do
after(:build) do |build|
build.job_artifacts << create(:ci_job_artifact, :terraform, job: build)
diff --git a/spec/factories/ci/job_artifacts.rb b/spec/factories/ci/job_artifacts.rb
index 223184891b7..ad98e9d1f24 100644
--- a/spec/factories/ci/job_artifacts.rb
+++ b/spec/factories/ci/job_artifacts.rb
@@ -229,6 +229,16 @@ FactoryBot.define do
end
end
+ trait :coverage_with_paths_not_relative_to_project_root do
+ file_type { :cobertura }
+ file_format { :gzip }
+
+ after(:build) do |artifact, evaluator|
+ artifact.file = fixture_file_upload(
+ Rails.root.join('spec/fixtures/cobertura/coverage_with_paths_not_relative_to_project_root.xml.gz'), 'application/x-gzip')
+ end
+ end
+
trait :coverage_with_corrupted_data do
file_type { :cobertura }
file_format { :gzip }
@@ -245,7 +255,17 @@ FactoryBot.define do
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
- Rails.root.join('spec/fixtures/codequality/codequality.json'), 'application/json')
+ Rails.root.join('spec/fixtures/codequality/codeclimate.json'), 'application/json')
+ end
+ end
+
+ trait :codequality_without_errors do
+ file_type { :codequality }
+ file_format { :raw }
+
+ after(:build) do |artifact, evaluator|
+ artifact.file = fixture_file_upload(
+ Rails.root.join('spec/fixtures/codequality/codeclimate_without_errors.json'), 'application/json')
end
end
diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb
index 14bd0ab1bc6..86a8b008e48 100644
--- a/spec/factories/ci/pipelines.rb
+++ b/spec/factories/ci/pipelines.rb
@@ -16,6 +16,7 @@ FactoryBot.define do
transient { head_pipeline_of { nil } }
transient { child_of { nil } }
+ transient { upstream_of { nil } }
after(:build) do |pipeline, evaluator|
if evaluator.child_of
@@ -30,9 +31,12 @@ FactoryBot.define do
if evaluator.child_of
bridge = create(:ci_bridge, pipeline: evaluator.child_of)
- create(:ci_sources_pipeline,
- source_job: bridge,
- pipeline: pipeline)
+ create(:ci_sources_pipeline, source_job: bridge, pipeline: pipeline)
+ end
+
+ if evaluator.upstream_of
+ bridge = create(:ci_bridge, pipeline: pipeline)
+ create(:ci_sources_pipeline, source_job: bridge, pipeline: evaluator.upstream_of)
end
end
@@ -122,10 +126,10 @@ FactoryBot.define do
end
trait :with_test_reports_with_three_failures do
- status { :success }
+ status { :failed }
after(:build) do |pipeline, _evaluator|
- pipeline.builds << build(:ci_build, :test_reports_with_three_failures, pipeline: pipeline, project: pipeline.project)
+ pipeline.builds << build(:ci_build, :failed, :test_reports_with_three_failures, pipeline: pipeline, project: pipeline.project)
end
end
@@ -145,6 +149,14 @@ FactoryBot.define do
end
end
+ trait :with_codequality_reports do
+ status { :success }
+
+ after(:build) do |pipeline, evaluator|
+ pipeline.builds << build(:ci_build, :codequality_reports, pipeline: pipeline, project: pipeline.project)
+ end
+ end
+
trait :with_coverage_report_artifact do
after(:build) do |pipeline, evaluator|
pipeline.pipeline_artifacts << build(:ci_pipeline_artifact, pipeline: pipeline, project: pipeline.project)
diff --git a/spec/factories/dependency_proxy.rb b/spec/factories/dependency_proxy.rb
index 5d763392a99..de95df19876 100644
--- a/spec/factories/dependency_proxy.rb
+++ b/spec/factories/dependency_proxy.rb
@@ -6,4 +6,11 @@ FactoryBot.define do
file { fixture_file_upload('spec/fixtures/dependency_proxy/a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4.gz') }
file_name { 'a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4.gz' }
end
+
+ factory :dependency_proxy_manifest, class: 'DependencyProxy::Manifest' do
+ group
+ file { fixture_file_upload('spec/fixtures/dependency_proxy/manifest') }
+ digest { 'sha256:5ab5a6872b264fe4fd35d63991b9b7d8425f4bc79e7cf4d563c10956581170c9' }
+ file_name { 'alpine:latest.json' }
+ end
end
diff --git a/spec/factories/experiment_subjects.rb b/spec/factories/experiment_subjects.rb
new file mode 100644
index 00000000000..c35bc370bad
--- /dev/null
+++ b/spec/factories/experiment_subjects.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :experiment_subject do
+ experiment
+ user
+ variant { :control }
+ end
+end
diff --git a/spec/factories/experiment_users.rb b/spec/factories/experiment_users.rb
new file mode 100644
index 00000000000..66c39d684eb
--- /dev/null
+++ b/spec/factories/experiment_users.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :experiment_user do
+ experiment
+ user
+ group_type { :control }
+ converted_at { nil }
+ end
+end
diff --git a/spec/factories/exported_protected_branches.rb b/spec/factories/exported_protected_branches.rb
new file mode 100644
index 00000000000..7ad49b12e5b
--- /dev/null
+++ b/spec/factories/exported_protected_branches.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :exported_protected_branch, class: 'ExportedProtectedBranch', parent: :protected_branch
+end
diff --git a/spec/factories/gitlab/database/postgres_index.rb b/spec/factories/gitlab/database/postgres_index.rb
new file mode 100644
index 00000000000..54bbb738512
--- /dev/null
+++ b/spec/factories/gitlab/database/postgres_index.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :postgres_index, class: 'Gitlab::Database::PostgresIndex' do
+ identifier { "public.some_index_#{indexrelid}" }
+ sequence(:indexrelid) { |n| n }
+ schema { 'public' }
+ name { "some_index_#{indexrelid}" }
+ tablename { 'foo' }
+ unique { false }
+ valid_index { true }
+ partitioned { false }
+ exclusion { false }
+ expression { false }
+ partial { false }
+ definition { "CREATE INDEX #{identifier} ON #{tablename} (bar)"}
+ ondisk_size_bytes { 100.megabytes }
+ end
+end
diff --git a/spec/factories/gitlab/database/postgres_index_bloat_estimate.rb b/spec/factories/gitlab/database/postgres_index_bloat_estimate.rb
new file mode 100644
index 00000000000..878650714b8
--- /dev/null
+++ b/spec/factories/gitlab/database/postgres_index_bloat_estimate.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :postgres_index_bloat_estimate, class: 'Gitlab::Database::PostgresIndexBloatEstimate' do
+ association :index, factory: :postgres_index
+
+ identifier { index.identifier }
+ bloat_size_bytes { 10.megabytes }
+ end
+end
diff --git a/spec/factories/gitlab/database/reindexing/reindex_action.rb b/spec/factories/gitlab/database/reindexing/reindex_action.rb
new file mode 100644
index 00000000000..4b558286463
--- /dev/null
+++ b/spec/factories/gitlab/database/reindexing/reindex_action.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :reindex_action, class: 'Gitlab::Database::Reindexing::ReindexAction' do
+ association :index, factory: :postgres_index
+
+ action_start { Time.now - 10.minutes }
+ action_end { Time.now - 5.minutes }
+ ondisk_size_bytes_start { 2.megabytes }
+ ondisk_size_bytes_end { 1.megabytes }
+ state { Gitlab::Database::Reindexing::ReindexAction.states[:finished] }
+ index_identifier { index.identifier }
+ end
+end
diff --git a/spec/factories/gpg_keys.rb b/spec/factories/gpg_keys.rb
index 9f321643174..5967d9ba9d3 100644
--- a/spec/factories/gpg_keys.rb
+++ b/spec/factories/gpg_keys.rb
@@ -10,5 +10,10 @@ FactoryBot.define do
factory :gpg_key_with_subkeys do
key { GpgHelpers::User1.public_key_with_extra_signing_key }
end
+
+ factory :another_gpg_key do
+ key { GpgHelpers::User1.public_key2 }
+ user
+ end
end
end
diff --git a/spec/factories/issues.rb b/spec/factories/issues.rb
index 90e43b9e22c..5c62de4d08d 100644
--- a/spec/factories/issues.rb
+++ b/spec/factories/issues.rb
@@ -52,9 +52,5 @@ FactoryBot.define do
factory :incident do
issue_type { :incident }
end
-
- factory :quality_test_case do
- issue_type { :test_case }
- end
end
end
diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb
index e5381071228..e69743122cc 100644
--- a/spec/factories/merge_requests.rb
+++ b/spec/factories/merge_requests.rb
@@ -24,6 +24,14 @@ FactoryBot.define do
trait :with_diffs do
end
+ trait :jira_title do
+ title { generate(:jira_title) }
+ end
+
+ trait :jira_branch do
+ source_branch { generate(:jira_branch) }
+ end
+
trait :with_image_diffs do
source_branch { "add_images_and_changes" }
target_branch { "master" }
@@ -52,7 +60,7 @@ FactoryBot.define do
after(:build) do |merge_request, evaluator|
metrics = merge_request.build_metrics
- metrics.merged_at = 1.week.ago
+ metrics.merged_at = 1.week.from_now
metrics.merged_by = evaluator.merged_by
metrics.pipeline = create(:ci_empty_pipeline)
end
@@ -159,6 +167,18 @@ FactoryBot.define do
end
end
+ trait :with_codequality_reports do
+ after(:build) do |merge_request|
+ merge_request.head_pipeline = build(
+ :ci_pipeline,
+ :success,
+ :with_codequality_reports,
+ project: merge_request.source_project,
+ ref: merge_request.source_branch,
+ sha: merge_request.diff_head_sha)
+ end
+ end
+
trait :unique_branches do
source_branch { generate(:branch) }
target_branch { generate(:branch) }
@@ -237,7 +257,7 @@ FactoryBot.define do
target_branch { 'pages-deploy-target' }
transient do
- deployment { create(:deployment, :review_app) }
+ deployment { association(:deployment, :review_app) }
end
after(:build) do |merge_request, evaluator|
@@ -256,7 +276,7 @@ FactoryBot.define do
source_project = merge_request.source_project
# Fake `fetch_ref!` if we don't have repository
- # We have too many existing tests replying on this behaviour
+ # We have too many existing tests relying on this behaviour
unless [target_project, source_project].all?(&:repository_exists?)
allow(merge_request).to receive(:fetch_ref!)
end
diff --git a/spec/factories/namespace_onboarding_actions.rb b/spec/factories/namespace_onboarding_actions.rb
new file mode 100644
index 00000000000..aca62013b57
--- /dev/null
+++ b/spec/factories/namespace_onboarding_actions.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :namespace_onboarding_action do
+ namespace
+ action { :subscription_created }
+ end
+end
diff --git a/spec/factories/packages.rb b/spec/factories/packages.rb
index 73870a28b89..5543be4aa82 100644
--- a/spec/factories/packages.rb
+++ b/spec/factories/packages.rb
@@ -22,7 +22,14 @@ FactoryBot.define do
end
factory :debian_package do
+ sequence(:name) { |n| "package-#{n}" }
+ sequence(:version) { |n| "1.0-#{n}" }
package_type { :debian }
+
+ factory :debian_incoming do
+ name { 'incoming' }
+ version { nil }
+ end
end
factory :npm_package do
diff --git a/spec/factories/packages/package_file.rb b/spec/factories/packages/package_file.rb
index 643ab8e4f95..bee1b2076df 100644
--- a/spec/factories/packages/package_file.rb
+++ b/spec/factories/packages/package_file.rb
@@ -152,14 +152,6 @@ FactoryBot.define do
file_store { Packages::PackageFileUploader::Store::REMOTE }
end
- trait(:checksummed) do
- verification_checksum { 'abc' }
- end
-
- trait(:checksum_failure) do
- verification_failure { 'Could not calculate the checksum' }
- end
-
factory :package_file_with_file, traits: [:jar]
end
end
diff --git a/spec/factories/personal_access_tokens.rb b/spec/factories/personal_access_tokens.rb
index d8ff2e08657..9625fdc195d 100644
--- a/spec/factories/personal_access_tokens.rb
+++ b/spec/factories/personal_access_tokens.rb
@@ -26,5 +26,9 @@ FactoryBot.define do
trait :invalid do
token_digest { nil }
end
+
+ trait :no_prefix do
+ after(:build) { |personal_access_token| personal_access_token.set_token(Devise.friendly_token) }
+ end
end
end
diff --git a/spec/factories/project_repository_storage_moves.rb b/spec/factories/project_repository_storage_moves.rb
index c0068de5f58..5df2b7c32d6 100644
--- a/spec/factories/project_repository_storage_moves.rb
+++ b/spec/factories/project_repository_storage_moves.rb
@@ -2,7 +2,7 @@
FactoryBot.define do
factory :project_repository_storage_move, class: 'ProjectRepositoryStorageMove' do
- project
+ container { association(:project) }
source_storage_name { 'default' }
diff --git a/spec/factories/project_settings.rb b/spec/factories/project_settings.rb
new file mode 100644
index 00000000000..c0c5039ab51
--- /dev/null
+++ b/spec/factories/project_settings.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :project_setting do
+ project
+ end
+end
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb
index 639fff06cec..29a25e71095 100644
--- a/spec/factories/projects.rb
+++ b/spec/factories/projects.rb
@@ -32,10 +32,13 @@ FactoryBot.define do
visibility_level == Gitlab::VisibilityLevel::PUBLIC ? ProjectFeature::ENABLED : ProjectFeature::PRIVATE
end
metrics_dashboard_access_level { ProjectFeature::PRIVATE }
+ operations_access_level { ProjectFeature::ENABLED }
# we can't assign the delegated `#ci_cd_settings` attributes directly, as the
# `#ci_cd_settings` relation needs to be created first
group_runners_enabled { nil }
+ merge_pipelines_enabled { nil }
+ merge_trains_enabled { nil }
import_status { nil }
import_jid { nil }
import_correlation_id { nil }
@@ -57,7 +60,8 @@ FactoryBot.define do
merge_requests_access_level: merge_requests_access_level,
repository_access_level: evaluator.repository_access_level,
pages_access_level: evaluator.pages_access_level,
- metrics_dashboard_access_level: evaluator.metrics_dashboard_access_level
+ metrics_dashboard_access_level: evaluator.metrics_dashboard_access_level,
+ operations_access_level: evaluator.operations_access_level
}
project.build_project_feature(hash)
@@ -75,7 +79,9 @@ FactoryBot.define do
project.group&.refresh_members_authorized_projects
# assign the delegated `#ci_cd_settings` attributes after create
- project.reload.group_runners_enabled = evaluator.group_runners_enabled unless evaluator.group_runners_enabled.nil?
+ project.group_runners_enabled = evaluator.group_runners_enabled unless evaluator.group_runners_enabled.nil?
+ project.merge_pipelines_enabled = evaluator.merge_pipelines_enabled unless evaluator.merge_pipelines_enabled.nil?
+ project.merge_trains_enabled = evaluator.merge_trains_enabled unless evaluator.merge_trains_enabled.nil?
if evaluator.import_status
import_state = project.import_state || project.build_import_state
@@ -322,6 +328,9 @@ FactoryBot.define do
trait(:metrics_dashboard_enabled) { metrics_dashboard_access_level { ProjectFeature::ENABLED } }
trait(:metrics_dashboard_disabled) { metrics_dashboard_access_level { ProjectFeature::DISABLED } }
trait(:metrics_dashboard_private) { metrics_dashboard_access_level { ProjectFeature::PRIVATE } }
+ trait(:operations_enabled) { operations_access_level { ProjectFeature::ENABLED } }
+ trait(:operations_disabled) { operations_access_level { ProjectFeature::DISABLED } }
+ trait(:operations_private) { operations_access_level { ProjectFeature::PRIVATE } }
trait :auto_devops do
association :auto_devops, factory: :project_auto_devops
@@ -389,10 +398,6 @@ FactoryBot.define do
jira_service
end
- factory :mock_deployment_project, parent: :project do
- mock_deployment_service
- end
-
factory :prometheus_project, parent: :project do
after :create do |project|
project.create_prometheus_service(
diff --git a/spec/factories/sent_notifications.rb b/spec/factories/sent_notifications.rb
index 11116af7dbb..f10a3235202 100644
--- a/spec/factories/sent_notifications.rb
+++ b/spec/factories/sent_notifications.rb
@@ -4,7 +4,7 @@ FactoryBot.define do
factory :sent_notification do
project
recipient { project.creator }
- noteable { create(:issue, project: project) }
+ noteable { association(:issue, project: project) }
reply_key { SentNotification.reply_key }
end
end
diff --git a/spec/factories/sequences.rb b/spec/factories/sequences.rb
index ca0804965df..b338fd99625 100644
--- a/spec/factories/sequences.rb
+++ b/spec/factories/sequences.rb
@@ -13,4 +13,8 @@ FactoryBot.define do
sequence(:past_time) { |n| 4.hours.ago + (2 * n).seconds }
sequence(:iid)
sequence(:sha) { |n| Digest::SHA1.hexdigest("commit-like-#{n}") }
+ sequence(:oid) { |n| Digest::SHA2.hexdigest("oid-like-#{n}") }
+ sequence(:variable) { |n| "var#{n}" }
+ sequence(:jira_title) { |n| "[PROJ-#{n}]: fix bug" }
+ sequence(:jira_branch) { |n| "feature/PROJ-#{n}" }
end
diff --git a/spec/factories/services.rb b/spec/factories/services.rb
index 1935ace8e96..44b157014a5 100644
--- a/spec/factories/services.rb
+++ b/spec/factories/services.rb
@@ -27,12 +27,6 @@ FactoryBot.define do
end
end
- factory :mock_deployment_service do
- project
- type { 'MockDeploymentService' }
- active { true }
- end
-
factory :prometheus_service do
project
active { true }
diff --git a/spec/factories/snippet_repository_storage_moves.rb b/spec/factories/snippet_repository_storage_moves.rb
new file mode 100644
index 00000000000..ed65dc5374f
--- /dev/null
+++ b/spec/factories/snippet_repository_storage_moves.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :snippet_repository_storage_move, class: 'SnippetRepositoryStorageMove' do
+ container { association(:snippet) }
+
+ source_storage_name { 'default' }
+
+ trait :scheduled do
+ state { SnippetRepositoryStorageMove.state_machines[:state].states[:scheduled].value }
+ end
+
+ trait :started do
+ state { SnippetRepositoryStorageMove.state_machines[:state].states[:started].value }
+ end
+
+ trait :replicated do
+ state { SnippetRepositoryStorageMove.state_machines[:state].states[:replicated].value }
+ end
+
+ trait :finished do
+ state { SnippetRepositoryStorageMove.state_machines[:state].states[:finished].value }
+ end
+
+ trait :failed do
+ state { SnippetRepositoryStorageMove.state_machines[:state].states[:failed].value }
+ end
+ end
+end
diff --git a/spec/factories/terraform/state.rb b/spec/factories/terraform/state.rb
index c54a8aedbc6..fb63c845073 100644
--- a/spec/factories/terraform/state.rb
+++ b/spec/factories/terraform/state.rb
@@ -6,11 +6,6 @@ FactoryBot.define do
sequence(:name) { |n| "state-#{n}" }
- trait :with_file do
- versioning_enabled { false }
- file { fixture_file_upload('spec/fixtures/terraform/terraform.tfstate', 'application/json') }
- end
-
trait :locked do
sequence(:lock_xid) { |n| "lock-#{n}" }
locked_at { Time.current }
@@ -22,8 +17,5 @@ FactoryBot.define do
create(:terraform_state_version, terraform_state: state)
end
end
-
- # Remove with https://gitlab.com/gitlab-org/gitlab/-/issues/235108
- factory :legacy_terraform_state, parent: :terraform_state, traits: [:with_file]
end
end
diff --git a/spec/factories/usage_data.rb b/spec/factories/usage_data.rb
index 87f806a3d74..f933461a07a 100644
--- a/spec/factories/usage_data.rb
+++ b/spec/factories/usage_data.rb
@@ -19,15 +19,16 @@ FactoryBot.define do
create(:jira_import_state, :finished, project: projects[1], label: jira_label, imported_issues_count: 3)
create(:jira_import_state, :scheduled, project: projects[1], label: jira_label)
create(:prometheus_service, project: projects[1])
+ create(:service, project: projects[1], type: 'JenkinsService', active: true)
create(:service, project: projects[0], type: 'SlackSlashCommandsService', active: true)
create(:service, project: projects[1], type: 'SlackService', active: true)
create(:service, project: projects[2], type: 'SlackService', active: true)
create(:service, project: projects[2], type: 'MattermostService', active: false)
create(:service, group: group, project: nil, type: 'MattermostService', active: true)
create(:service, :template, type: 'MattermostService', active: true)
- matermost_instance = create(:service, :instance, type: 'MattermostService', active: true)
- create(:service, project: projects[1], type: 'MattermostService', active: true, inherit_from_id: matermost_instance.id)
- create(:service, group: group, project: nil, type: 'SlackService', active: true, inherit_from_id: matermost_instance.id)
+ mattermost_instance = create(:service, :instance, type: 'MattermostService', active: true)
+ create(:service, project: projects[1], type: 'MattermostService', active: true, inherit_from_id: mattermost_instance.id)
+ create(:service, group: group, project: nil, type: 'SlackService', active: true, inherit_from_id: mattermost_instance.id)
create(:service, project: projects[2], type: 'CustomIssueTrackerService', active: true)
create(:project_error_tracking_setting, project: projects[0])
create(:project_error_tracking_setting, project: projects[1], enabled: false)
diff --git a/spec/factories/users.rb b/spec/factories/users.rb
index 1b430009ab5..9b5e4a981a0 100644
--- a/spec/factories/users.rb
+++ b/spec/factories/users.rb
@@ -35,6 +35,10 @@ FactoryBot.define do
user_type { :alert_bot }
end
+ trait :deactivated do
+ after(:build) { |user, _| user.deactivate! }
+ end
+
trait :project_bot do
user_type { :project_bot }
end
@@ -43,6 +47,10 @@ FactoryBot.define do
user_type { :migration_bot }
end
+ trait :security_bot do
+ user_type { :security_bot }
+ end
+
trait :external do
external { true }
end