diff options
Diffstat (limited to 'spec/factories')
31 files changed, 416 insertions, 26 deletions
diff --git a/spec/factories/alert_management/alerts.rb b/spec/factories/alert_management/alerts.rb index f63a3c9f7f5..589a62a68bb 100644 --- a/spec/factories/alert_management/alerts.rb +++ b/spec/factories/alert_management/alerts.rb @@ -15,9 +15,9 @@ FactoryBot.define do end end - trait :with_issue do + trait :with_incident do after(:create) do |alert| - create(:issue, alert_management_alert: alert, project: alert.project) + create(:incident, alert_management_alert: alert, project: alert.project) end end @@ -128,7 +128,7 @@ FactoryBot.define do end trait :all_fields do - with_issue + with_incident with_assignee with_fingerprint with_service diff --git a/spec/factories/ci/build_trace_section_names.rb b/spec/factories/ci/build_trace_section_names.rb deleted file mode 100644 index b9b66b49317..00000000000 --- a/spec/factories/ci/build_trace_section_names.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -FactoryBot.define do - factory :ci_build_trace_section_name, class: 'Ci::BuildTraceSectionName' do - sequence(:name) { |n| "section_#{n}" } - project factory: :project - end -end diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index 0e535aeaa8d..f3500301e22 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -120,6 +120,19 @@ FactoryBot.define do end end + trait :environment_with_deployment_tier do + environment { 'test_portal' } + options do + { + script: %w(ls), + environment: { name: 'test_portal', + action: 'start', + url: 'http://staging.example.com/$CI_JOB_NAME', + deployment_tier: 'testing' } + } + end + end + trait :deploy_to_production do environment { 'production' } @@ -224,8 +237,13 @@ FactoryBot.define do # to the job. If `build.deployment` has already been set, it doesn't # build a new instance. environment = Gitlab::Ci::Pipeline::Seed::Environment.new(build).to_resource - build.deployment = - Gitlab::Ci::Pipeline::Seed::Deployment.new(build, environment).to_resource + + build.assign_attributes( + deployment: Gitlab::Ci::Pipeline::Seed::Deployment.new(build, environment).to_resource, + metadata_attributes: { + expanded_environment_name: environment.name + } + ) end end diff --git a/spec/factories/ci/job_artifacts.rb b/spec/factories/ci/job_artifacts.rb index 642437b1119..2f4eb99a073 100644 --- a/spec/factories/ci/job_artifacts.rb +++ b/spec/factories/ci/job_artifacts.rb @@ -287,6 +287,76 @@ FactoryBot.define do end end + trait :common_security_report do + file_format { :raw } + file_type { :dependency_scanning } + + after(:build) do |artifact, _| + artifact.file = fixture_file_upload( + Rails.root.join('spec/fixtures/security_reports/master/gl-common-scanning-report.json'), 'application/json') + end + end + + trait :common_security_report_with_blank_names do + file_format { :raw } + file_type { :dependency_scanning } + + after(:build) do |artifact, _| + artifact.file = fixture_file_upload( + Rails.root.join('spec/fixtures/security_reports/master/gl-common-scanning-report-names.json'), 'application/json') + end + end + + trait :sast_deprecated do + file_type { :sast } + file_format { :raw } + + after(:build) do |artifact, _| + artifact.file = fixture_file_upload( + Rails.root.join('spec/fixtures/security_reports/deprecated/gl-sast-report.json'), 'application/json') + end + end + + trait :sast_with_corrupted_data do + file_type { :sast } + file_format { :raw } + + after(:build) do |artifact, _| + artifact.file = fixture_file_upload( + Rails.root.join('spec/fixtures/trace/sample_trace'), 'application/json') + end + end + + trait :sast_feature_branch do + file_format { :raw } + file_type { :sast } + + after(:build) do |artifact, _| + artifact.file = fixture_file_upload( + Rails.root.join('spec/fixtures/security_reports/feature-branch/gl-sast-report.json'), 'application/json') + end + end + + trait :secret_detection_feature_branch do + file_format { :raw } + file_type { :secret_detection } + + after(:build) do |artifact, _| + artifact.file = fixture_file_upload( + Rails.root.join('spec/fixtures/security_reports/feature-branch/gl-secret-detection-report.json'), 'application/json') + end + end + + trait :sast_with_missing_scanner do + file_type { :sast } + file_format { :raw } + + after(:build) do |artifact, _| + artifact.file = fixture_file_upload( + Rails.root.join('spec/fixtures/security_reports/master/gl-sast-missing-scanner.json'), 'application/json') + end + end + trait :secret_detection do file_type { :secret_detection } file_format { :raw } diff --git a/spec/factories/ci/pending_builds.rb b/spec/factories/ci/pending_builds.rb index 90779ae8ab9..fbd76e07d8e 100644 --- a/spec/factories/ci/pending_builds.rb +++ b/spec/factories/ci/pending_builds.rb @@ -6,5 +6,7 @@ FactoryBot.define do project protected { build.protected } instance_runners_enabled { true } + namespace { project.namespace } + minutes_exceeded { false } end end diff --git a/spec/factories/ci/reports/security/aggregated_reports.rb b/spec/factories/ci/reports/security/aggregated_reports.rb new file mode 100644 index 00000000000..eb678dc9766 --- /dev/null +++ b/spec/factories/ci/reports/security/aggregated_reports.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_reports_security_aggregated_reports, class: '::Gitlab::Ci::Reports::Security::AggregatedReport' do + reports { FactoryBot.build_list(:ci_reports_security_report, 1) } + findings { FactoryBot.build_list(:ci_reports_security_finding, 1) } + + skip_create + + initialize_with do + ::Gitlab::Ci::Reports::Security::AggregatedReport.new(reports, findings) + end + end +end diff --git a/spec/factories/ci/reports/security/finding_keys.rb b/spec/factories/ci/reports/security/finding_keys.rb new file mode 100644 index 00000000000..f00a043012e --- /dev/null +++ b/spec/factories/ci/reports/security/finding_keys.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_reports_security_finding_key, class: '::Gitlab::Ci::Reports::Security::FindingKey' do + sequence :location_fingerprint do |a| + Digest::SHA1.hexdigest(a.to_s) + end + sequence :identifier_fingerprint do |a| + Digest::SHA1.hexdigest(a.to_s) + end + + skip_create + + initialize_with do + ::Gitlab::Ci::Reports::Security::FindingKey.new(**attributes) + end + end +end diff --git a/spec/factories/ci/reports/security/findings.rb b/spec/factories/ci/reports/security/findings.rb new file mode 100644 index 00000000000..e3971bc48f3 --- /dev/null +++ b/spec/factories/ci/reports/security/findings.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_reports_security_finding, class: '::Gitlab::Ci::Reports::Security::Finding' do + compare_key { "#{identifiers.first&.external_type}:#{identifiers.first&.external_id}:#{location.fingerprint}" } + confidence { :medium } + identifiers { Array.new(1) { association(:ci_reports_security_identifier) } } + location factory: :ci_reports_security_locations_sast + metadata_version { 'sast:1.0' } + name { 'Cipher with no integrity' } + report_type { :sast } + raw_metadata do + { + description: "The cipher does not provide data integrity update 1", + solution: "GCM mode introduces an HMAC into the resulting encrypted data, providing integrity of the result.", + location: { + file: "maven/src/main/java/com/gitlab/security_products/tests/App.java", + start_line: 29, + end_line: 29, + class: "com.gitlab.security_products.tests.App", + method: "insecureCypher" + }, + links: [ + { + name: "Cipher does not check for integrity first?", + url: "https://crypto.stackexchange.com/questions/31428/pbewithmd5anddes-cipher-does-not-check-for-integrity-first" + } + ] + }.to_json + end + scanner factory: :ci_reports_security_scanner + severity { :high } + scan factory: :ci_reports_security_scan + sequence(:uuid) do |n| + ::Security::VulnerabilityUUID.generate( + report_type: report_type, + primary_identifier_fingerprint: identifiers.first&.fingerprint, + location_fingerprint: location.fingerprint, + project_id: n + ) + end + vulnerability_finding_signatures_enabled { false } + + skip_create + + trait :dynamic do + location { association(:ci_reports_security_locations_sast, :dynamic) } + end + + initialize_with do + ::Gitlab::Ci::Reports::Security::Finding.new(**attributes) + end + end +end diff --git a/spec/factories/ci/reports/security/locations/sast.rb b/spec/factories/ci/reports/security/locations/sast.rb new file mode 100644 index 00000000000..59b54ecd8f2 --- /dev/null +++ b/spec/factories/ci/reports/security/locations/sast.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_reports_security_locations_sast, class: '::Gitlab::Ci::Reports::Security::Locations::Sast' do + file_path { 'maven/src/main/java/com/gitlab/security_products/tests/App.java' } + start_line { 29 } + end_line { 31 } + class_name { 'com.gitlab.security_products.tests.App' } + method_name { 'insecureCypher' } + + skip_create + + initialize_with do + ::Gitlab::Ci::Reports::Security::Locations::Sast.new(**attributes) + end + + trait :dynamic do + sequence(:file_path, 'a') { |n| "path/#{n}" } + start_line { Random.rand(20) } + end_line { start_line + Random.rand(5) } + end + end +end diff --git a/spec/factories/ci/reports/security/reports.rb b/spec/factories/ci/reports/security/reports.rb new file mode 100644 index 00000000000..5699b8fee3e --- /dev/null +++ b/spec/factories/ci/reports/security/reports.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_reports_security_report, class: '::Gitlab::Ci::Reports::Security::Report' do + type { :sast } + pipeline { association(:ci_pipeline) } + created_at { 2.weeks.ago } + scanned_resources { [] } + + transient do + findings { [] } + scanners { [] } + identifiers { [] } + end + + after :build do |report, evaluator| + evaluator.scanners.each { |s| report.add_scanner(s) } + evaluator.identifiers.each { |id| report.add_identifier(id) } + evaluator.findings.each { |o| report.add_finding(o) } + end + + skip_create + + initialize_with do + ::Gitlab::Ci::Reports::Security::Report.new(type, pipeline, created_at) + end + end +end diff --git a/spec/factories/customer_relations/organizations.rb b/spec/factories/customer_relations/organizations.rb new file mode 100644 index 00000000000..b6efd46f1a4 --- /dev/null +++ b/spec/factories/customer_relations/organizations.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :organization, class: 'CustomerRelations::Organization' do + group + + name { generate(:name) } + end +end diff --git a/spec/factories/deploy_tokens.rb b/spec/factories/deploy_tokens.rb index d4127f78ebf..b2c478fd3fe 100644 --- a/spec/factories/deploy_tokens.rb +++ b/spec/factories/deploy_tokens.rb @@ -35,9 +35,13 @@ FactoryBot.define do end trait :all_scopes do - write_registry { true} + write_registry { true } read_package_registry { true } write_package_registry { true } end + + trait :dependency_proxy_scopes do + write_registry { true } + end end end diff --git a/spec/factories/design_management/designs.rb b/spec/factories/design_management/designs.rb index c4fb330a0da..c23a67fe95b 100644 --- a/spec/factories/design_management/designs.rb +++ b/spec/factories/design_management/designs.rb @@ -39,7 +39,7 @@ FactoryBot.define do sha = commit_version[action] version = DesignManagement::Version.new(sha: sha, issue: issue, author: evaluator.author) version.save!(validate: false) # We need it to have an ID, validate later - Gitlab::Database.bulk_insert(dv_table_name, [action.row_attrs(version)]) # rubocop:disable Gitlab/BulkInsert + Gitlab::Database.main.bulk_insert(dv_table_name, [action.row_attrs(version)]) # rubocop:disable Gitlab/BulkInsert end # always a creation diff --git a/spec/factories/environments.rb b/spec/factories/environments.rb index 148ee64fb08..0a9255e1abe 100644 --- a/spec/factories/environments.rb +++ b/spec/factories/environments.rb @@ -75,6 +75,11 @@ FactoryBot.define do auto_stop_at { 1.day.ago } end + trait :auto_deletable do + state { :stopped } + auto_delete_at { 1.day.ago } + end + trait :will_auto_stop do auto_stop_at { 1.day.from_now } end diff --git a/spec/factories/error_tracking/client_key.rb b/spec/factories/error_tracking/client_key.rb new file mode 100644 index 00000000000..eb5acc8dab7 --- /dev/null +++ b/spec/factories/error_tracking/client_key.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :error_tracking_client_key, class: 'ErrorTracking::ClientKey' do + project + active { true } + + trait :disabled do + active { false } + end + end +end diff --git a/spec/factories/error_tracking/detailed_error.rb b/spec/factories/error_tracking/detailed_error.rb index 83004ffae38..c2e5741b150 100644 --- a/spec/factories/error_tracking/detailed_error.rb +++ b/spec/factories/error_tracking/detailed_error.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true FactoryBot.define do - factory :detailed_error_tracking_error, parent: :error_tracking_error, class: 'Gitlab::ErrorTracking::DetailedError' do + factory :error_tracking_sentry_detailed_error, parent: :error_tracking_sentry_error, class: 'Gitlab::ErrorTracking::DetailedError' do gitlab_issue { 'http://gitlab.example.com/issues/1' } external_base_url { 'http://example.com' } first_release_last_commit { '68c914da9' } diff --git a/spec/factories/error_tracking/error.rb b/spec/factories/error_tracking/error.rb index e5f2e2ca9a7..bebdffb3614 100644 --- a/spec/factories/error_tracking/error.rb +++ b/spec/factories/error_tracking/error.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true FactoryBot.define do - factory :error_tracking_error, class: 'Gitlab::ErrorTracking::Error' do + # There is an issue to rename this class https://gitlab.com/gitlab-org/gitlab/-/issues/323342. + factory :error_tracking_sentry_error, class: 'Gitlab::ErrorTracking::Error' do id { '1' } title { 'title' } type { 'error' } @@ -25,4 +26,19 @@ FactoryBot.define do skip_create end + + factory :error_tracking_error, class: 'ErrorTracking::Error' do + project + name { 'ActionView::MissingTemplate' } + description { 'Missing template posts/edit' } + actor { 'PostsController#edit' } + platform { 'ruby' } + first_seen_at { Time.now.iso8601 } + last_seen_at { Time.now.iso8601 } + status { 'unresolved' } + + trait :resolved do + status { 'resolved' } + end + end end diff --git a/spec/factories/error_tracking/error_event.rb b/spec/factories/error_tracking/error_event.rb index 880fdf17fae..9620e3999d6 100644 --- a/spec/factories/error_tracking/error_event.rb +++ b/spec/factories/error_tracking/error_event.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true FactoryBot.define do - factory :error_tracking_error_event, class: 'Gitlab::ErrorTracking::ErrorEvent' do + # There is an issue to rename this class https://gitlab.com/gitlab-org/gitlab/-/issues/323342. + factory :error_tracking_sentry_error_event, class: 'Gitlab::ErrorTracking::ErrorEvent' do issue_id { 'id' } date_received { Time.now.iso8601 } stack_trace_entries do @@ -53,4 +54,14 @@ FactoryBot.define do skip_create end + + factory :error_tracking_error_event, class: 'ErrorTracking::ErrorEvent' do + error factory: :error_tracking_error + + description { 'ActionView::MissingTemplate' } + environment { 'development' } + level { 'error' } + occurred_at { Time.now.iso8601 } + payload { Gitlab::Json.parse(File.read(Rails.root.join('spec/fixtures/', 'error_tracking/parsed_event.json'))) } + end end diff --git a/spec/factories/gitlab/database/async_indexes/postgres_async_index.rb b/spec/factories/gitlab/database/async_indexes/postgres_async_index.rb new file mode 100644 index 00000000000..d6b4b90bbd0 --- /dev/null +++ b/spec/factories/gitlab/database/async_indexes/postgres_async_index.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :postgres_async_index, class: 'Gitlab::Database::AsyncIndexes::PostgresAsyncIndex' do + sequence(:name) { |n| "users_id_#{n}" } + definition { "CREATE INDEX #{name} ON #{table_name} (id)" } + table_name { "users" } + end +end diff --git a/spec/factories/incident_management/issuable_escalation_statuses.rb b/spec/factories/incident_management/issuable_escalation_statuses.rb new file mode 100644 index 00000000000..54d0887f386 --- /dev/null +++ b/spec/factories/incident_management/issuable_escalation_statuses.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :incident_management_issuable_escalation_status, class: 'IncidentManagement::IssuableEscalationStatus' do + issue + triggered + + trait :triggered do + status { ::IncidentManagement::IssuableEscalationStatus.status_value(:triggered) } + end + + trait :acknowledged do + status { ::IncidentManagement::IssuableEscalationStatus.status_value(:acknowledged) } + end + + trait :resolved do + status { ::IncidentManagement::IssuableEscalationStatus.status_value(:resolved) } + resolved_at { Time.current } + end + + trait :ignored do + status { ::IncidentManagement::IssuableEscalationStatus.status_value(:ignored) } + end + end +end diff --git a/spec/factories/integrations.rb b/spec/factories/integrations.rb index ed8a562b331..a5a17ca4058 100644 --- a/spec/factories/integrations.rb +++ b/spec/factories/integrations.rb @@ -53,7 +53,7 @@ FactoryBot.define do transient do create_data { true } url { 'https://jira.example.com' } - api_url { nil } + api_url { '' } username { 'jira_username' } password { 'jira_password' } jira_issue_transition_automatic { false } diff --git a/spec/factories/packages/debian/distribution.rb b/spec/factories/packages/debian/distribution.rb index 619308e4e18..2142dba974b 100644 --- a/spec/factories/packages/debian/distribution.rb +++ b/spec/factories/packages/debian/distribution.rb @@ -13,8 +13,18 @@ FactoryBot.define do end trait(:with_file) do + file_signature do + <<~EOF + -----BEGIN PGP SIGNATURE----- + + ABC + -----BEGIN PGP SIGNATURE----- + EOF + end + 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 end diff --git a/spec/factories/packages/debian/distribution_key.rb b/spec/factories/packages/debian/distribution_key.rb index 6bd457c50d0..94e041eb4a9 100644 --- a/spec/factories/packages/debian/distribution_key.rb +++ b/spec/factories/packages/debian/distribution_key.rb @@ -4,9 +4,9 @@ FactoryBot.define do factory :debian_project_distribution_key, class: 'Packages::Debian::ProjectDistributionKey' do distribution { association(:debian_project_distribution) } - private_key { '-----BEGIN PGP PRIVATE KEY BLOCK-----' } + private_key { File.read(Rails.root.join('spec/fixtures/', 'private_key.asc')) } passphrase { '12345' } - public_key { '-----BEGIN PGP PUBLIC KEY BLOCK-----' } + public_key { File.read(Rails.root.join('spec/fixtures/', 'public_key.asc')) } fingerprint { '12345' } factory :debian_group_distribution_key, class: 'Packages::Debian::GroupDistributionKey' do diff --git a/spec/factories/packages/debian/file_metadatum.rb b/spec/factories/packages/debian/file_metadatum.rb index f761dd18b4e..505b9975f79 100644 --- a/spec/factories/packages/debian/file_metadatum.rb +++ b/spec/factories/packages/debian/file_metadatum.rb @@ -26,7 +26,27 @@ FactoryBot.define do file_type { 'dsc' } component { 'main' } architecture { nil } - fields { { 'a': 'b' } } + fields do + { + 'Format' => '3.0 (native)', + 'Source' => package_file.package.name, + 'Binary' => 'sample-dev, libsample0, sample-udeb', + 'Architecture' => 'any', + '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" + } + end end trait(:deb) do diff --git a/spec/factories/project_error_tracking_settings.rb b/spec/factories/project_error_tracking_settings.rb index e09d58d293f..424f462e1a0 100644 --- a/spec/factories/project_error_tracking_settings.rb +++ b/spec/factories/project_error_tracking_settings.rb @@ -12,5 +12,9 @@ FactoryBot.define do trait :disabled do enabled { false } end + + trait :integrated do + integrated { true } + end end end diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 84686c58a8e..fb86f4672bc 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -34,6 +34,7 @@ FactoryBot.define do end metrics_dashboard_access_level { ProjectFeature::PRIVATE } operations_access_level { ProjectFeature::ENABLED } + container_registry_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 @@ -50,7 +51,7 @@ FactoryBot.define do ci_job_token_scope_enabled { nil } end - before(:create) do |project, evaluator| + after(:build) do |project, evaluator| # Builds and MRs can't have higher visibility level than repository access level. builds_access_level = [evaluator.builds_access_level, evaluator.repository_access_level].min merge_requests_access_level = [evaluator.merge_requests_access_level, evaluator.repository_access_level].min @@ -66,7 +67,8 @@ FactoryBot.define do pages_access_level: evaluator.pages_access_level, metrics_dashboard_access_level: evaluator.metrics_dashboard_access_level, operations_access_level: evaluator.operations_access_level, - analytics_access_level: evaluator.analytics_access_level + analytics_access_level: evaluator.analytics_access_level, + container_registry_access_level: evaluator.container_registry_access_level } project.build_project_feature(hash) @@ -263,7 +265,6 @@ FactoryBot.define do trait :remote_mirror do transient do - remote_name { "remote_mirror_#{SecureRandom.hex}" } url { "http://foo.com" } enabled { true } end @@ -344,6 +345,9 @@ FactoryBot.define do trait(:analytics_enabled) { analytics_access_level { ProjectFeature::ENABLED } } trait(:analytics_disabled) { analytics_access_level { ProjectFeature::DISABLED } } trait(:analytics_private) { analytics_access_level { ProjectFeature::PRIVATE } } + trait(:container_registry_enabled) { container_registry_access_level { ProjectFeature::ENABLED } } + trait(:container_registry_disabled) { container_registry_access_level { ProjectFeature::DISABLED } } + trait(:container_registry_private) { container_registry_access_level { ProjectFeature::PRIVATE } } trait :auto_devops do association :auto_devops, factory: :project_auto_devops diff --git a/spec/factories/projects/ci_feature_usages.rb b/spec/factories/projects/ci_feature_usages.rb new file mode 100644 index 00000000000..1ab1d82ef4b --- /dev/null +++ b/spec/factories/projects/ci_feature_usages.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :project_ci_feature_usage, class: 'Projects::CiFeatureUsage' do + project factory: :project + feature { :code_coverage } # rubocop: disable RSpec/EmptyExampleGroup + default_branch { false } + end +end diff --git a/spec/factories/sequences.rb b/spec/factories/sequences.rb index b276e6f8cfc..0edc2b6027d 100644 --- a/spec/factories/sequences.rb +++ b/spec/factories/sequences.rb @@ -20,4 +20,5 @@ FactoryBot.define do sequence(:jira_title) { |n| "[PROJ-#{n}]: fix bug" } sequence(:jira_branch) { |n| "feature/PROJ-#{n}" } sequence(:job_name) { |n| "job #{n}" } + sequence(:work_item_type_name) { |n| "bug#{n}" } end diff --git a/spec/factories/usage_data.rb b/spec/factories/usage_data.rb index 4593294fd14..c02bcfc2169 100644 --- a/spec/factories/usage_data.rb +++ b/spec/factories/usage_data.rb @@ -25,7 +25,6 @@ FactoryBot.define do 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) 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) @@ -124,6 +123,8 @@ FactoryBot.define do create_list(:project_snippet, 2, project: projects[0], created_at: n.days.ago) create(:personal_snippet, created_at: n.days.ago) end + + create(:operations_feature_flag, project: projects[0]) end end end diff --git a/spec/factories/user_details.rb b/spec/factories/user_details.rb index d3cf0d48577..6d58123f2e1 100644 --- a/spec/factories/user_details.rb +++ b/spec/factories/user_details.rb @@ -5,5 +5,6 @@ FactoryBot.define do user job_title { 'VP of Sales' } pronouns { nil } + pronunciation { nil } end end diff --git a/spec/factories/work_item/work_item_types.rb b/spec/factories/work_item/work_item_types.rb new file mode 100644 index 00000000000..07d6d685c57 --- /dev/null +++ b/spec/factories/work_item/work_item_types.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :work_item_type, class: 'WorkItem::Type' do + namespace + + name { generate(:work_item_type_name) } + base_type { WorkItem::Type.base_types[:issue] } + icon_name { 'issue-type-issue' } + + trait :default do + namespace { nil } + end + + trait :incident do + base_type { WorkItem::Type.base_types[:incident] } + icon_name { 'issue-type-incident' } + end + + trait :test_case do + base_type { WorkItem::Type.base_types[:test_case] } + icon_name { 'issue-type-test-case' } + end + + trait :requirement do + base_type { WorkItem::Type.base_types[:requirement] } + icon_name { 'issue-type-requirements' } + end + end +end |