From 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 20 Sep 2021 13:18:24 +0000 Subject: Add latest changes from gitlab-org/gitlab@14-3-stable-ee --- spec/factories/ci/build_trace_metadata.rb | 7 +++++ spec/factories/ci/builds.rb | 8 ++++++ spec/factories/ci/pending_builds.rb | 1 + spec/factories/ci/reports/security/flags.rb | 15 ++++++++++ spec/factories/clusters/agents.rb | 1 + .../clusters/agents/group_authorizations.rb | 10 +++++++ .../clusters/agents/project_authorizations.rb | 10 +++++++ spec/factories/compares.rb | 22 +++++++++++++++ spec/factories/customer_relations/contacts.rb | 14 ++++++++++ spec/factories/dependency_proxy.rb | 2 ++ .../dependency_proxy/image_ttl_group_policies.rb | 10 +++++++ spec/factories/integration_data.rb | 10 ++++++- spec/factories/integrations.rb | 32 ++++++++++++++++++++++ spec/factories/issues.rb | 2 ++ spec/factories/namespaces/project_namespaces.rb | 12 ++++++++ spec/factories/operations/feature_flag_scopes.rb | 10 ------- spec/factories/operations/feature_flags.rb | 8 ------ spec/factories/packages.rb | 10 ++++++- spec/factories/packages/helm/file_metadatum.rb | 10 ++++++- spec/factories/packages/package_file.rb | 3 +- spec/factories/plan_limits.rb | 2 ++ spec/factories/project_topics.rb | 8 ++++++ spec/factories/topics.rb | 7 +++++ spec/factories/users.rb | 4 --- spec/factories/users/group_user_callouts.rb | 10 +++++++ spec/factories/work_item/work_item_types.rb | 11 ++++++++ 26 files changed, 213 insertions(+), 26 deletions(-) create mode 100644 spec/factories/ci/build_trace_metadata.rb create mode 100644 spec/factories/ci/reports/security/flags.rb create mode 100644 spec/factories/clusters/agents/group_authorizations.rb create mode 100644 spec/factories/clusters/agents/project_authorizations.rb create mode 100644 spec/factories/compares.rb create mode 100644 spec/factories/customer_relations/contacts.rb create mode 100644 spec/factories/dependency_proxy/image_ttl_group_policies.rb create mode 100644 spec/factories/namespaces/project_namespaces.rb delete mode 100644 spec/factories/operations/feature_flag_scopes.rb create mode 100644 spec/factories/project_topics.rb create mode 100644 spec/factories/topics.rb create mode 100644 spec/factories/users/group_user_callouts.rb (limited to 'spec/factories') diff --git a/spec/factories/ci/build_trace_metadata.rb b/spec/factories/ci/build_trace_metadata.rb new file mode 100644 index 00000000000..e5f8ae40cc5 --- /dev/null +++ b/spec/factories/ci/build_trace_metadata.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_build_trace_metadata, class: 'Ci::BuildTraceMetadata' do + build factory: :ci_build + end +end diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index f3500301e22..1108c606df3 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -534,6 +534,14 @@ FactoryBot.define do end end + trait :coverage_fuzzing do + options do + { + artifacts: { reports: { coverage_fuzzing: 'gl-coverage-fuzzing-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 index fbd76e07d8e..31e42e1bc9e 100644 --- a/spec/factories/ci/pending_builds.rb +++ b/spec/factories/ci/pending_builds.rb @@ -8,5 +8,6 @@ FactoryBot.define do instance_runners_enabled { true } namespace { project.namespace } minutes_exceeded { false } + tag_ids { build.tags_ids } end end diff --git a/spec/factories/ci/reports/security/flags.rb b/spec/factories/ci/reports/security/flags.rb new file mode 100644 index 00000000000..7efe72276c9 --- /dev/null +++ b/spec/factories/ci/reports/security/flags.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ci_reports_security_flag, class: '::Gitlab::Ci::Reports::Security::Flag' do + type { 'flagged-as-likely-false-positive' } + origin { 'post analyzer X' } + description { 'static string to sink' } + + skip_create + + initialize_with do + ::Gitlab::Ci::Reports::Security::Flag.new(**attributes) + end + end +end diff --git a/spec/factories/clusters/agents.rb b/spec/factories/clusters/agents.rb index 334671f69f0..4dc82f91bab 100644 --- a/spec/factories/clusters/agents.rb +++ b/spec/factories/clusters/agents.rb @@ -3,6 +3,7 @@ FactoryBot.define do factory :cluster_agent, class: 'Clusters::Agent' do project + association :created_by_user, factory: :user sequence(:name) { |n| "agent-#{n}" } end diff --git a/spec/factories/clusters/agents/group_authorizations.rb b/spec/factories/clusters/agents/group_authorizations.rb new file mode 100644 index 00000000000..6ea3668dc66 --- /dev/null +++ b/spec/factories/clusters/agents/group_authorizations.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :agent_group_authorization, class: 'Clusters::Agents::GroupAuthorization' do + association :agent, factory: :cluster_agent + group + + config { { default_namespace: 'production' } } + end +end diff --git a/spec/factories/clusters/agents/project_authorizations.rb b/spec/factories/clusters/agents/project_authorizations.rb new file mode 100644 index 00000000000..176ecc3b517 --- /dev/null +++ b/spec/factories/clusters/agents/project_authorizations.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :agent_project_authorization, class: 'Clusters::Agents::ProjectAuthorization' do + association :agent, factory: :cluster_agent + project + + config { { default_namespace: 'production' } } + end +end diff --git a/spec/factories/compares.rb b/spec/factories/compares.rb new file mode 100644 index 00000000000..4dd94b93049 --- /dev/null +++ b/spec/factories/compares.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :compare do + skip_create # No persistence + + start_project { association(:project, :repository) } + target_project { start_project } + + start_ref { 'master' } + target_ref { 'feature' } + + base_sha { nil } + straight { false } + + initialize_with do + CompareService + .new(start_project, start_ref) + .execute(target_project, target_ref, base_sha: base_sha, straight: straight) + end + end +end diff --git a/spec/factories/customer_relations/contacts.rb b/spec/factories/customer_relations/contacts.rb new file mode 100644 index 00000000000..437f8feea48 --- /dev/null +++ b/spec/factories/customer_relations/contacts.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :contact, class: 'CustomerRelations::Contact' do + group + + first_name { generate(:name) } + last_name { generate(:name) } + + trait :with_organization do + organization + end + end +end diff --git a/spec/factories/dependency_proxy.rb b/spec/factories/dependency_proxy.rb index 94a7986a8fa..c2873ce9b5e 100644 --- a/spec/factories/dependency_proxy.rb +++ b/spec/factories/dependency_proxy.rb @@ -3,12 +3,14 @@ FactoryBot.define do factory :dependency_proxy_blob, class: 'DependencyProxy::Blob' do group + size { 1234 } file { fixture_file_upload('spec/fixtures/dependency_proxy/a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4.gz') } file_name { 'a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4.gz' } end factory :dependency_proxy_manifest, class: 'DependencyProxy::Manifest' do group + size { 1234 } file { fixture_file_upload('spec/fixtures/dependency_proxy/manifest') } digest { 'sha256:d0710affa17fad5f466a70159cc458227bd25d4afb39514ef662ead3e6c99515' } file_name { 'alpine:latest.json' } diff --git a/spec/factories/dependency_proxy/image_ttl_group_policies.rb b/spec/factories/dependency_proxy/image_ttl_group_policies.rb new file mode 100644 index 00000000000..21e5dd44cf5 --- /dev/null +++ b/spec/factories/dependency_proxy/image_ttl_group_policies.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :image_ttl_group_policy, class: 'DependencyProxy::ImageTtlGroupPolicy' do + group + + enabled { true } + ttl { 90 } + end +end diff --git a/spec/factories/integration_data.rb b/spec/factories/integration_data.rb index a7406794437..4d0892556f8 100644 --- a/spec/factories/integration_data.rb +++ b/spec/factories/integration_data.rb @@ -7,13 +7,21 @@ FactoryBot.define do integration factory: :jira_integration end + factory :zentao_tracker_data, class: 'Integrations::ZentaoTrackerData' do + integration factory: :zentao_integration + url { 'https://jihudemo.zentao.net' } + api_url { '' } + api_token { 'ZENTAO_TOKEN' } + zentao_product_xid { '3' } + end + factory :issue_tracker_data, class: 'Integrations::IssueTrackerData' do integration end factory :open_project_tracker_data, class: 'Integrations::OpenProjectTrackerData' do integration factory: :open_project_service - url { 'http://openproject.example.com'} + url { 'http://openproject.example.com' } token { 'supersecret' } project_identifier_code { 'PRJ-1' } closed_status_id { '15' } diff --git a/spec/factories/integrations.rb b/spec/factories/integrations.rb index a5a17ca4058..cb1c94c25c1 100644 --- a/spec/factories/integrations.rb +++ b/spec/factories/integrations.rb @@ -12,6 +12,12 @@ FactoryBot.define do issue_tracker end + factory :datadog_integration, class: 'Integrations::Datadog' do + project + active { true } + api_key { 'secret' } + end + factory :emails_on_push_integration, class: 'Integrations::EmailsOnPush' do project type { 'EmailsOnPushService' } @@ -79,6 +85,32 @@ FactoryBot.define do end end + factory :zentao_integration, class: 'Integrations::Zentao' do + project + active { true } + type { 'ZentaoService' } + + transient do + create_data { true } + url { 'https://jihudemo.zentao.net' } + api_url { '' } + api_token { 'ZENTAO_TOKEN' } + zentao_product_xid { '3' } + end + + after(:build) do |integration, evaluator| + if evaluator.create_data + integration.zentao_tracker_data = build(:zentao_tracker_data, + integration: integration, + url: evaluator.url, + api_url: evaluator.api_url, + api_token: evaluator.api_token, + zentao_product_xid: evaluator.zentao_product_xid + ) + end + end + end + factory :confluence_integration, class: 'Integrations::Confluence' do project active { true } diff --git a/spec/factories/issues.rb b/spec/factories/issues.rb index 2d52747dece..8b53732a3c1 100644 --- a/spec/factories/issues.rb +++ b/spec/factories/issues.rb @@ -8,6 +8,7 @@ FactoryBot.define do updated_by { author } relative_position { RelativePositioning::START_POSITION } issue_type { :issue } + association :work_item_type, :default trait :confidential do confidential { true } @@ -59,6 +60,7 @@ FactoryBot.define do factory :incident do issue_type { :incident } + association :work_item_type, :default, :incident end end end diff --git a/spec/factories/namespaces/project_namespaces.rb b/spec/factories/namespaces/project_namespaces.rb new file mode 100644 index 00000000000..10b86f48090 --- /dev/null +++ b/spec/factories/namespaces/project_namespaces.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :project_namespace, class: 'Namespaces::ProjectNamespace' do + project + name { project.name } + path { project.path } + type { Namespaces::ProjectNamespace.sti_name } + owner { nil } + parent factory: :group + end +end diff --git a/spec/factories/operations/feature_flag_scopes.rb b/spec/factories/operations/feature_flag_scopes.rb deleted file mode 100644 index 4ca9b53f320..00000000000 --- a/spec/factories/operations/feature_flag_scopes.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -FactoryBot.define do - factory :operations_feature_flag_scope, class: 'Operations::FeatureFlagScope' do - association :feature_flag, factory: [:operations_feature_flag, :legacy_flag] - active { true } - strategies { [{ name: "default", parameters: {} }] } - sequence(:environment_scope) { |n| "review/patch-#{n}" } - end -end diff --git a/spec/factories/operations/feature_flags.rb b/spec/factories/operations/feature_flags.rb index 32e5ec9fb26..33c13a62445 100644 --- a/spec/factories/operations/feature_flags.rb +++ b/spec/factories/operations/feature_flags.rb @@ -6,13 +6,5 @@ FactoryBot.define do project active { true } version { :new_version_flag } - - trait :legacy_flag do - version { Operations::FeatureFlag.versions['legacy_flag'] } - end - - trait :new_version_flag do - version { Operations::FeatureFlag.versions['new_version_flag'] } - end end end diff --git a/spec/factories/packages.rb b/spec/factories/packages.rb index cd9c8a8bfbb..b04b7e691fe 100644 --- a/spec/factories/packages.rb +++ b/spec/factories/packages.rb @@ -112,7 +112,7 @@ FactoryBot.define do factory :npm_package do sequence(:name) { |n| "@#{project.root_namespace.path}/package-#{n}"} - version { '1.0.0' } + sequence(:version) { |n| "1.0.#{n}" } package_type { :npm } after :create do |package| @@ -354,4 +354,12 @@ FactoryBot.define do package sequence(:name) { |n| "tag-#{n}"} end + + factory :packages_build_info, class: 'Packages::BuildInfo' do + package + + trait :with_pipeline do + association :pipeline, factory: [:ci_pipeline, :with_job] + end + end end diff --git a/spec/factories/packages/helm/file_metadatum.rb b/spec/factories/packages/helm/file_metadatum.rb index cbc7e114ef6..3f599b5d5c0 100644 --- a/spec/factories/packages/helm/file_metadatum.rb +++ b/spec/factories/packages/helm/file_metadatum.rb @@ -2,8 +2,16 @@ FactoryBot.define do factory :helm_file_metadatum, class: 'Packages::Helm::FileMetadatum' do + transient do + description { nil } + end + package_file { association(:helm_package_file, without_loaded_metadatum: true) } sequence(:channel) { |n| "#{FFaker::Lorem.word}-#{n}" } - metadata { { 'name': package_file.package.name, 'version': package_file.package.version, 'apiVersion': 'v2' } } + metadata do + { 'name': package_file.package.name, 'version': package_file.package.version, 'apiVersion': 'v2' }.tap do |defaults| + defaults['description'] = description if description + end + end end end diff --git a/spec/factories/packages/package_file.rb b/spec/factories/packages/package_file.rb index ac121da432c..d9afbac1048 100644 --- a/spec/factories/packages/package_file.rb +++ b/spec/factories/packages/package_file.rb @@ -212,11 +212,12 @@ FactoryBot.define do package_name { package&.name || 'foo' } sequence(:package_version) { |n| package&.version || "v#{n}" } channel { 'stable' } + description { nil } end after :create do |package_file, evaluator| unless evaluator.without_loaded_metadatum - create :helm_file_metadatum, package_file: package_file, channel: evaluator.channel + create :helm_file_metadatum, package_file: package_file, channel: evaluator.channel, description: evaluator.description end end end diff --git a/spec/factories/plan_limits.rb b/spec/factories/plan_limits.rb index ae892307193..b5921c1b311 100644 --- a/spec/factories/plan_limits.rb +++ b/spec/factories/plan_limits.rb @@ -4,6 +4,8 @@ FactoryBot.define do factory :plan_limits do plan + dast_profile_schedules { 50 } + trait :default_plan do plan factory: :default_plan end diff --git a/spec/factories/project_topics.rb b/spec/factories/project_topics.rb new file mode 100644 index 00000000000..60f5357d129 --- /dev/null +++ b/spec/factories/project_topics.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :project_topic, class: 'Projects::ProjectTopic' do + association :project, factory: :project + association :topic, factory: :topic + end +end diff --git a/spec/factories/topics.rb b/spec/factories/topics.rb new file mode 100644 index 00000000000..e77441d9eae --- /dev/null +++ b/spec/factories/topics.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :topic, class: 'Projects::Topic' do + name { generate(:name) } + end +end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 476c57f2d80..04bacbe14e7 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -11,10 +11,6 @@ FactoryBot.define do confirmation_token { nil } can_create_group { true } - after(:stub) do |user| - user.notification_email = user.email - end - trait :admin do admin { true } end diff --git a/spec/factories/users/group_user_callouts.rb b/spec/factories/users/group_user_callouts.rb new file mode 100644 index 00000000000..de8a6d3ee77 --- /dev/null +++ b/spec/factories/users/group_user_callouts.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :group_callout, class: 'Users::GroupCallout' do + feature_name { :invite_members_banner } + + user + group + end +end diff --git a/spec/factories/work_item/work_item_types.rb b/spec/factories/work_item/work_item_types.rb index 07d6d685c57..1c586aab59b 100644 --- a/spec/factories/work_item/work_item_types.rb +++ b/spec/factories/work_item/work_item_types.rb @@ -8,6 +8,17 @@ FactoryBot.define do base_type { WorkItem::Type.base_types[:issue] } icon_name { 'issue-type-issue' } + initialize_with do + type_base_attributes = attributes.with_indifferent_access.slice(:base_type, :namespace, :namespace_id) + + # Expect base_types to exist on the DB + if type_base_attributes.slice(:namespace, :namespace_id).compact.empty? + WorkItem::Type.find_or_initialize_by(type_base_attributes).tap { |type| type.assign_attributes(attributes) } + else + WorkItem::Type.new(attributes) + end + end + trait :default do namespace { nil } end -- cgit v1.2.1