diff options
Diffstat (limited to 'spec/factories')
28 files changed, 315 insertions, 214 deletions
diff --git a/spec/factories/alert_management/alerts.rb b/spec/factories/alert_management/alerts.rb index d931947fff1..d0546657ccf 100644 --- a/spec/factories/alert_management/alerts.rb +++ b/spec/factories/alert_management/alerts.rb @@ -100,7 +100,7 @@ FactoryBot.define do end trait :prometheus do - monitoring_tool { Gitlab::AlertManagement::AlertParams::MONITORING_TOOLS[:prometheus] } + monitoring_tool { Gitlab::AlertManagement::Payload::MONITORING_TOOLS[:prometheus] } payload do { annotations: { @@ -123,5 +123,17 @@ FactoryBot.define do with_description low end + + trait :from_payload do + after(:build) do |alert| + alert_params = ::Gitlab::AlertManagement::Payload.parse( + alert.project, + alert.payload, + monitoring_tool: alert.monitoring_tool + ).alert_params + + alert.assign_attributes(alert_params) + end + end end end diff --git a/spec/factories/alert_management/http_integrations.rb b/spec/factories/alert_management/http_integrations.rb new file mode 100644 index 00000000000..9311cb3e114 --- /dev/null +++ b/spec/factories/alert_management/http_integrations.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :alert_management_http_integration, class: 'AlertManagement::HttpIntegration' do + project + active { true } + name { 'DataDog' } + endpoint_identifier { SecureRandom.hex(4) } + + trait :inactive do + active { false } + end + end +end diff --git a/spec/factories/alerting/alert.rb b/spec/factories/alerting/alert.rb deleted file mode 100644 index 285bb14efa2..00000000000 --- a/spec/factories/alerting/alert.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -FactoryBot.define do - factory :alerting_alert, class: 'Gitlab::Alerting::Alert' do - project - payload { {} } - - transient do - metric_id { nil } - - after(:build) do |alert, evaluator| - unless alert.payload.key?('startsAt') - alert.payload['startsAt'] = Time.now.rfc3339 - end - - if metric_id = evaluator.metric_id - alert.payload['labels'] ||= {} - alert.payload['labels']['gitlab_alert_id'] = metric_id.to_s - end - end - end - - skip_create - end -end diff --git a/spec/factories/authentication_event.rb b/spec/factories/authentication_event.rb new file mode 100644 index 00000000000..ff539c6f5c4 --- /dev/null +++ b/spec/factories/authentication_event.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :authentication_event do + user + provider { :standard } + user_name { 'Jane Doe' } + ip_address { '127.0.0.1' } + result { :failed } + end +end diff --git a/spec/factories/ci/build_pending_states.rb b/spec/factories/ci/build_pending_states.rb index 765b7f005b9..eddd74b1068 100644 --- a/spec/factories/ci/build_pending_states.rb +++ b/spec/factories/ci/build_pending_states.rb @@ -3,7 +3,7 @@ FactoryBot.define do factory :ci_build_pending_state, class: 'Ci::BuildPendingState' do build factory: :ci_build - trace_checksum { 'crc32:12345678' } + trace_checksum { 'crc32:bc614e' } state { 'success' } end end diff --git a/spec/factories/ci/build_trace_chunks.rb b/spec/factories/ci/build_trace_chunks.rb index 7c348f4b7e4..d996b41b648 100644 --- a/spec/factories/ci/build_trace_chunks.rb +++ b/spec/factories/ci/build_trace_chunks.rb @@ -53,5 +53,18 @@ FactoryBot.define do trait :fog_without_data do data_store { :fog } end + + trait :persisted do + data_store { :database} + + transient do + initial_data { 'test data' } + end + + after(:build) do |chunk, evaluator| + Ci::BuildTraceChunks::Database.new.set_data(chunk, evaluator.initial_data) + chunk.checksum = chunk.class.crc32(evaluator.initial_data) + end + end end end diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb index 6174bfbfbb7..5fec6dd0d78 100644 --- a/spec/factories/ci/pipelines.rb +++ b/spec/factories/ci/pipelines.rb @@ -23,7 +23,7 @@ FactoryBot.define do factory :ci_pipeline do transient { ci_ref_presence { true } } - after(:build) do |pipeline, evaluator| + before(:create) do |pipeline, evaluator| pipeline.ensure_ci_ref! if evaluator.ci_ref_presence && pipeline.ci_ref_id.nil? end diff --git a/spec/factories/design_management/designs.rb b/spec/factories/design_management/designs.rb index 66c33c9ece0..38d0545483c 100644 --- a/spec/factories/design_management/designs.rb +++ b/spec/factories/design_management/designs.rb @@ -75,7 +75,7 @@ FactoryBot.define do end # Use this trait if you want versions in a particular history, but don't - # want to pay for gitlay calls. + # want to pay for gitaly calls. trait :with_versions do transient do deleted { false } diff --git a/spec/factories/events.rb b/spec/factories/events.rb index ecbda5fbfd3..6c9f1ba0137 100644 --- a/spec/factories/events.rb +++ b/spec/factories/events.rb @@ -18,6 +18,7 @@ FactoryBot.define do trait(:destroyed) { action { :destroyed } } trait(:expired) { action { :expired } } trait(:archived) { action { :archived } } + trait(:approved) { action { :approved } } factory :closed_issue_event do action { :closed } @@ -55,6 +56,16 @@ FactoryBot.define do action { :created } target { design } end + + factory :project_created_event do + project factory: :project + action { :created } + end + + factory :project_imported_event do + project factory: [:project, :with_import_url] + action { :created } + end end factory :push_event, class: 'PushEvent' do diff --git a/spec/factories/group_import_states.rb b/spec/factories/group_import_states.rb index 0b491d444fa..47d4b480b12 100644 --- a/spec/factories/group_import_states.rb +++ b/spec/factories/group_import_states.rb @@ -3,6 +3,7 @@ FactoryBot.define do factory :group_import_state, class: 'GroupImportState', traits: %i[created] do association :group, factory: :group + association :user, factory: :user trait :created do status { 0 } diff --git a/spec/factories/instance_statistics/measurement.rb b/spec/factories/instance_statistics/measurement.rb index fb180c23214..f9398cd3061 100644 --- a/spec/factories/instance_statistics/measurement.rb +++ b/spec/factories/instance_statistics/measurement.rb @@ -13,5 +13,13 @@ FactoryBot.define do trait :group_count do identifier { :groups } end + + trait :pipelines_succeeded_count do + identifier { :pipelines_succeeded } + end + + trait :pipelines_skipped_count do + identifier { :pipelines_skipped } + end end end diff --git a/spec/factories/issue_email_participants.rb b/spec/factories/issue_email_participants.rb new file mode 100644 index 00000000000..730e224b01e --- /dev/null +++ b/spec/factories/issue_email_participants.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :issue_email_participant do + issue + email { generate(:email) } + end +end diff --git a/spec/factories/merge_request_diffs.rb b/spec/factories/merge_request_diffs.rb index fdb7f52f3bd..481cabdae6d 100644 --- a/spec/factories/merge_request_diffs.rb +++ b/spec/factories/merge_request_diffs.rb @@ -2,13 +2,7 @@ FactoryBot.define do factory :merge_request_diff do - merge_request do - build(:merge_request) do |merge_request| - # MergeRequest should not create a MergeRequestDiff in the callback - allow(merge_request).to receive(:ensure_merge_request_diff) - end - end - + association :merge_request, factory: :merge_request_without_merge_request_diff state { :collected } commits_count { 1 } diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb index 6836d5d71f0..67f547dfbbb 100644 --- a/spec/factories/merge_requests.rb +++ b/spec/factories/merge_requests.rb @@ -286,5 +286,7 @@ FactoryBot.define do merge_request.update!(labels: evaluator.labels) end end + + factory :merge_request_without_merge_request_diff, class: 'MergeRequestWithoutMergeRequestDiff' end end diff --git a/spec/factories/namespaces.rb b/spec/factories/namespaces.rb index 0dcec086da9..0ec977b8234 100644 --- a/spec/factories/namespaces.rb +++ b/spec/factories/namespaces.rb @@ -63,5 +63,13 @@ FactoryBot.define do ) end end + + trait :shared_runners_disabled do + shared_runners_enabled { false } + end + + trait :allow_descendants_override_disabled_shared_runners do + allow_descendants_override_disabled_shared_runners { true } + end end end diff --git a/spec/factories/packages.rb b/spec/factories/packages.rb index 52b2a32cd3b..3562f57654e 100644 --- a/spec/factories/packages.rb +++ b/spec/factories/packages.rb @@ -91,6 +91,12 @@ FactoryBot.define do end end + factory :golang_package do + sequence(:name) { |n| "golang.org/x/pkg-#{n}"} + sequence(:version) { |n| "v1.0.#{n}" } + package_type { :golang } + end + factory :conan_package do conan_metadatum @@ -141,160 +147,6 @@ FactoryBot.define do package end - factory :package_file, class: 'Packages::PackageFile' do - package - - file_name { 'somefile.txt' } - - transient do - file_fixture { 'spec/fixtures/packages/conan/recipe_files/conanfile.py' } - end - - after(:build) do |package_file, evaluator| - package_file.file = fixture_file_upload(evaluator.file_fixture) - end - - factory :conan_package_file do - package { create(:conan_package, without_package_files: true) } - - transient do - without_loaded_metadatum { false } - end - - trait(:conan_recipe_file) do - after :create do |package_file, evaluator| - unless evaluator.without_loaded_metadatum - create :conan_file_metadatum, :recipe_file, package_file: package_file - end - end - - file_fixture { 'spec/fixtures/packages/conan/recipe_files/conanfile.py' } - file_name { 'conanfile.py' } - file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } - file_md5 { '12345abcde' } - size { 400.kilobytes } - end - - trait(:conan_recipe_manifest) do - after :create do |package_file, evaluator| - unless evaluator.without_loaded_metadatum - create :conan_file_metadatum, :recipe_file, package_file: package_file - end - end - - file_fixture { 'spec/fixtures/packages/conan/recipe_files/conanmanifest.txt' } - file_name { 'conanmanifest.txt' } - file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } - file_md5 { '12345abcde' } - size { 400.kilobytes } - end - - trait(:conan_package_manifest) do - after :create do |package_file, evaluator| - unless evaluator.without_loaded_metadatum - create :conan_file_metadatum, :package_file, package_file: package_file - end - end - - file_fixture { 'spec/fixtures/packages/conan/package_files/conanmanifest.txt' } - file_name { 'conanmanifest.txt' } - file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } - file_md5 { '12345abcde' } - size { 400.kilobytes } - end - - trait(:conan_package_info) do - after :create do |package_file, evaluator| - unless evaluator.without_loaded_metadatum - create :conan_file_metadatum, :package_file, package_file: package_file - end - end - - file_fixture { 'spec/fixtures/packages/conan/package_files/conaninfo.txt' } - file_name { 'conaninfo.txt' } - file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } - file_md5 { '12345abcde' } - size { 400.kilobytes } - end - - trait(:conan_package) do - after :create do |package_file, evaluator| - unless evaluator.without_loaded_metadatum - create :conan_file_metadatum, :package_file, package_file: package_file - end - end - - file_fixture { 'spec/fixtures/packages/conan/package_files/conan_package.tgz' } - file_name { 'conan_package.tgz' } - file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } - file_md5 { '12345abcde' } - size { 400.kilobytes } - end - end - - trait(:jar) do - file_fixture { 'spec/fixtures/packages/maven/my-app-1.0-20180724.124855-1.jar' } - file_name { 'my-app-1.0-20180724.124855-1.jar' } - file_sha1 { '4f0bfa298744d505383fbb57c554d4f5c12d88b3' } - size { 100.kilobytes } - end - - trait(:pom) do - file_fixture { 'spec/fixtures/packages/maven/my-app-1.0-20180724.124855-1.pom' } - file_name { 'my-app-1.0-20180724.124855-1.pom' } - file_sha1 { '19c975abd49e5102ca6c74a619f21e0cf0351c57' } - size { 200.kilobytes } - end - - trait(:xml) do - file_fixture { 'spec/fixtures/packages/maven/maven-metadata.xml' } - file_name { 'maven-metadata.xml' } - file_sha1 { '42b1bdc80de64953b6876f5a8c644f20204011b0' } - size { 300.kilobytes } - end - - trait(:npm) do - file_fixture { 'spec/fixtures/packages/npm/foo-1.0.1.tgz' } - file_name { 'foo-1.0.1.tgz' } - file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } - verified_at { Date.current } - verification_checksum { '4437b5775e61455588a7e5187a2e5c58c680694260bbe5501c235ec690d17f83' } - size { 400.kilobytes } - end - - trait(:nuget) do - package - file_fixture { 'spec/fixtures/packages/nuget/package.nupkg' } - file_name { 'package.nupkg' } - file_sha1 { '5fe852b2a6abd96c22c11fa1ff2fb19d9ce58b57' } - size { 300.kilobytes } - end - - trait(:pypi) do - package - file_fixture { 'spec/fixtures/packages/pypi/sample-project.tar.gz' } - file_name { 'sample-project-1.0.0.tar.gz' } - file_sha1 { '2c0cfbed075d3fae226f051f0cc771b533e01aff' } - file_md5 { '0a7392d24f42f83068fa3767c5310052' } - file_sha256 { '440e5e148a25331bbd7991575f7d54933c0ebf6cc735a18ee5066ac1381bb590' } - size { 1149.bytes } - end - - trait(:object_storage) 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 - factory :maven_metadatum, class: 'Packages::Maven::Metadatum' do association :package, package_type: :maven path { 'my/company/app/my-app/1.0-SNAPSHOT' } diff --git a/spec/factories/packages/package_file.rb b/spec/factories/packages/package_file.rb new file mode 100644 index 00000000000..bcca48fb086 --- /dev/null +++ b/spec/factories/packages/package_file.rb @@ -0,0 +1,165 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :package_file, class: 'Packages::PackageFile' do + package + + file_name { 'somefile.txt' } + + transient do + file_fixture { 'spec/fixtures/packages/conan/recipe_files/conanfile.py' } + end + + after(:build) do |package_file, evaluator| + package_file.file = fixture_file_upload(evaluator.file_fixture) + end + + factory :conan_package_file do + package { create(:conan_package, without_package_files: true) } + + transient do + without_loaded_metadatum { false } + end + + trait(:conan_recipe_file) do + after :create do |package_file, evaluator| + unless evaluator.without_loaded_metadatum + create :conan_file_metadatum, :recipe_file, package_file: package_file + end + end + + file_fixture { 'spec/fixtures/packages/conan/recipe_files/conanfile.py' } + file_name { 'conanfile.py' } + file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } + file_md5 { '12345abcde' } + size { 400.kilobytes } + end + + trait(:conan_recipe_manifest) do + after :create do |package_file, evaluator| + unless evaluator.without_loaded_metadatum + create :conan_file_metadatum, :recipe_file, package_file: package_file + end + end + + file_fixture { 'spec/fixtures/packages/conan/recipe_files/conanmanifest.txt' } + file_name { 'conanmanifest.txt' } + file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } + file_md5 { '12345abcde' } + size { 400.kilobytes } + end + + trait(:conan_package_manifest) do + after :create do |package_file, evaluator| + unless evaluator.without_loaded_metadatum + create :conan_file_metadatum, :package_file, package_file: package_file + end + end + + file_fixture { 'spec/fixtures/packages/conan/package_files/conanmanifest.txt' } + file_name { 'conanmanifest.txt' } + file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } + file_md5 { '12345abcde' } + size { 400.kilobytes } + end + + trait(:conan_package_info) do + after :create do |package_file, evaluator| + unless evaluator.without_loaded_metadatum + create :conan_file_metadatum, :package_file, package_file: package_file + end + end + + file_fixture { 'spec/fixtures/packages/conan/package_files/conaninfo.txt' } + file_name { 'conaninfo.txt' } + file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } + file_md5 { '12345abcde' } + size { 400.kilobytes } + end + + trait(:conan_package) do + after :create do |package_file, evaluator| + unless evaluator.without_loaded_metadatum + create :conan_file_metadatum, :package_file, package_file: package_file + end + end + + file_fixture { 'spec/fixtures/packages/conan/package_files/conan_package.tgz' } + file_name { 'conan_package.tgz' } + file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } + file_md5 { '12345abcde' } + size { 400.kilobytes } + end + end + + trait(:jar) do + file_fixture { 'spec/fixtures/packages/maven/my-app-1.0-20180724.124855-1.jar' } + file_name { 'my-app-1.0-20180724.124855-1.jar' } + file_sha1 { '4f0bfa298744d505383fbb57c554d4f5c12d88b3' } + size { 100.kilobytes } + end + + trait(:pom) do + file_fixture { 'spec/fixtures/packages/maven/my-app-1.0-20180724.124855-1.pom' } + file_name { 'my-app-1.0-20180724.124855-1.pom' } + file_sha1 { '19c975abd49e5102ca6c74a619f21e0cf0351c57' } + size { 200.kilobytes } + end + + trait(:xml) do + file_fixture { 'spec/fixtures/packages/maven/maven-metadata.xml' } + file_name { 'maven-metadata.xml' } + file_sha1 { '42b1bdc80de64953b6876f5a8c644f20204011b0' } + size { 300.kilobytes } + end + + trait(:npm) do + file_fixture { 'spec/fixtures/packages/npm/foo-1.0.1.tgz' } + file_name { 'foo-1.0.1.tgz' } + file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } + verified_at { Date.current } + verification_checksum { '4437b5775e61455588a7e5187a2e5c58c680694260bbe5501c235ec690d17f83' } + size { 400.kilobytes } + end + + trait(:nuget) do + package + file_fixture { 'spec/fixtures/packages/nuget/package.nupkg' } + file_name { 'package.nupkg' } + file_sha1 { '5fe852b2a6abd96c22c11fa1ff2fb19d9ce58b57' } + size { 300.kilobytes } + end + + trait(:pypi) do + package + file_fixture { 'spec/fixtures/packages/pypi/sample-project.tar.gz' } + file_name { 'sample-project-1.0.0.tar.gz' } + file_sha1 { '2c0cfbed075d3fae226f051f0cc771b533e01aff' } + file_md5 { '0a7392d24f42f83068fa3767c5310052' } + file_sha256 { '440e5e148a25331bbd7991575f7d54933c0ebf6cc735a18ee5066ac1381bb590' } + size { 1149.bytes } + end + + trait(:generic) do + package + file_fixture { 'spec/fixtures/packages/generic/myfile.tar.gz' } + file_name { "#{package.name}.tar.gz" } + file_sha256 { '440e5e148a25331bbd7991575f7d54933c0ebf6cc735a18ee5066ac1381bb590' } + size { 1149.bytes } + end + + trait(:object_storage) 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/pages_deployments.rb b/spec/factories/pages_deployments.rb index 1bea003d683..20b8e4782df 100644 --- a/spec/factories/pages_deployments.rb +++ b/spec/factories/pages_deployments.rb @@ -4,9 +4,12 @@ FactoryBot.define do factory :pages_deployment, class: 'PagesDeployment' do project file_store { ObjectStorage::SUPPORTED_STORES.first } - size { 1.megabytes } - # TODO: replace with proper file uploaded in https://gitlab.com/gitlab-org/gitlab/-/issues/245295 - file { "dummy string" } + after(:build) do |deployment, _evaluator| + deployment.file = fixture_file_upload( + Rails.root.join("spec/fixtures/pages.zip") + ) + deployment.size = deployment.file.size + end end end diff --git a/spec/factories/project_tracing_settings.rb b/spec/factories/project_tracing_settings.rb new file mode 100644 index 00000000000..05c1529c18e --- /dev/null +++ b/spec/factories/project_tracing_settings.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :project_tracing_setting do + project + external_url { 'https://example.com' } + end +end diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 147413557d6..091c9d5a245 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -285,6 +285,12 @@ FactoryBot.define do end end + trait :with_import_url do + import_finished + + import_url { generate(:url) } + end + trait(:wiki_enabled) { wiki_access_level { ProjectFeature::ENABLED } } trait(:wiki_disabled) { wiki_access_level { ProjectFeature::DISABLED } } trait(:wiki_private) { wiki_access_level { ProjectFeature::PRIVATE } } diff --git a/spec/factories/prometheus_metrics.rb b/spec/factories/prometheus_metrics.rb index 83e3845f1c3..503d392a524 100644 --- a/spec/factories/prometheus_metrics.rb +++ b/spec/factories/prometheus_metrics.rb @@ -9,6 +9,7 @@ FactoryBot.define do group { :business } project legend { 'legend' } + dashboard_path { '.gitlab/dashboards/dashboard_path.yml'} trait :common do common { true } diff --git a/spec/factories/services.rb b/spec/factories/services.rb index 9056fd97f13..13997080817 100644 --- a/spec/factories/services.rb +++ b/spec/factories/services.rb @@ -81,7 +81,7 @@ FactoryBot.define do project_key { nil } end - after(:build) do |service, evaluator| + before(:create) do |service, evaluator| if evaluator.create_data create(:jira_tracker_data, service: service, url: evaluator.url, api_url: evaluator.api_url, jira_issue_transition_id: evaluator.jira_issue_transition_id, @@ -130,7 +130,7 @@ FactoryBot.define do new_issue_url { 'http://new-issue.example.com' } end - after(:build) do |service, evaluator| + before(:create) do |service, evaluator| if evaluator.create_data create(:issue_tracker_data, service: service, project_url: evaluator.project_url, issues_url: evaluator.issues_url, new_issue_url: evaluator.new_issue_url @@ -151,7 +151,7 @@ FactoryBot.define do project_identifier_code { 'PRJ-1' } end - after(:build) do |service, evaluator| + before(:create) do |service, evaluator| create(:open_project_tracker_data, service: service, url: evaluator.url, api_url: evaluator.api_url, token: evaluator.token, closed_status_id: evaluator.closed_status_id, project_identifier_code: evaluator.project_identifier_code diff --git a/spec/factories/terraform/state.rb b/spec/factories/terraform/state.rb index 9decc89ef39..d80c1315e28 100644 --- a/spec/factories/terraform/state.rb +++ b/spec/factories/terraform/state.rb @@ -17,16 +17,6 @@ FactoryBot.define do locked_by_user { create(:user) } end - trait(:checksummed) do - with_file - verification_checksum { 'abc' } - end - - trait(:checksum_failure) do - with_file - verification_failure { 'Could not calculate the checksum' } - end - trait :with_version do after(:create) do |state| create(:terraform_state_version, :with_file, terraform_state: state) diff --git a/spec/factories/terraform/state_version.rb b/spec/factories/terraform/state_version.rb index d1bd78215e3..b45bd01fd3c 100644 --- a/spec/factories/terraform/state_version.rb +++ b/spec/factories/terraform/state_version.rb @@ -7,5 +7,13 @@ FactoryBot.define do sequence(:version) file { fixture_file_upload('spec/fixtures/terraform/terraform.tfstate', 'application/json') } + + trait(:checksummed) do + verification_checksum { 'abc' } + end + + trait(:checksum_failure) do + verification_failure { 'Could not calculate the checksum' } + end end end diff --git a/spec/factories/todos.rb b/spec/factories/todos.rb index 0b5d00cff67..97a1265c46a 100644 --- a/spec/factories/todos.rb +++ b/spec/factories/todos.rb @@ -12,6 +12,10 @@ FactoryBot.define do action { Todo::ASSIGNED } end + trait :review_requested do + action { Todo::REVIEW_REQUESTED } + end + trait :mentioned do action { Todo::MENTIONED } end diff --git a/spec/factories/usage_data.rb b/spec/factories/usage_data.rb index 5b20205a235..2f7c6fde3e4 100644 --- a/spec/factories/usage_data.rb +++ b/spec/factories/usage_data.rb @@ -50,6 +50,9 @@ FactoryBot.define do create(:protected_branch, project: projects[0]) create(:protected_branch, name: 'main', project: projects[0]) + # Tracing + create(:project_tracing_setting, project: projects[0]) + # Incident Labeled Issues incident_label = create(:label, :incident, project: projects[0]) create(:labeled_issue, project: projects[0], labels: [incident_label]) @@ -97,16 +100,19 @@ FactoryBot.define do create(:grafana_integration, project: projects[1], enabled: true) create(:grafana_integration, project: projects[2], enabled: false) - create(:package, project: projects[0]) - create(:package, project: projects[0]) - create(:package, project: projects[1]) + create(:package, project: projects[0], created_at: 3.days.ago) + create(:package, project: projects[0], created_at: 3.days.ago) + create(:package, project: projects[1], created_at: 3.days.ago) create(:package, created_at: 2.months.ago, project: projects[1]) + # User Preferences + create(:user_preference, gitpod_enabled: true) + ProjectFeature.first.update_attribute('repository_access_level', 0) # Create fresh & a month (28-days SMAU) old data env = create(:environment, project: projects[3]) - [2, 29].each do |n| + [3, 31].each do |n| deployment_options = { created_at: n.days.ago, project: env.project, environment: env } create(:deployment, :failed, deployment_options) create(:deployment, :success, deployment_options) diff --git a/spec/factories/wiki_pages.rb b/spec/factories/wiki_pages.rb index cc866d336a4..3397277839e 100644 --- a/spec/factories/wiki_pages.rb +++ b/spec/factories/wiki_pages.rb @@ -9,7 +9,7 @@ FactoryBot.define do content { 'Content for wiki page' } format { :markdown } message { nil } - project { association(:project, :wiki_repo) } + project { association(:project) } container { project } wiki { association(:wiki, container: container) } page { OpenStruct.new(url_path: title) } @@ -18,6 +18,7 @@ FactoryBot.define do initialize_with do new(wiki, page).tap do |page| page.attributes = { + slug: title&.tr(' ', '-'), title: title, content: content, format: format diff --git a/spec/factories/wikis.rb b/spec/factories/wikis.rb index 96578fdcee6..86d98bfd756 100644 --- a/spec/factories/wikis.rb +++ b/spec/factories/wikis.rb @@ -3,8 +3,8 @@ FactoryBot.define do factory :wiki do transient do - container { association(:project, :wiki_repo) } - user { association(:user) } + container { association(:project) } + user { container.default_owner || association(:user) } end initialize_with { Wiki.for_container(container, user) } @@ -12,7 +12,7 @@ FactoryBot.define do factory :project_wiki do transient do - project { association(:project, :wiki_repo) } + project { association(:project) } end container { project } |