diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /spec/factories | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) | |
download | gitlab-ce-4555e1b21c365ed8303ffb7a3325d773c9b8bf31.tar.gz |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/factories')
31 files changed, 262 insertions, 61 deletions
diff --git a/spec/factories/alert_management/alerts.rb b/spec/factories/alert_management/alerts.rb index ee1225b9542..f63a3c9f7f5 100644 --- a/spec/factories/alert_management/alerts.rb +++ b/spec/factories/alert_management/alerts.rb @@ -95,6 +95,10 @@ FactoryBot.define do severity { 'unknown' } end + trait :threat_monitoring do + domain { :threat_monitoring } + end + trait :prometheus do monitoring_tool { Gitlab::AlertManagement::Payload::MONITORING_TOOLS[:prometheus] } payload do @@ -109,6 +113,20 @@ FactoryBot.define do end end + trait :cilium do + monitoring_tool { Gitlab::AlertManagement::Payload::MONITORING_TOOLS[:cilium] } + payload do + { + annotations: { + title: 'This is a cilium alert', + summary: 'Summary of the alert', + description: 'Description of the alert' + }, + startsAt: started_at + }.with_indifferent_access + end + end + trait :all_fields do with_issue with_assignee diff --git a/spec/factories/analytics/cycle_analytics/project_stages.rb b/spec/factories/analytics/cycle_analytics/project_stages.rb index 3a481bd20fd..e673c4957b0 100644 --- a/spec/factories/analytics/cycle_analytics/project_stages.rb +++ b/spec/factories/analytics/cycle_analytics/project_stages.rb @@ -6,6 +6,7 @@ FactoryBot.define do sequence(:name) { |n| "Stage ##{n}" } hidden { false } issue_stage + value_stream { association(:cycle_analytics_project_value_stream, project: project) } trait :issue_stage do start_event_identifier { Gitlab::Analytics::CycleAnalytics::StageEvents::IssueCreated.identifier } diff --git a/spec/factories/analytics/cycle_analytics/project_value_streams.rb b/spec/factories/analytics/cycle_analytics/project_value_streams.rb new file mode 100644 index 00000000000..45a6470b0aa --- /dev/null +++ b/spec/factories/analytics/cycle_analytics/project_value_streams.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :cycle_analytics_project_value_stream, class: 'Analytics::CycleAnalytics::ProjectValueStream' do + sequence(:name) { |n| "Value Stream ##{n}" } + + project + end +end diff --git a/spec/factories/bulk_import/export_uploads.rb b/spec/factories/bulk_import/export_uploads.rb new file mode 100644 index 00000000000..9f03498b9d9 --- /dev/null +++ b/spec/factories/bulk_import/export_uploads.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :bulk_import_export_upload, class: 'BulkImports::ExportUpload' do + export { association(:bulk_import_export) } + end +end diff --git a/spec/factories/bulk_import/exports.rb b/spec/factories/bulk_import/exports.rb new file mode 100644 index 00000000000..dd8831ce33a --- /dev/null +++ b/spec/factories/bulk_import/exports.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :bulk_import_export, class: 'BulkImports::Export', traits: %i[started] do + group + relation { 'labels' } + + trait :started do + status { 0 } + + sequence(:jid) { |n| "bulk_import_export_#{n}" } + end + + trait :finished do + status { 1 } + + sequence(:jid) { |n| "bulk_import_export_#{n}" } + end + + trait :failed do + status { -1 } + end + end +end diff --git a/spec/factories/chat_names.rb b/spec/factories/chat_names.rb index 73c885806f2..56567394bf5 100644 --- a/spec/factories/chat_names.rb +++ b/spec/factories/chat_names.rb @@ -2,8 +2,8 @@ FactoryBot.define do factory :chat_name, class: 'ChatName' do - user factory: :user - service factory: :service + user + integration team_id { 'T0001' } team_domain { 'Awesome Team' } diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index b06d581d2c0..f99021ad223 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -include ActionDispatch::TestProcess - FactoryBot.define do factory :ci_build, class: 'Ci::Build', parent: :ci_processable do name { 'test' } @@ -371,6 +369,12 @@ FactoryBot.define do end end + trait :codequality_reports_without_degradation do + after(:build) do |build| + build.job_artifacts << create(:ci_job_artifact, :codequality_without_errors, job: build) + end + end + trait :terraform_reports do after(:build) do |build| build.job_artifacts << create(:ci_job_artifact, :terraform, job: build) @@ -427,7 +431,8 @@ FactoryBot.define do name: 'Release $CI_COMMIT_SHA', description: 'Created using the release-cli $EXTRA_DESCRIPTION', tag_name: 'release-$CI_COMMIT_SHA', - ref: '$CI_COMMIT_SHA' + ref: '$CI_COMMIT_SHA', + assets: { links: [{ name: 'asset1', url: 'https://example.com/assets/1' }] } } } end diff --git a/spec/factories/ci/job_artifacts.rb b/spec/factories/ci/job_artifacts.rb index bfd8506566b..17cd495e217 100644 --- a/spec/factories/ci/job_artifacts.rb +++ b/spec/factories/ci/job_artifacts.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -include ActionDispatch::TestProcess - FactoryBot.define do factory :ci_job_artifact, class: 'Ci::JobArtifact' do job factory: :ci_build @@ -279,6 +277,16 @@ FactoryBot.define do end end + trait :sast_minimal 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-report-minimal.json'), 'application/json') + end + end + trait :secret_detection do file_type { :secret_detection } file_format { :raw } diff --git a/spec/factories/ci/pipeline_artifacts.rb b/spec/factories/ci/pipeline_artifacts.rb index 3250c7abb4b..85277ce6fbf 100644 --- a/spec/factories/ci/pipeline_artifacts.rb +++ b/spec/factories/ci/pipeline_artifacts.rb @@ -13,6 +13,10 @@ FactoryBot.define do Rails.root.join('spec/fixtures/pipeline_artifacts/code_coverage.json'), 'application/json') end + trait :unlocked do + association :pipeline, :unlocked, factory: :ci_pipeline + end + trait :checksummed do verification_checksum { 'abc' } end diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb index 87b9a6c0e23..4fc7d945881 100644 --- a/spec/factories/ci/pipelines.rb +++ b/spec/factories/ci/pipelines.rb @@ -81,6 +81,10 @@ FactoryBot.define do status { :failed } end + trait :unlocked do + locked { Ci::Pipeline.lockeds[:unlocked] } + end + trait :protected do add_attribute(:protected) { true } end @@ -237,7 +241,7 @@ FactoryBot.define do trait :merged_result_pipeline do detached_merge_request_pipeline - sha { 'test-merge-sha'} + sha { 'mergeSha' } ref { merge_request.merge_ref_path } source_sha { merge_request.source_branch_sha } target_sha { merge_request.target_branch_sha } diff --git a/spec/factories/ci/runner_namespaces.rb b/spec/factories/ci/runner_namespaces.rb new file mode 100644 index 00000000000..a5060d196ca --- /dev/null +++ b/spec/factories/ci/runner_namespaces.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_runner_namespace, class: 'Ci::RunnerNamespace' do + runner factory: [:ci_runner, :group] + group + end +end diff --git a/spec/factories/clusters/integrations/elastic_stack.rb b/spec/factories/clusters/integrations/elastic_stack.rb new file mode 100644 index 00000000000..1ab3256845b --- /dev/null +++ b/spec/factories/clusters/integrations/elastic_stack.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :clusters_integrations_elastic_stack, class: 'Clusters::Integrations::ElasticStack' do + cluster factory: %i(cluster provided_by_gcp) + enabled { true } + + trait :disabled do + enabled { false } + end + end +end diff --git a/spec/factories/gitlab/database/background_migration/batched_jobs.rb b/spec/factories/gitlab/database/background_migration/batched_jobs.rb index 52bc04447da..cec20616f7f 100644 --- a/spec/factories/gitlab/database/background_migration/batched_jobs.rb +++ b/spec/factories/gitlab/database/background_migration/batched_jobs.rb @@ -8,5 +8,6 @@ FactoryBot.define do max_value { 10 } batch_size { 5 } sub_batch_size { 1 } + pause_ms { 100 } end end diff --git a/spec/factories/gitlab/database/background_migration/batched_migrations.rb b/spec/factories/gitlab/database/background_migration/batched_migrations.rb index 49cbdc5a8fb..c03841d8c02 100644 --- a/spec/factories/gitlab/database/background_migration/batched_migrations.rb +++ b/spec/factories/gitlab/database/background_migration/batched_migrations.rb @@ -10,5 +10,6 @@ FactoryBot.define do table_name { :events } column_name { :id } total_tuple_count { 10_000 } + pause_ms { 100 } end end diff --git a/spec/factories/gitlab/jwt_token.rb b/spec/factories/gitlab/jwt_token.rb new file mode 100644 index 00000000000..bc00c6a5ff4 --- /dev/null +++ b/spec/factories/gitlab/jwt_token.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :jwt_token, class: 'Gitlab::JWTToken' do + skip_create + + initialize_with { new } + + trait :with_custom_payload do + transient do + custom_payload { {} } + end + + after(:build) do |jwt, evaluator| + evaluator.custom_payload.each do |key, value| + jwt[key] = value + end + end + end + end +end diff --git a/spec/factories/services_data.rb b/spec/factories/integration_data.rb index 7b6a705c791..2541a3d2da3 100644 --- a/spec/factories/services_data.rb +++ b/spec/factories/integration_data.rb @@ -4,15 +4,15 @@ # The factories are used when creating integrations. FactoryBot.define do factory :jira_tracker_data do - service + integration factory: :jira_service end factory :issue_tracker_data do - service + integration end factory :open_project_tracker_data do - service + integration factory: :open_project_service url { 'http://openproject.example.com'} token { 'supersecret' } project_identifier_code { 'PRJ-1' } diff --git a/spec/factories/services.rb b/spec/factories/integrations.rb index 25ef75880bb..6bd6deb262a 100644 --- a/spec/factories/services.rb +++ b/spec/factories/integrations.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true FactoryBot.define do - factory :service do + factory :integration, aliases: [:service] do project - type { 'Service' } + type { 'Integration' } end factory :custom_issue_tracker_service, class: 'CustomIssueTrackerService' do @@ -12,7 +12,7 @@ FactoryBot.define do issue_tracker end - factory :emails_on_push_service do + factory :emails_on_push_service, class: 'Integrations::EmailsOnPush' do project type { 'EmailsOnPushService' } active { true } @@ -65,21 +65,21 @@ FactoryBot.define do deployment_type { 'cloud' } end - before(:create) do |service, evaluator| + after(:build) do |integration, evaluator| if evaluator.create_data - create(:jira_tracker_data, service: service, - url: evaluator.url, api_url: evaluator.api_url, - jira_issue_transition_automatic: evaluator.jira_issue_transition_automatic, - jira_issue_transition_id: evaluator.jira_issue_transition_id, - username: evaluator.username, password: evaluator.password, issues_enabled: evaluator.issues_enabled, - project_key: evaluator.project_key, vulnerabilities_enabled: evaluator.vulnerabilities_enabled, - vulnerabilities_issuetype: evaluator.vulnerabilities_issuetype, deployment_type: evaluator.deployment_type + integration.jira_tracker_data = build(:jira_tracker_data, + integration: integration, url: evaluator.url, api_url: evaluator.api_url, + jira_issue_transition_automatic: evaluator.jira_issue_transition_automatic, + jira_issue_transition_id: evaluator.jira_issue_transition_id, + username: evaluator.username, password: evaluator.password, issues_enabled: evaluator.issues_enabled, + project_key: evaluator.project_key, vulnerabilities_enabled: evaluator.vulnerabilities_enabled, + vulnerabilities_issuetype: evaluator.vulnerabilities_issuetype, deployment_type: evaluator.deployment_type ) end end end - factory :confluence_service do + factory :confluence_service, class: 'Integrations::Confluence' do project active { true } confluence_url { 'https://example.atlassian.net/wiki' } @@ -117,10 +117,11 @@ FactoryBot.define do new_issue_url { 'http://new-issue.example.com' } end - before(:create) do |service, evaluator| + after(:build) do |integration, 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 + integration.issue_tracker_data = build(:issue_tracker_data, + integration: integration, project_url: evaluator.project_url, + issues_url: evaluator.issues_url, new_issue_url: evaluator.new_issue_url ) end end @@ -145,9 +146,9 @@ FactoryBot.define do project_identifier_code { 'PRJ-1' } end - before(:create) do |service, evaluator| - create(:open_project_tracker_data, service: service, - url: evaluator.url, api_url: evaluator.api_url, token: evaluator.token, + after(:build) do |integration, evaluator| + integration.open_project_tracker_data = build(:open_project_tracker_data, + integration: integration, 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 ) end @@ -159,12 +160,6 @@ FactoryBot.define do password { 'my-secret-password' } end - factory :hipchat_service do - project - type { 'HipchatService' } - token { 'test_token' } - end - factory :slack_service do project active { true } @@ -186,7 +181,7 @@ FactoryBot.define do issue_tracker_data { nil } create_data { false } - after(:build) do |service| + after(:build) do IssueTrackerService.skip_callback(:validation, :before, :handle_properties) end diff --git a/spec/factories/issues.rb b/spec/factories/issues.rb index 5c62de4d08d..2d52747dece 100644 --- a/spec/factories/issues.rb +++ b/spec/factories/issues.rb @@ -13,6 +13,14 @@ FactoryBot.define do confidential { true } end + trait :with_asc_relative_position do + sequence(:relative_position) { |n| n * 1000 } + end + + trait :with_desc_relative_position do + sequence(:relative_position) { |n| -n * 1000 } + end + trait :opened do state_id { Issue.available_states[:opened] } end diff --git a/spec/factories/lfs_objects.rb b/spec/factories/lfs_objects.rb index 35fc4db8519..59c6ea5f55a 100644 --- a/spec/factories/lfs_objects.rb +++ b/spec/factories/lfs_objects.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -include ActionDispatch::TestProcess - FactoryBot.define do factory :lfs_object do sequence(:oid) { |n| "b68143e6463773b1b6c6fd009a76c32aeec041faff32ba2ed42fd7f708a%05x" % n } diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb index fce44c2cee0..0aab41df90b 100644 --- a/spec/factories/merge_requests.rb +++ b/spec/factories/merge_requests.rb @@ -279,7 +279,7 @@ FactoryBot.define do trait :with_merge_request_pipeline do transient do - merge_sha { 'test-merge-sha' } + merge_sha { 'mergesha' } source_sha { source_branch_sha } target_sha { target_branch_sha } end diff --git a/spec/factories/namespace_package_settings.rb b/spec/factories/namespace_package_settings.rb index 875933ce84f..042808f042f 100644 --- a/spec/factories/namespace_package_settings.rb +++ b/spec/factories/namespace_package_settings.rb @@ -7,6 +7,9 @@ FactoryBot.define do maven_duplicates_allowed { true } maven_duplicate_exception_regex { 'SNAPSHOT' } + generic_duplicates_allowed { true } + generic_duplicate_exception_regex { 'foo' } + trait :group do namespace { association(:group) } end diff --git a/spec/factories/namespaces.rb b/spec/factories/namespaces.rb index f4b57369678..957ec88420d 100644 --- a/spec/factories/namespaces.rb +++ b/spec/factories/namespaces.rb @@ -5,22 +5,7 @@ FactoryBot.define do sequence(:name) { |n| "namespace#{n}" } path { name.downcase.gsub(/\s/, '_') } - # This is a workaround to avoid the user creating another namespace via - # User#ensure_namespace_correct. We should try to remove it and then - # we could remove this workaround - association :owner, factory: :user, strategy: :build - before(:create) do |namespace| - owner = namespace.owner - - if owner - # We're changing the username here because we want to keep our path, - # and User#ensure_namespace_correct would change the path based on - # username, so we're forced to do this otherwise we'll need to change - # a lot of existing tests. - owner.username = namespace.path - owner.namespace = namespace - end - end + owner { association(:user, strategy: :build, namespace: instance, username: path) } trait :with_aggregation_schedule do after(:create) do |namespace| diff --git a/spec/factories/notes.rb b/spec/factories/notes.rb index 299d08972b7..c15ec91d2ce 100644 --- a/spec/factories/notes.rb +++ b/spec/factories/notes.rb @@ -2,8 +2,6 @@ require_relative '../support/helpers/repo_helpers' -include ActionDispatch::TestProcess - FactoryBot.define do factory :note do project diff --git a/spec/factories/packages.rb b/spec/factories/packages.rb index 9edee735af9..a8020f396fd 100644 --- a/spec/factories/packages.rb +++ b/spec/factories/packages.rb @@ -94,6 +94,22 @@ FactoryBot.define do end end + factory :helm_package do + sequence(:name) { |n| "package-#{n}" } + sequence(:version) { |n| "v1.0.#{n}" } + package_type { :helm } + + transient do + without_package_files { false } + end + + after :create do |package, evaluator| + unless evaluator.without_package_files + create :helm_package_file, package: package + end + end + end + factory :npm_package do sequence(:name) { |n| "@#{project.root_namespace.path}/package-#{n}"} version { '1.0.0' } @@ -113,6 +129,25 @@ FactoryBot.define do end end + factory :terraform_module_package do + sequence(:name) { |n| "module-#{n}/system" } + version { '1.0.0' } + package_type { :terraform_module } + + after :create do |package| + create :package_file, :terraform_module, package: package + end + + trait :with_build do + after :create do |package| + user = package.project.creator + pipeline = create(:ci_pipeline, user: user) + create(:ci_build, user: user, pipeline: pipeline) + create :package_build_info, package: package, pipeline: pipeline + end + end + end + factory :nuget_package do sequence(:name) { |n| "NugetPackage#{n}"} sequence(:version) { |n| "1.0.#{n}" } diff --git a/spec/factories/packages/helm/file_metadatum.rb b/spec/factories/packages/helm/file_metadatum.rb new file mode 100644 index 00000000000..e809f592546 --- /dev/null +++ b/spec/factories/packages/helm/file_metadatum.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :helm_file_metadatum, class: 'Packages::Helm::FileMetadatum' do + package_file { association(:helm_package_file, without_loaded_metadatum: true) } + channel { 'stable' } + 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 74400975670..e49e3f36635 100644 --- a/spec/factories/packages/package_file.rb +++ b/spec/factories/packages/package_file.rb @@ -201,10 +201,29 @@ FactoryBot.define do end end + factory :helm_package_file 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" } + + transient do + without_loaded_metadatum { false } + channel { 'stable' } + end + + after :create do |package_file, evaluator| + unless evaluator.without_loaded_metadatum + create :helm_file_metadatum, package_file: package_file, channel: evaluator.channel + end + 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' } + file_md5 { '0a7392d24f42f83068fa3767c5310052' } + file_sha256 { '440e5e148a25331bbd7991575f7d54933c0ebf6cc735a18ee5066ac1381bb590' } size { 100.kilobytes } end @@ -212,6 +231,8 @@ FactoryBot.define 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' } + file_md5 { '0a7392d24f42f83068fa3767c5310052' } + file_sha256 { '440e5e148a25331bbd7991575f7d54933c0ebf6cc735a18ee5066ac1381bb590' } size { 200.kilobytes } end @@ -219,6 +240,8 @@ FactoryBot.define do file_fixture { 'spec/fixtures/packages/maven/maven-metadata.xml' } file_name { 'maven-metadata.xml' } file_sha1 { '42b1bdc80de64953b6876f5a8c644f20204011b0' } + file_md5 { '0a7392d24f42f83068fa3767c5310052' } + file_sha256 { '440e5e148a25331bbd7991575f7d54933c0ebf6cc735a18ee5066ac1381bb590' } size { 300.kilobytes } end @@ -231,6 +254,13 @@ FactoryBot.define do size { 400.kilobytes } end + trait(:terraform_module) do + file_fixture { 'spec/fixtures/packages/terraform_module/module-system-v1.0.0.tgz' } + file_name { 'module-system-v1.0.0.tgz' } + file_sha1 { 'abf850accb1947c0c0e3ef4b441b771bb5c9ae3c' } + size { 806.bytes } + end + trait(:nuget) do package file_fixture { 'spec/fixtures/packages/nuget/package.nupkg' } diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 80392a2fece..f4f1e1bcbda 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -194,7 +194,7 @@ FactoryBot.define do filename, content, message: "Automatically created file #{filename}", - branch_name: project.default_branch_or_master + branch_name: project.default_branch || 'master' ) end end diff --git a/spec/factories/service_hooks.rb b/spec/factories/service_hooks.rb index ff819f4f8d0..ea70d2fc433 100644 --- a/spec/factories/service_hooks.rb +++ b/spec/factories/service_hooks.rb @@ -3,6 +3,6 @@ FactoryBot.define do factory :service_hook do url { generate(:url) } - service + integration end end diff --git a/spec/factories/usage_data.rb b/spec/factories/usage_data.rb index 714f8451f39..2aa926e4dd8 100644 --- a/spec/factories/usage_data.rb +++ b/spec/factories/usage_data.rb @@ -32,8 +32,6 @@ FactoryBot.define do 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) - create(:service, project: projects[0], type: 'AlertsService', active: true) - create(:service, project: projects[1], type: 'AlertsService', active: false) alert_bot_issues = create_list(:incident, 2, project: projects[0], author: User.alert_bot) create_list(:incident, 2, project: projects[1], author: User.alert_bot) issues = create_list(:issue, 4, project: projects[0]) diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 9b5e4a981a0..476c57f2d80 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -27,6 +27,10 @@ FactoryBot.define do after(:build) { |user, _| user.block_pending_approval! } end + trait :banned do + after(:build) { |user, _| user.ban! } + end + trait :ldap_blocked do after(:build) { |user, _| user.ldap_block! } end @@ -80,6 +84,12 @@ FactoryBot.define do last_sign_in_ip { '127.0.0.1' } end + trait :with_credit_card_validation do + after :create do |user| + create :credit_card_validation, user: user + end + end + trait :two_factor_via_otp do before(:create) do |user| user.otp_required_for_login = true diff --git a/spec/factories/users/credit_card_validations.rb b/spec/factories/users/credit_card_validations.rb new file mode 100644 index 00000000000..09940347708 --- /dev/null +++ b/spec/factories/users/credit_card_validations.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :credit_card_validation, class: 'Users::CreditCardValidation' do + user + + credit_card_validated_at { Time.current } + end +end |