diff options
Diffstat (limited to 'spec/factories')
-rw-r--r-- | spec/factories/audit_events.rb | 1 | ||||
-rw-r--r-- | spec/factories/ci/builds.rb | 8 | ||||
-rw-r--r-- | spec/factories/ci/pending_builds.rb | 10 | ||||
-rw-r--r-- | spec/factories/ci/reports/security/identifiers.rb | 15 | ||||
-rw-r--r-- | spec/factories/ci/reports/security/links.rb | 14 | ||||
-rw-r--r-- | spec/factories/ci/reports/security/scanners.rb | 29 | ||||
-rw-r--r-- | spec/factories/ci/running_builds.rb | 10 | ||||
-rw-r--r-- | spec/factories/events.rb | 1 | ||||
-rw-r--r-- | spec/factories/integration_data.rb | 2 | ||||
-rw-r--r-- | spec/factories/integrations.rb | 15 | ||||
-rw-r--r-- | spec/factories/merge_request_cleanup_schedules.rb | 15 | ||||
-rw-r--r-- | spec/factories/merge_request_diff_commit_users.rb | 8 | ||||
-rw-r--r-- | spec/factories/packages.rb | 6 | ||||
-rw-r--r-- | spec/factories/packages/helm/file_metadatum.rb | 2 | ||||
-rw-r--r-- | spec/factories/packages/package_file.rb | 9 | ||||
-rw-r--r-- | spec/factories/projects.rb | 8 | ||||
-rw-r--r-- | spec/factories/usage_data.rb | 10 |
17 files changed, 143 insertions, 20 deletions
diff --git a/spec/factories/audit_events.rb b/spec/factories/audit_events.rb index 05b86d2f13b..10f60591922 100644 --- a/spec/factories/audit_events.rb +++ b/spec/factories/audit_events.rb @@ -51,6 +51,7 @@ FactoryBot.define do trait :unauthenticated do author_id { -1 } + author_name { 'An unauthenticated user' } details do { custom_message: 'Custom action', diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index 395d3ea598c..0e535aeaa8d 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -508,6 +508,14 @@ FactoryBot.define do end end + trait :cluster_image_scanning do + options do + { + artifacts: { reports: { cluster_image_scanning: 'gl-cluster-image-scanning-report.json' } } + } + end + end + trait :license_scanning do options do { diff --git a/spec/factories/ci/pending_builds.rb b/spec/factories/ci/pending_builds.rb new file mode 100644 index 00000000000..90779ae8ab9 --- /dev/null +++ b/spec/factories/ci/pending_builds.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_pending_build, class: 'Ci::PendingBuild' do + build factory: :ci_build + project + protected { build.protected } + instance_runners_enabled { true } + end +end diff --git a/spec/factories/ci/reports/security/identifiers.rb b/spec/factories/ci/reports/security/identifiers.rb new file mode 100644 index 00000000000..5211cb5c54a --- /dev/null +++ b/spec/factories/ci/reports/security/identifiers.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_reports_security_identifier, class: '::Gitlab::Ci::Reports::Security::Identifier' do + external_id { 'PREDICTABLE_RANDOM' } + external_type { 'find_sec_bugs_type' } + name { "#{external_type}-#{external_id}" } + + skip_create + + initialize_with do + ::Gitlab::Ci::Reports::Security::Identifier.new(**attributes) + end + end +end diff --git a/spec/factories/ci/reports/security/links.rb b/spec/factories/ci/reports/security/links.rb new file mode 100644 index 00000000000..77af827e7be --- /dev/null +++ b/spec/factories/ci/reports/security/links.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_reports_security_link, class: '::Gitlab::Ci::Reports::Security::Link' do + name { 'CVE-2020-0202' } + url { 'https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-0202' } + + skip_create + + initialize_with do + ::Gitlab::Ci::Reports::Security::Link.new(**attributes) + end + end +end diff --git a/spec/factories/ci/reports/security/scanners.rb b/spec/factories/ci/reports/security/scanners.rb new file mode 100644 index 00000000000..8b68ebdb47a --- /dev/null +++ b/spec/factories/ci/reports/security/scanners.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_reports_security_scanner, class: '::Gitlab::Ci::Reports::Security::Scanner' do + external_id { 'find_sec_bugs' } + name { 'Find Security Bugs' } + vendor { 'Security Scanner Vendor' } + version { '1.0.0' } + + skip_create + + initialize_with do + ::Gitlab::Ci::Reports::Security::Scanner.new(**attributes) + end + end + + factory :ci_reports_security_scan, class: '::Gitlab::Ci::Reports::Security::Scan' do + status { 'success' } + type { 'sast' } + start_time { 'placeholder' } + end_time { 'placeholder' } + + skip_create + + initialize_with do + ::Gitlab::Ci::Reports::Security::Scan.new(attributes) + end + end +end diff --git a/spec/factories/ci/running_builds.rb b/spec/factories/ci/running_builds.rb new file mode 100644 index 00000000000..96d2e6913f4 --- /dev/null +++ b/spec/factories/ci/running_builds.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_running_build, class: 'Ci::RunningBuild' do + build factory: :ci_build + project + runner factory: :ci_runner + runner_type { runner.runner_type } + end +end diff --git a/spec/factories/events.rb b/spec/factories/events.rb index c9e4ada3ffa..d182dc9f95f 100644 --- a/spec/factories/events.rb +++ b/spec/factories/events.rb @@ -17,7 +17,6 @@ FactoryBot.define do trait(:left) { action { :left } } trait(:destroyed) { action { :destroyed } } trait(:expired) { action { :expired } } - trait(:archived) { action { :archived } } trait(:approved) { action { :approved } } factory :closed_issue_event do diff --git a/spec/factories/integration_data.rb b/spec/factories/integration_data.rb index a6b2693b8df..a7406794437 100644 --- a/spec/factories/integration_data.rb +++ b/spec/factories/integration_data.rb @@ -4,7 +4,7 @@ # The factories are used when creating integrations. FactoryBot.define do factory :jira_tracker_data, class: 'Integrations::JiraTrackerData' do - integration factory: :jira_service + integration factory: :jira_integration end factory :issue_tracker_data, class: 'Integrations::IssueTrackerData' do diff --git a/spec/factories/integrations.rb b/spec/factories/integrations.rb index 1dd2839aa46..ed8a562b331 100644 --- a/spec/factories/integrations.rb +++ b/spec/factories/integrations.rb @@ -27,7 +27,7 @@ FactoryBot.define do end end - factory :prometheus_service do + factory :prometheus_integration, class: 'Integrations::Prometheus' do project active { true } properties do @@ -45,7 +45,7 @@ FactoryBot.define do token { 'test' } end - factory :jira_service, class: 'Integrations::Jira' do + factory :jira_integration, class: 'Integrations::Jira' do project active { true } type { 'JiraService' } @@ -91,13 +91,13 @@ FactoryBot.define do issue_tracker end - factory :redmine_service, class: 'Integrations::Redmine' do + factory :redmine_integration, class: 'Integrations::Redmine' do project active { true } issue_tracker end - factory :youtrack_service, class: 'Integrations::Youtrack' do + factory :youtrack_integration, class: 'Integrations::Youtrack' do project active { true } issue_tracker @@ -160,20 +160,21 @@ FactoryBot.define do password { 'my-secret-password' } end - factory :slack_service, class: 'Integrations::Slack' do + # avoids conflict with slack_integration factory + factory :integrations_slack, class: 'Integrations::Slack' do project active { true } webhook { 'https://slack.service.url' } type { 'SlackService' } end - factory :slack_slash_commands_service, class: 'Integrations::SlackSlashCommands' do + factory :slack_slash_commands_integration, class: 'Integrations::SlackSlashCommands' do project active { true } type { 'SlackSlashCommandsService' } end - factory :pipelines_email_service, class: 'Integrations::PipelinesEmail' do + factory :pipelines_email_integration, class: 'Integrations::PipelinesEmail' do project active { true } type { 'PipelinesEmailService' } diff --git a/spec/factories/merge_request_cleanup_schedules.rb b/spec/factories/merge_request_cleanup_schedules.rb index a89d0c88731..ecf0d5818e4 100644 --- a/spec/factories/merge_request_cleanup_schedules.rb +++ b/spec/factories/merge_request_cleanup_schedules.rb @@ -3,6 +3,19 @@ FactoryBot.define do factory :merge_request_cleanup_schedule, class: 'MergeRequest::CleanupSchedule' do merge_request - scheduled_at { Time.current } + scheduled_at { 1.day.ago } + + trait :running do + status { MergeRequest::CleanupSchedule::STATUSES[:running] } + end + + trait :completed do + status { MergeRequest::CleanupSchedule::STATUSES[:completed] } + completed_at { Time.current } + end + + trait :failed do + status { MergeRequest::CleanupSchedule::STATUSES[:failed] } + end end end diff --git a/spec/factories/merge_request_diff_commit_users.rb b/spec/factories/merge_request_diff_commit_users.rb new file mode 100644 index 00000000000..94bd358454c --- /dev/null +++ b/spec/factories/merge_request_diff_commit_users.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :merge_request_diff_commit_user, class: 'MergeRequest::DiffCommitUser' do + name { generate(:name) } + email { generate(:email) } + end +end diff --git a/spec/factories/packages.rb b/spec/factories/packages.rb index cedda8d0854..cd9c8a8bfbb 100644 --- a/spec/factories/packages.rb +++ b/spec/factories/packages.rb @@ -162,6 +162,12 @@ FactoryBot.define do pkg.nuget_metadatum = build(:nuget_metadatum) end end + + trait(:with_symbol_package) do + after :create do |package| + create :package_file, :snupkg, package: package, file_name: "#{package.name}.#{package.version}.snupkg" + end + end end factory :pypi_package do diff --git a/spec/factories/packages/helm/file_metadatum.rb b/spec/factories/packages/helm/file_metadatum.rb index e809f592546..cbc7e114ef6 100644 --- a/spec/factories/packages/helm/file_metadatum.rb +++ b/spec/factories/packages/helm/file_metadatum.rb @@ -3,7 +3,7 @@ FactoryBot.define do factory :helm_file_metadatum, class: 'Packages::Helm::FileMetadatum' do package_file { association(:helm_package_file, without_loaded_metadatum: true) } - channel { 'stable' } + sequence(:channel) { |n| "#{FFaker::Lorem.word}-#{n}" } metadata { { 'name': package_file.package.name, 'version': package_file.package.version, 'apiVersion': 'v2' } } end end diff --git a/spec/factories/packages/package_file.rb b/spec/factories/packages/package_file.rb index d82fbe02311..ac121da432c 100644 --- a/spec/factories/packages/package_file.rb +++ b/spec/factories/packages/package_file.rb @@ -205,6 +205,7 @@ FactoryBot.define do package { association(:helm_package, without_package_files: true) } file_name { "#{package.name}-#{package.version}.tgz" } file_fixture { "spec/fixtures/packages/helm/rook-ceph-v1.5.8.tgz" } + file_sha256 { 'fd2b2fa0329e80a2a602c2bb3b40608bcd6ee5cf96cf46fd0d2800a4c129c9db' } transient do without_loaded_metadatum { false } @@ -271,6 +272,14 @@ FactoryBot.define do size { 300.kilobytes } end + trait(:snupkg) do + package + file_fixture { 'spec/fixtures/packages/nuget/package.snupkg' } + file_name { 'package.snupkg' } + file_sha1 { '5fe852b2a6abd96c22c11fa1ff2fb19d9ce58b57' } + size { 300.kilobytes } + end + trait(:gem) do package file_fixture { 'spec/fixtures/packages/rubygems/package-0.0.1.gem' } diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 6641d8749f9..84686c58a8e 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -396,24 +396,24 @@ FactoryBot.define do factory :redmine_project, parent: :project do has_external_issue_tracker { true } - redmine_service + redmine_integration end factory :youtrack_project, parent: :project do has_external_issue_tracker { true } - youtrack_service + youtrack_integration end factory :jira_project, parent: :project do has_external_issue_tracker { true } - jira_service + jira_integration end factory :prometheus_project, parent: :project do after :create do |project| - project.create_prometheus_service( + project.create_prometheus_integration( active: true, properties: { api_url: 'https://prometheus.example.com/', diff --git a/spec/factories/usage_data.rb b/spec/factories/usage_data.rb index 2aa926e4dd8..4593294fd14 100644 --- a/spec/factories/usage_data.rb +++ b/spec/factories/usage_data.rb @@ -9,16 +9,16 @@ FactoryBot.define do projects << create(:project, :repository) group = create(:group) create(:board, project: projects[0]) - create(:jira_service, project: projects[0]) - create(:jira_service, :without_properties_callback, project: projects[1]) - create(:jira_service, :jira_cloud_service, project: projects[2]) - create(:jira_service, :without_properties_callback, project: projects[3], properties: { url: 'https://mysite.atlassian.net' }) + create(:jira_integration, project: projects[0]) + create(:jira_integration, :without_properties_callback, project: projects[1]) + create(:jira_integration, :jira_cloud_service, project: projects[2]) + create(:jira_integration, :without_properties_callback, project: projects[3], properties: { url: 'https://mysite.atlassian.net' }) jira_label = create(:label, project: projects[0]) create(:jira_import_state, :finished, project: projects[0], label: jira_label, failed_to_import_count: 2, imported_issues_count: 7, total_issue_count: 9) create(:jira_import_state, :finished, project: projects[1], label: jira_label, imported_issues_count: 3, total_issue_count: 3) 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(:prometheus_integration, 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) |