diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/factories | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/factories')
-rw-r--r-- | spec/factories/alerts_service_data.rb | 8 | ||||
-rw-r--r-- | spec/factories/boards.rb | 4 | ||||
-rw-r--r-- | spec/factories/ci/builds.rb | 8 | ||||
-rw-r--r-- | spec/factories/ci_platform_metrics.rb | 2 | ||||
-rw-r--r-- | spec/factories/namespace_onboarding_actions.rb | 8 | ||||
-rw-r--r-- | spec/factories/namespace_package_settings.rb | 14 | ||||
-rw-r--r-- | spec/factories/onboarding_progresses.rb | 7 | ||||
-rw-r--r-- | spec/factories/packages.rb | 22 | ||||
-rw-r--r-- | spec/factories/packages/debian/distribution.rb | 25 | ||||
-rw-r--r-- | spec/factories/packages/debian/file_metadatum.rb | 60 | ||||
-rw-r--r-- | spec/factories/packages/debian/group_architecture.rb | 9 | ||||
-rw-r--r-- | spec/factories/packages/debian/project_architecture.rb | 9 | ||||
-rw-r--r-- | spec/factories/packages/package_file.rb | 91 | ||||
-rw-r--r-- | spec/factories/project_group_links.rb | 2 | ||||
-rw-r--r-- | spec/factories/project_members.rb | 4 | ||||
-rw-r--r-- | spec/factories/projects.rb | 4 | ||||
-rw-r--r-- | spec/factories/services.rb | 18 | ||||
-rw-r--r-- | spec/factories/usage_data.rb | 4 |
18 files changed, 260 insertions, 39 deletions
diff --git a/spec/factories/alerts_service_data.rb b/spec/factories/alerts_service_data.rb deleted file mode 100644 index 2dd1d0a714e..00000000000 --- a/spec/factories/alerts_service_data.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -FactoryBot.define do - factory :alerts_service_data do - service { association(:alerts_service) } - token { SecureRandom.hex } - end -end diff --git a/spec/factories/boards.rb b/spec/factories/boards.rb index cef7ec37f07..9ea8f3ad06f 100644 --- a/spec/factories/boards.rb +++ b/spec/factories/boards.rb @@ -31,4 +31,8 @@ FactoryBot.define do board.lists.create!(list_type: :closed) end end + + factory :group_board, parent: :board do + group + end end diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index c3d6e9d7569..24abad66530 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -486,6 +486,14 @@ FactoryBot.define do end end + trait :non_public_artifacts do + options do + { + artifacts: { public: false } + } + end + end + trait :non_playable do status { 'created' } self.when { 'manual' } diff --git a/spec/factories/ci_platform_metrics.rb b/spec/factories/ci_platform_metrics.rb index 478f9715021..6a517376d65 100644 --- a/spec/factories/ci_platform_metrics.rb +++ b/spec/factories/ci_platform_metrics.rb @@ -4,6 +4,6 @@ FactoryBot.define do factory :ci_platform_metric do recorded_at { Time.zone.now } platform_target { generate(:title) } - count { SecureRandom.random_number(100) } + count { SecureRandom.random_number(100) + 1 } end end diff --git a/spec/factories/namespace_onboarding_actions.rb b/spec/factories/namespace_onboarding_actions.rb deleted file mode 100644 index aca62013b57..00000000000 --- a/spec/factories/namespace_onboarding_actions.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -FactoryBot.define do - factory :namespace_onboarding_action do - namespace - action { :subscription_created } - end -end diff --git a/spec/factories/namespace_package_settings.rb b/spec/factories/namespace_package_settings.rb new file mode 100644 index 00000000000..875933ce84f --- /dev/null +++ b/spec/factories/namespace_package_settings.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :namespace_package_setting, class: 'Namespace::PackageSetting' do + namespace + + maven_duplicates_allowed { true } + maven_duplicate_exception_regex { 'SNAPSHOT' } + + trait :group do + namespace { association(:group) } + end + end +end diff --git a/spec/factories/onboarding_progresses.rb b/spec/factories/onboarding_progresses.rb new file mode 100644 index 00000000000..e39bad91b19 --- /dev/null +++ b/spec/factories/onboarding_progresses.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :onboarding_progress do + namespace + end +end diff --git a/spec/factories/packages.rb b/spec/factories/packages.rb index 5543be4aa82..31f1aabe5dd 100644 --- a/spec/factories/packages.rb +++ b/spec/factories/packages.rb @@ -26,9 +26,31 @@ FactoryBot.define do sequence(:version) { |n| "1.0-#{n}" } package_type { :debian } + transient do + without_package_files { false } + file_metadatum_trait { :keep } + end + + after :create do |package, evaluator| + unless evaluator.without_package_files + create :debian_package_file, :source, evaluator.file_metadatum_trait, package: package + create :debian_package_file, :dsc, evaluator.file_metadatum_trait, package: package + create :debian_package_file, :deb, evaluator.file_metadatum_trait, package: package + create :debian_package_file, :deb2, evaluator.file_metadatum_trait, package: package + create :debian_package_file, :udeb, evaluator.file_metadatum_trait, package: package + create :debian_package_file, :buildinfo, evaluator.file_metadatum_trait, package: package + create :debian_package_file, :changes, evaluator.file_metadatum_trait, package: package + end + end + factory :debian_incoming do name { 'incoming' } version { nil } + + transient do + without_package_files { false } + file_metadatum_trait { :unknown } + end end end diff --git a/spec/factories/packages/debian/distribution.rb b/spec/factories/packages/debian/distribution.rb new file mode 100644 index 00000000000..2015f2923b8 --- /dev/null +++ b/spec/factories/packages/debian/distribution.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :debian_project_distribution, class: 'Packages::Debian::ProjectDistribution' do + container { association(:project) } + + sequence(:codename) { |n| "project-dist-#{n}" } + + factory :debian_group_distribution, class: 'Packages::Debian::GroupDistribution' do + container { association(:group) } + + sequence(:codename) { |n| "group-dist-#{n}" } + end + + trait(:with_file) do + after(:build) do |distribution, evaluator| + distribution.file = fixture_file_upload('spec/fixtures/packages/debian/README.md') + end + end + + trait(:object_storage) do + file_store { Packages::PackageFileUploader::Store::REMOTE } + end + end +end diff --git a/spec/factories/packages/debian/file_metadatum.rb b/spec/factories/packages/debian/file_metadatum.rb new file mode 100644 index 00000000000..088d0140afe --- /dev/null +++ b/spec/factories/packages/debian/file_metadatum.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :debian_file_metadatum, class: 'Packages::Debian::FileMetadatum' do + package_file { association(:debian_package_file, without_loaded_metadatum: true) } + file_type { 'deb' } + component { 'main' } + architecture { 'amd64' } + fields { { 'a': 'b' } } + + trait(:unknown) do + file_type { 'unknown' } + component { nil } + architecture { nil } + fields { nil } + end + + trait(:source) do + file_type { 'source' } + component { 'main' } + architecture { nil } + fields { nil } + end + + trait(:dsc) do + file_type { 'dsc' } + component { 'main' } + architecture { nil } + fields { { 'a': 'b' } } + end + + trait(:deb) do + file_type { 'deb' } + component { 'main' } + architecture { 'amd64' } + fields { { 'a': 'b' } } + end + + trait(:udeb) do + file_type { 'udeb' } + component { 'main' } + architecture { 'amd64' } + fields { { 'a': 'b' } } + end + + trait(:buildinfo) do + file_type { 'buildinfo' } + component { 'main' } + architecture { nil } + fields { { 'Architecture': 'amd64 source' } } + end + + trait(:changes) do + file_type { 'changes' } + component { nil } + architecture { nil } + fields { { 'Architecture': 'source amd64' } } + end + end +end diff --git a/spec/factories/packages/debian/group_architecture.rb b/spec/factories/packages/debian/group_architecture.rb new file mode 100644 index 00000000000..2582faae4ed --- /dev/null +++ b/spec/factories/packages/debian/group_architecture.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :debian_group_architecture, class: 'Packages::Debian::GroupArchitecture' do + distribution { association(:debian_group_distribution) } + + sequence(:name) { |n| "group-arch-#{n}" } + end +end diff --git a/spec/factories/packages/debian/project_architecture.rb b/spec/factories/packages/debian/project_architecture.rb new file mode 100644 index 00000000000..d6985da4128 --- /dev/null +++ b/spec/factories/packages/debian/project_architecture.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :debian_project_architecture, class: 'Packages::Debian::ProjectArchitecture' do + distribution { association(:debian_project_distribution) } + + sequence(:name) { |n| "project-arch-#{n}" } + end +end diff --git a/spec/factories/packages/package_file.rb b/spec/factories/packages/package_file.rb index bee1b2076df..c328c01ec95 100644 --- a/spec/factories/packages/package_file.rb +++ b/spec/factories/packages/package_file.rb @@ -92,6 +92,97 @@ FactoryBot.define do end end + factory :debian_package_file do + package { association(:debian_package, without_package_files: true) } + file_name { 'libsample0_1.2.3~alpha2_amd64.deb' } + file_fixture { "spec/fixtures/packages/debian/#{file_name}" } + file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } + file_md5 { '12345abcde' } + size { 400.kilobytes } + + transient do + without_loaded_metadatum { false } + file_metadatum_trait { :deb } + end + + after :create do |package_file, evaluator| + unless evaluator.without_loaded_metadatum + create :debian_file_metadatum, evaluator.file_metadatum_trait, package_file: package_file + end + end + + trait(:unknown) do + package { association(:debian_incoming, without_package_files: true) } + + transient do + file_metadatum_trait { :unknown } + end + end + + trait(:invalid) do + file_name { 'README.md' } + end + + trait(:source) do + file_name { 'sample_1.2.3~alpha2.tar.xz' } + + transient do + file_metadatum_trait { :source } + end + end + + trait(:dsc) do + file_name { 'sample_1.2.3~alpha2.dsc' } + + transient do + file_metadatum_trait { :dsc } + end + end + + trait(:deb) do + file_name { 'libsample0_1.2.3~alpha2_amd64.deb' } + + transient do + file_metadatum_trait { :deb } + end + end + + trait(:deb2) do + file_name { 'sample-dev_1.2.3~binary_amd64.deb' } + + transient do + file_metadatum_trait { :deb } + end + end + + trait(:udeb) do + file_name { 'sample-udeb_1.2.3~alpha2_amd64.udeb' } + + transient do + file_metadatum_trait { :udeb } + end + end + + trait(:buildinfo) do + file_name { 'sample_1.2.3~alpha2_amd64.buildinfo' } + + transient do + file_metadatum_trait { :buildinfo } + end + end + + trait(:changes) do + file_name { 'sample_1.2.3~alpha2_amd64.changes' } + + transient do + file_metadatum_trait { :changes } + end + end + + trait(:keep) do + 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' } diff --git a/spec/factories/project_group_links.rb b/spec/factories/project_group_links.rb index 5e3e83f18c1..b1b0f04d84c 100644 --- a/spec/factories/project_group_links.rb +++ b/spec/factories/project_group_links.rb @@ -3,7 +3,7 @@ FactoryBot.define do factory :project_group_link do project - group + group { association(:group) } expires_at { nil } group_access { Gitlab::Access::DEVELOPER } diff --git a/spec/factories/project_members.rb b/spec/factories/project_members.rb index 0c2ffac4112..3e83ab7118c 100644 --- a/spec/factories/project_members.rb +++ b/spec/factories/project_members.rb @@ -15,7 +15,9 @@ FactoryBot.define do trait(:invited) do user_id { nil } invite_token { 'xxx' } - invite_email { 'email@email.com' } + sequence :invite_email do |n| + "email#{n}@email.com" + end end trait :blocked do diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 29a25e71095..f5e496080c4 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -39,11 +39,13 @@ FactoryBot.define do group_runners_enabled { nil } merge_pipelines_enabled { nil } merge_trains_enabled { nil } + ci_keep_latest_artifact { nil } import_status { nil } import_jid { nil } import_correlation_id { nil } import_last_error { nil } forward_deployment_enabled { nil } + restrict_user_defined_variables { nil } end before(:create) do |project, evaluator| @@ -82,6 +84,8 @@ FactoryBot.define do project.group_runners_enabled = evaluator.group_runners_enabled unless evaluator.group_runners_enabled.nil? project.merge_pipelines_enabled = evaluator.merge_pipelines_enabled unless evaluator.merge_pipelines_enabled.nil? project.merge_trains_enabled = evaluator.merge_trains_enabled unless evaluator.merge_trains_enabled.nil? + project.ci_keep_latest_artifact = evaluator.ci_keep_latest_artifact unless evaluator.ci_keep_latest_artifact.nil? + project.restrict_user_defined_variables = evaluator.restrict_user_defined_variables unless evaluator.restrict_user_defined_variables.nil? if evaluator.import_status import_state = project.import_state || project.build_import_state diff --git a/spec/factories/services.rb b/spec/factories/services.rb index 44b157014a5..18d3b2d99b7 100644 --- a/spec/factories/services.rb +++ b/spec/factories/services.rb @@ -38,24 +38,6 @@ FactoryBot.define do end end - factory :alerts_service do - active - project - type { 'AlertsService' } - - trait :active do - active { true } - end - - trait :inactive do - active { false } - end - - before(:create) do |service| - service.data = build(:alerts_service_data, service: service) - end - end - factory :drone_ci_service do project active { true } diff --git a/spec/factories/usage_data.rb b/spec/factories/usage_data.rb index f933461a07a..0ed4176109a 100644 --- a/spec/factories/usage_data.rb +++ b/spec/factories/usage_data.rb @@ -32,8 +32,8 @@ 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(:alerts_service, project: projects[0]) - create(:alerts_service, :inactive, project: projects[1]) + 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]) |