diff options
Diffstat (limited to 'spec/factories')
-rw-r--r-- | spec/factories/alert_management/alerts.rb | 14 | ||||
-rw-r--r-- | spec/factories/ci/pipelines.rb | 4 | ||||
-rw-r--r-- | spec/factories/ci/secure_files.rb | 2 | ||||
-rw-r--r-- | spec/factories/clusters/agent_tokens.rb | 1 | ||||
-rw-r--r-- | spec/factories/deploy_tokens.rb | 1 | ||||
-rw-r--r-- | spec/factories/incident_management/timeline_events.rb | 14 | ||||
-rw-r--r-- | spec/factories/keys.rb | 10 | ||||
-rw-r--r-- | spec/factories/namespace_ci_cd_settings.rb | 7 | ||||
-rw-r--r-- | spec/factories/packages/cleanup/policies.rb | 16 | ||||
-rw-r--r-- | spec/factories/projects.rb | 6 | ||||
-rw-r--r-- | spec/factories/topics.rb | 1 | ||||
-rw-r--r-- | spec/factories/users/in_product_marketing_email.rb | 6 |
12 files changed, 66 insertions, 16 deletions
diff --git a/spec/factories/alert_management/alerts.rb b/spec/factories/alert_management/alerts.rb index 589a62a68bb..7e9e58edc1e 100644 --- a/spec/factories/alert_management/alerts.rb +++ b/spec/factories/alert_management/alerts.rb @@ -113,20 +113,6 @@ 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_incident with_assignee diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb index 122af139985..d6b1da1d5c2 100644 --- a/spec/factories/ci/pipelines.rb +++ b/spec/factories/ci/pipelines.rb @@ -79,6 +79,10 @@ FactoryBot.define do status { :running } end + trait :canceled do + status { :canceled } + end + trait :failed do status { :failed } end diff --git a/spec/factories/ci/secure_files.rb b/spec/factories/ci/secure_files.rb index 9198ea61d14..9afec5db858 100644 --- a/spec/factories/ci/secure_files.rb +++ b/spec/factories/ci/secure_files.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :ci_secure_file, class: 'Ci::SecureFile' do - name { 'filename' } + sequence(:name) { |n| "file#{n}" } file { fixture_file_upload('spec/fixtures/ci_secure_files/upload-keystore.jks', 'application/octet-stream') } checksum { 'foo1234' } project diff --git a/spec/factories/clusters/agent_tokens.rb b/spec/factories/clusters/agent_tokens.rb index 03f765123db..3ca6c95d0df 100644 --- a/spec/factories/clusters/agent_tokens.rb +++ b/spec/factories/clusters/agent_tokens.rb @@ -3,6 +3,7 @@ FactoryBot.define do factory :cluster_agent_token, class: 'Clusters::AgentToken' do association :agent, factory: :cluster_agent + association :created_by_user, factory: :user token_encrypted { Gitlab::CryptoHelper.aes256_gcm_encrypt(SecureRandom.hex(50)) } diff --git a/spec/factories/deploy_tokens.rb b/spec/factories/deploy_tokens.rb index b2c478fd3fe..a2116b738fd 100644 --- a/spec/factories/deploy_tokens.rb +++ b/spec/factories/deploy_tokens.rb @@ -2,7 +2,6 @@ FactoryBot.define do factory :deploy_token do - token { nil } token_encrypted { Gitlab::CryptoHelper.aes256_gcm_encrypt(SecureRandom.hex(50)) } sequence(:name) { |n| "PDT #{n}" } read_repository { true } diff --git a/spec/factories/incident_management/timeline_events.rb b/spec/factories/incident_management/timeline_events.rb new file mode 100644 index 00000000000..e2e216d24b8 --- /dev/null +++ b/spec/factories/incident_management/timeline_events.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :incident_management_timeline_event, class: 'IncidentManagement::TimelineEvent' do + association :project + association :author, factory: :user + association :incident + association :promoted_from_note, factory: :note + occurred_at { Time.current } + note { 'timeline created' } + note_html { '<strong>timeline created</strong>' } + action { 'comment' } + end +end diff --git a/spec/factories/keys.rb b/spec/factories/keys.rb index 6b800e3d790..a7478ce2657 100644 --- a/spec/factories/keys.rb +++ b/spec/factories/keys.rb @@ -5,6 +5,16 @@ FactoryBot.define do title key { SSHData::PrivateKey::RSA.generate(1024, unsafe_allow_small_key: true).public_key.openssh(comment: 'dummy@gitlab.com') } + trait :expired do + to_create { |key| key.save!(validate: false) } + expires_at { 2.days.ago } + end + + trait :expired_today do + to_create { |key| key.save!(validate: false) } + expires_at { Date.today.beginning_of_day + 3.hours } + end + factory :key_without_comment do key { SSHData::PrivateKey::RSA.generate(1024, unsafe_allow_small_key: true).public_key.openssh } end diff --git a/spec/factories/namespace_ci_cd_settings.rb b/spec/factories/namespace_ci_cd_settings.rb new file mode 100644 index 00000000000..0e58a19ee8d --- /dev/null +++ b/spec/factories/namespace_ci_cd_settings.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :namespace_ci_cd_settings, class: 'NamespaceCiCdSetting' do + namespace + end +end diff --git a/spec/factories/packages/cleanup/policies.rb b/spec/factories/packages/cleanup/policies.rb new file mode 100644 index 00000000000..80baa2f78bd --- /dev/null +++ b/spec/factories/packages/cleanup/policies.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :packages_cleanup_policy, class: 'Packages::Cleanup::Policy' do + project + + keep_n_duplicated_package_files { '10' } + + trait :runnable do + after(:create) do |policy| + # next_run_at will be set before_save to Time.now + cadence, so this ensures the policy is active + policy.update_column(:next_run_at, Time.zone.now - 1.day) + end + end + end +end diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index b3395758729..c3c02782578 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -183,6 +183,10 @@ FactoryBot.define do request_access_enabled { false } end + trait :with_namespace_settings do + namespace factory: [:namespace, :with_namespace_settings] + end + trait :with_avatar do avatar { fixture_file_upload('spec/fixtures/dk.png') } end @@ -304,6 +308,8 @@ FactoryBot.define do trait :wiki_repo do after(:create) do |project| + stub_feature_flags(main_branch_over_master: false) + raise 'Failed to create wiki repository!' unless project.create_wiki end end diff --git a/spec/factories/topics.rb b/spec/factories/topics.rb index e77441d9eae..a6e614e0c66 100644 --- a/spec/factories/topics.rb +++ b/spec/factories/topics.rb @@ -3,5 +3,6 @@ FactoryBot.define do factory :topic, class: 'Projects::Topic' do name { generate(:name) } + title { generate(:title) } end end diff --git a/spec/factories/users/in_product_marketing_email.rb b/spec/factories/users/in_product_marketing_email.rb index c86c469ff31..42309319bf3 100644 --- a/spec/factories/users/in_product_marketing_email.rb +++ b/spec/factories/users/in_product_marketing_email.rb @@ -6,5 +6,11 @@ FactoryBot.define do track { 'create' } series { 0 } + + trait :campaign do + track { nil } + series { nil } + campaign { Users::InProductMarketingEmail::BUILD_IOS_APP_GUIDE } + end end end |