Commit d1028335 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'brodock/update-factorybot' into 'master'

Upgrade factory_bot to latest 5.1.0

See merge request gitlab-org/gitlab!17941
parents 67beaa8c c996b0d7
......@@ -355,7 +355,7 @@ group :development, :test do
gem 'fuubar', '~> 2.2.0'
gem 'database_cleaner', '~> 1.7.0'
gem 'factory_bot_rails', '~> 4.8.2'
gem 'factory_bot_rails', '~> 5.1.0'
gem 'rspec-rails', '~> 3.8.0'
gem 'rspec-retry', '~> 0.6.1'
gem 'rspec_profiling', '~> 0.0.5'
......
......@@ -254,7 +254,7 @@ GEM
mail (~> 2.7)
encryptor (3.0.0)
equalizer (0.0.11)
erubi (1.8.0)
erubi (1.9.0)
escape_utils (1.2.1)
et-orbi (1.2.1)
tzinfo
......@@ -264,11 +264,11 @@ GEM
expression_parser (0.9.0)
extended-markdown-filter (0.6.0)
html-pipeline (~> 2.0)
factory_bot (4.8.2)
activesupport (>= 3.0.0)
factory_bot_rails (4.8.2)
factory_bot (~> 4.8.2)
railties (>= 3.0.0)
factory_bot (5.1.0)
activesupport (>= 4.2.0)
factory_bot_rails (5.1.0)
factory_bot (~> 5.1.0)
railties (>= 4.2.0)
faraday (0.12.2)
multipart-post (>= 1.2, < 3)
faraday-http-cache (2.0.0)
......@@ -565,7 +565,7 @@ GEM
activesupport (>= 4)
railties (>= 4)
request_store (~> 1.0)
loofah (2.2.3)
loofah (2.3.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
......@@ -783,7 +783,7 @@ GEM
thor (>= 0.19.0, < 2.0)
rainbow (3.0.0)
raindrops (0.19.0)
rake (12.3.2)
rake (12.3.3)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
......@@ -1144,7 +1144,7 @@ DEPENDENCIES
email_reply_trimmer (~> 0.1)
email_spec (~> 2.2.0)
escape_utils (~> 1.1)
factory_bot_rails (~> 4.8.2)
factory_bot_rails (~> 5.1.0)
faraday (~> 0.12)
faraday_middleware-aws-signers-v4
fast_blank
......
......@@ -6,7 +6,7 @@ FactoryBot.define do
payload { {} }
transient do
metric_id nil
metric_id { nil }
after(:build) do |alert, evaluator|
unless alert.payload.key?('startsAt')
......
......@@ -8,15 +8,15 @@ FactoryBot.define do
factory :code_owner_rule, parent: :approval_merge_request_rule do
merge_request
rule_type :code_owner
code_owner true # deprecated, replaced with `rule_type: :code_owner`
rule_type { :code_owner }
code_owner { true } # deprecated, replaced with `rule_type: :code_owner`
sequence(:name) { |n| "*-#{n}.js" }
end
factory :report_approver_rule, parent: :approval_merge_request_rule do
merge_request
rule_type :report_approver
report_type :security
rule_type { :report_approver }
report_type { :security }
sequence(:name) { |n| "*-#{n}.js" }
trait :requires_approval do
......@@ -24,23 +24,23 @@ FactoryBot.define do
end
trait :license_management do
name ApprovalRuleLike::DEFAULT_NAME_FOR_LICENSE_REPORT
report_type :license_management
name { ApprovalRuleLike::DEFAULT_NAME_FOR_LICENSE_REPORT }
report_type { :license_management }
end
end
factory :approval_project_rule do
project
sequence(:name) { |n| "#{ApprovalRuleLike::DEFAULT_NAME}-#{n}" }
rule_type :regular
rule_type { :regular }
trait :requires_approval do
approvals_required { rand(1..ApprovalProjectRule::APPROVALS_REQUIRED_MAX) }
end
trait :security_report do
rule_type :report_approver
name ApprovalRuleLike::DEFAULT_NAME_FOR_SECURITY_REPORT
rule_type { :report_approver }
name { ApprovalRuleLike::DEFAULT_NAME_FOR_SECURITY_REPORT }
end
trait :security do
......@@ -48,8 +48,8 @@ FactoryBot.define do
end
trait :license_management do
name ApprovalRuleLike::DEFAULT_NAME_FOR_LICENSE_REPORT
rule_type :report_approver
name { ApprovalRuleLike::DEFAULT_NAME_FOR_LICENSE_REPORT }
rule_type { :report_approver }
end
end
end
......@@ -4,7 +4,7 @@ FactoryBot.define do
factory :audit_event, class: 'SecurityEvent', aliases: [:user_audit_event] do
user
entity_type 'User'
entity_type { 'User' }
entity_id { user.id }
details do
{
......@@ -21,7 +21,7 @@ FactoryBot.define do
end
trait :project_event do
entity_type 'Project'
entity_type { 'Project' }
entity_id { create(:project).id }
details do
{
......@@ -38,7 +38,7 @@ FactoryBot.define do
end
trait :group_event do
entity_type 'Group'
entity_type { 'Group' }
entity_id { create(:group).id }
details do
{
......
......@@ -10,7 +10,7 @@ FactoryBot.define do
trait "legacy_#{report_type}".to_sym do
success
artifacts
name report_type
name { report_type }
options do
{
......@@ -29,7 +29,7 @@ FactoryBot.define do
end
trait :dependency_list do
name :dependency_scanning
name { :dependency_scanning }
after(:build) do |build|
build.job_artifacts << build(:ee_ci_job_artifact, :dependency_list, job: build)
......
......@@ -3,8 +3,8 @@
FactoryBot.define do
factory :ee_ci_job_artifact, class: ::Ci::JobArtifact, parent: :ci_job_artifact do
trait :sast do
file_type :sast
file_format :raw
file_type { :sast }
file_format { :raw }
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
......@@ -13,8 +13,8 @@ FactoryBot.define do
end
trait :sast_feature_branch do
file_format :raw
file_type :sast
file_format { :raw }
file_type { :sast }
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
......@@ -23,8 +23,8 @@ FactoryBot.define do
end
trait :sast_deprecated do
file_type :sast
file_format :raw
file_type { :sast }
file_format { :raw }
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
......@@ -33,8 +33,8 @@ FactoryBot.define do
end
trait :sast_with_corrupted_data do
file_type :sast
file_format :raw
file_type { :sast }
file_format { :raw }
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
......@@ -43,8 +43,8 @@ FactoryBot.define do
end
trait :license_management do
file_type :license_management
file_format :raw
file_type { :license_management }
file_format { :raw }
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
......@@ -53,8 +53,8 @@ FactoryBot.define do
end
trait :license_management_feature_branch do
file_type :license_management
file_format :raw
file_type { :license_management }
file_format { :raw }
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
......@@ -63,8 +63,8 @@ FactoryBot.define do
end
trait :corrupted_license_management_report do
file_type :license_management
file_format :raw
file_type { :license_management }
file_format { :raw }
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
......@@ -73,8 +73,8 @@ FactoryBot.define do
end
trait :performance do
file_format :raw
file_type :performance
file_format { :raw }
file_type { :performance }
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
......@@ -83,8 +83,8 @@ FactoryBot.define do
end
trait :license_management do
file_format :raw
file_type :license_management
file_format { :raw }
file_type { :license_management }
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
......@@ -93,8 +93,8 @@ FactoryBot.define do
end
trait :dependency_scanning do
file_format :raw
file_type :dependency_scanning
file_format { :raw }
file_type { :dependency_scanning }
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
......@@ -103,8 +103,8 @@ FactoryBot.define do
end
trait :dependency_scanning_remediation do
file_format :raw
file_type :dependency_scanning
file_format { :raw }
file_type { :dependency_scanning }
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
......@@ -113,8 +113,8 @@ FactoryBot.define do
end
trait :dependency_scanning_deprecated do
file_format :raw
file_type :dependency_scanning
file_format { :raw }
file_type { :dependency_scanning }
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
......@@ -123,8 +123,8 @@ FactoryBot.define do
end
trait :dependency_scanning_feature_branch do
file_format :raw
file_type :dependency_scanning
file_format { :raw }
file_type { :dependency_scanning }
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
......@@ -133,8 +133,8 @@ FactoryBot.define do
end
trait :corrupted_dependency_scanning_report do
file_format :raw
file_type :dependency_scanning
file_format { :raw }
file_type { :dependency_scanning }
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
......@@ -143,8 +143,8 @@ FactoryBot.define do
end
trait :container_scanning do
file_format :raw
file_type :container_scanning
file_format { :raw }
file_type { :container_scanning }
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
......@@ -153,8 +153,8 @@ FactoryBot.define do
end
trait :container_scanning_feature_branch do
file_format :raw
file_type :container_scanning
file_format { :raw }
file_type { :container_scanning }
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
......@@ -163,8 +163,8 @@ FactoryBot.define do
end
trait :corrupted_container_scanning_report do
file_format :raw
file_type :container_scanning
file_format { :raw }
file_type { :container_scanning }
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
......@@ -173,8 +173,8 @@ FactoryBot.define do
end
trait :dast do
file_format :raw
file_type :dast
file_format { :raw }
file_type { :dast }
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
......@@ -183,8 +183,8 @@ FactoryBot.define do
end
trait :metrics do
file_format :gzip
file_type :metrics
file_format { :gzip }
file_type { :metrics }
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
......@@ -193,8 +193,8 @@ FactoryBot.define do
end
trait :metrics_alternate do
file_format :gzip
file_type :metrics
file_format { :gzip }
file_type { :metrics }
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
......@@ -203,8 +203,8 @@ FactoryBot.define do
end
trait :dependency_list do
file_format :raw
file_type :dependency_scanning
file_format { :raw }
file_type { :dependency_scanning }
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
......
......@@ -3,13 +3,13 @@
FactoryBot.define do
factory :ee_ci_pipeline, class: Ci::Pipeline, parent: :ci_pipeline do
trait :webide do
source :webide
config_source :webide_source
source { :webide }
config_source { :webide_source }
end
%i[license_management dependency_list dependency_scanning sast container_scanning].each do |report_type|
trait "with_#{report_type}_report".to_sym do
status :success
status { :success }
after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, report_type, :success, pipeline: pipeline, project: pipeline.project)
......@@ -18,7 +18,7 @@ FactoryBot.define do
end
trait :with_container_scanning_feature_branch do
status :success
status { :success }
after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :container_scanning_feature_branch, pipeline: pipeline, project: pipeline.project)
......@@ -26,7 +26,7 @@ FactoryBot.define do
end
trait :with_corrupted_container_scanning_report do
status :success
status { :success }
after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :corrupted_container_scanning_report, pipeline: pipeline, project: pipeline.project)
......@@ -34,7 +34,7 @@ FactoryBot.define do
end
trait :with_dependency_scanning_feature_branch do
status :success
status { :success }
after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :dependency_scanning_feature_branch, pipeline: pipeline, project: pipeline.project)
......@@ -42,7 +42,7 @@ FactoryBot.define do
end
trait :with_corrupted_dependency_scanning_report do
status :success
status { :success }
after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :corrupted_dependency_scanning_report, pipeline: pipeline, project: pipeline.project)
......@@ -50,7 +50,7 @@ FactoryBot.define do
end
trait :with_sast_feature_branch do
status :success
status { :success }
after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :sast_feature_branch, pipeline: pipeline, project: pipeline.project)
......@@ -58,7 +58,7 @@ FactoryBot.define do
end
trait :with_license_management_feature_branch do
status :success
status { :success }
after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :license_management_feature_branch, pipeline: pipeline, project: pipeline.project)
......@@ -66,7 +66,7 @@ FactoryBot.define do
end
trait :with_corrupted_license_management_report do
status :success
status { :success }
after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :corrupted_license_management_report, pipeline: pipeline, project: pipeline.project)
......@@ -74,7 +74,7 @@ FactoryBot.define do
end
trait :with_metrics_report do
status :success
status { :success }
after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :metrics, pipeline: pipeline, project: pipeline.project)
......@@ -82,7 +82,7 @@ FactoryBot.define do
end
trait :with_metrics_alternate_report do
status :success
status { :success }
after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :metrics_alternate, pipeline: pipeline, project: pipeline.project)
......
......@@ -2,8 +2,8 @@
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'
external_id { 'PREDICTABLE_RANDOM' }
external_type { 'find_sec_bugs_type' }
name { "#{external_type}-#{external_id}" }
skip_create
......
......@@ -2,10 +2,10 @@
FactoryBot.define do
factory :ci_reports_security_locations_container_scanning, class: ::Gitlab::Ci::Reports::Security::Locations::ContainerScanning do
image 'registry.gitlab.com/my/project:latest'
operating_system 'debian:9'
package_name 'glibc'
package_version '1.2.3'
image { 'registry.gitlab.com/my/project:latest' }
operating_system { 'debian:9' }
package_name { 'glibc' }
package_version { '1.2.3' }
skip_create
......
......@@ -2,10 +2,10 @@
FactoryBot.define do
factory :ci_reports_security_locations_dast, class: ::Gitlab::Ci::Reports::Security::Locations::Dast do
hostname 'my-app.com'
method_name 'GET'
param 'X-Content-Type-Options'
path '/some/path'
hostname { 'my-app.com' }
method_name { 'GET' }
param { 'X-Content-Type-Options' }
path { '/some/path' }
skip_create
......
......@@ -2,9 +2,9 @@
FactoryBot.define do
factory :ci_reports_security_locations_dependency_scanning, class: ::Gitlab::Ci::Reports::Security::Locations::DependencyScanning do
file_path 'app/pom.xml'
package_name 'io.netty/netty'
package_version '1.2.3'
file_path { 'app/pom.xml' }
package_name { 'io.netty/netty' }
package_version { '1.2.3' }
skip_create
......
......@@ -2,11 +2,11 @@
FactoryBot.define do
factory :ci_reports_security_locations_sast, class: ::Gitlab::Ci::Reports::Security::Locations::Sast do
file_path 'maven/src/main/java/com/gitlab/security_products/tests/App.java'
start_line 29
end_line 31
class_name 'com.gitlab.security_products.tests.App'
method_name 'insecureCypher'
file_path { 'maven/src/main/java/com/gitlab/security_products/tests/App.java' }
start_line { 29 }
end_line { 31 }
class_name { 'com.gitlab.security_products.tests.App' }
method_name { 'insecureCypher' }
skip_create
......
......@@ -3,12 +3,12 @@
FactoryBot.define do
factory :ci_reports_security_occurrence, class: ::Gitlab::Ci::Reports::Security::Occurrence do
compare_key { "#{identifiers.first.external_type}:#{identifiers.first.external_id}:#{location.fingerprint}" }
confidence :medium
confidence { :medium }
identifiers { Array.new(1) { FactoryBot.build(:ci_reports_security_identifier) } }
location factory: :ci_reports_security_locations_sast
metadata_version 'sast:1.0'
name 'Cipher with no integrity'
report_type :sast
metadata_version { 'sast:1.0' }
name { 'Cipher with no integrity' }
report_type { :sast }
raw_metadata do
{
description: "The cipher does not provide data integrity update 1",
......@@ -29,7 +29,7 @@ FactoryBot.define do
}.to_json
end
scanner factory: :ci_reports_security_scanner
severity :high
severity { :high }
sequence(:uuid) { generate(:vulnerability_occurrence_uuid) }
skip_create
......
......@@ -2,13 +2,13 @@
FactoryBot.define do
factory :ci_reports_security_report, class: ::Gitlab::Ci::Reports::Security::Report do
type :sast
type { :sast }
commit_sha { Digest::SHA1.hexdigest(SecureRandom.hex) }
transient do
occurrences []
scanners []
identifiers []
occurrences { [] }
scanners { [] }
identifiers { [] }
end
after :build do |report, evaluator|
......
......@@ -2,8 +2,8 @@
FactoryBot.define do
factory :ci_reports_security_scanner, class: ::Gitlab::Ci::Reports::Security::Scanner do
external_id 'find_sec_bugs'
name 'Find Security Bugs'
external_id { 'find_sec_bugs' }
name { 'Find Security Bugs' }
skip_create
......
......@@ -2,9 +2,9 @@
FactoryBot.define do
factory :dependency, class: Hash do
name 'nokogiri'
packager 'Ruby (Bundler)'
version '1.8.0'
name { 'nokogiri' }
packager { 'Ruby (Bundler)' }
version { '1.8.0' }
licenses { [] }
location do
{
......
......@@ -3,6 +3,6 @@ FactoryBot.define do
factory :dependency_proxy_blob, class: DependencyProxy::Blob do
group
file { fixture_file_upload('ee/spec/fixtures/dependency_proxy/a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4.gz') }
file_name 'a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4.gz'
file_name { 'a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4.gz' }
end
end
......@@ -38,7 +38,7 @@ FactoryBot.define do
with_file
transient do
file Gitlab::Git::LfsPointerFile.new('').pointer
file { Gitlab::Git::LfsPointerFile.new('').pointer }
end
end
......@@ -46,8 +46,8 @@ FactoryBot.define do
# want to pay for gitlay calls.
trait :with_versions do
transient do
deleted false
versions_count 1
deleted { false }
versions_count { 1 }
sequence(:file) { |n| "some-file-content-#{n}" }
end
......@@ -67,9 +67,9 @@ FactoryBot.define do
# with correctly made commits in the repository and files that can be retrieved.
trait :with_file do
transient do
deleted false
versions_count 1
file File.join(Rails.root, 'spec/fixtures/dk.png')
deleted { false }
versions_count { 1 }
file { File.join(Rails.root, 'spec/fixtures/dk.png') }
end
after :create do |design, evaluator|
......
......@@ -6,15 +6,15 @@ FactoryBot.define do
issue { designs.first&.issue || create(:issue) }
transient do
designs_count 1
created_designs []
modified_designs []
deleted_designs []
designs_count { 1 }
created_designs { [] }
modified_designs { [] }
deleted_designs { [] }
end
# Warning: this will intentionally result in an invalid version!
trait :empty do
designs_count 0
designs_count { 0 }
end
after(:build) do |version, evaluator|
......@@ -62,7 +62,7 @@ FactoryBot.define do
trait :committed do
transient do
author { create(:user) }
file File.join(Rails.root, 'spec/fixtures/dk.png')
file { File.join(Rails.root, 'spec/fixtures/dk.png') }
end
after :create do |version, evaluator|
......
......@@ -4,9 +4,9 @@ FactoryBot.define do
factory :doorkeeper_access_grant, class: Doorkeeper::AccessGrant do
sequence(:resource_owner_id) { |n| n }
association :application, factory: :doorkeeper_application
redirect_uri 'https://app.com/callback'
expires_in 100
scopes 'public write'
redirect_uri { 'https://app.com/callback' }
expires_in { 100 }
scopes { 'public write' }
end
factory :doorkeeper_access_token, class: Doorkeeper::AccessToken do
......@@ -15,12 +15,12 @@ FactoryBot.define do
expires_in { 2.hours }
factory :clientless_access_token do
application nil
application { nil }
end
end
factory :doorkeeper_application, class: Doorkeeper::Application do
sequence(:name) { |n| "Application #{n}" }
redirect_uri 'https://app.com/callback'
redirect_uri { 'https://app.com/callback' }
end
end
......@@ -7,7 +7,7 @@ FactoryBot.define do
factory :draft_note_on_text_diff do
transient do
line_number 14
line_number { 14 }
diff_refs { merge_request.try(:diff_refs) }
end
......
......@@ -9,24 +9,24 @@ FactoryBot.define do
trait :use_fixed_dates do
start_date { Date.new(2010, 1, 1) }
start_date_fixed { Date.new(2010, 1, 1) }
start_date_is_fixed true
start_date_is_fixed { true }
end_date { Date.new(2010, 1, 3) }
due_date_fixed { Date.new(2010, 1, 3) }
due_date_is_fixed true
due_date_is_fixed { true }
end
trait :opened do
state :opened
state { :opened }
end
trait :closed do
state :closed
state { :closed }
closed_at { Time.now }
end
factory :labeled_epic do
transient do
labels []
labels { [] }
end
after(:create) do |epic, evaluator|
......
......@@ -3,30 +3,30 @@
FactoryBot.define do
factory :container_repository_registry, class: Geo::ContainerRepositoryRegistry do
container_repository
last_sync_failure nil
last_synced_at nil
state :pending
last_sync_failure { nil }
last_synced_at { nil }
state { :pending }
trait :started do
state :started
state { :started }
end
trait :synced do
state :synced
state { :synced }
last_synced_at { 5.days.ago }
end
trait :sync_failed do
state :failed
state { :failed }
last_synced_at { 1.day.ago }
retry_count 2
last_sync_failure 'Random error'
retry_count { 2 }
last_sync_failure { 'Random error' }
end
trait :sync_started do
state :started
state { :started }
last_synced_at { 1.day.ago }
retry_count 0
retry_count { 0 }
end
end
end
......@@ -63,9 +63,9 @@ FactoryBot.define do
factory :geo_repository_updated_event, class: Geo::RepositoryUpdatedEvent do
project
source 0
branches_affected 0
tags_affected 0
source { 0 }
branches_affected { 0 }
tags_affected { 0 }
end
factory :geo_repository_deleted_event, class: Geo::RepositoryDeletedEvent do
......
......@@ -3,23 +3,23 @@
FactoryBot.define do
factory :geo_file_registry, class: Geo::FileRegistry do
sequence(:file_id)
file_type :file
success true
file_type { :file }
success { true }
trait(:attachment) { file_type :attachment }
trait(:avatar) { file_type :avatar }
trait(:file) { file_type :file }
trait(:lfs) { file_type :lfs }
trait(:namespace_file) { file_type :namespace_file }
trait(:personal_file) { file_type :personal_file }
trait(:favicon) { file_type :favicon }
trait(:import_export) { file_type :import_export }
trait(:attachment) { file_type { :attachment } }
trait(:avatar) { file_type { :avatar } }
trait(:file) { file_type { :file } }
trait(:lfs) { file_type { :lfs } }
trait(:namespace_file) { file_type { :namespace_file } }
trait(:personal_file) { file_type { :personal_file } }
trait(:favicon) { file_type { :favicon } }
trait(:import_export) { file_type { :import_export } }
factory :geo_upload_registry, class: Geo::UploadRegistry
trait :failed do
success false
retry_count 1
success { false }
retry_count { 1 }
end
trait :with_file do
......
......@@ -3,7 +3,7 @@
FactoryBot.define do
factory :geo_job_artifact_registry, class: Geo::JobArtifactRegistry do
sequence(:artifact_id)
success true
success { true }
trait :with_artifact do
transient do
......
......@@ -3,26 +3,26 @@
FactoryBot.define do
factory :geo_project_registry, class: Geo::ProjectRegistry do
project
last_repository_synced_at nil
last_repository_successful_sync_at nil
last_wiki_synced_at nil
last_wiki_successful_sync_at nil
resync_repository true
resync_wiki true
last_repository_synced_at { nil }
last_repository_successful_sync_at { nil }
last_wiki_synced_at { nil }
last_wiki_successful_sync_at { nil }
resync_repository { true }
resync_wiki { true }
trait :dirty do
resync_repository true
resync_wiki true
resync_repository { true }
resync_wiki { true }
end
trait :repository_dirty do
resync_repository true
resync_wiki false
resync_repository { true }
resync_wiki { false }
end
trait :wiki_dirty do
resync_repository false
resync_wiki true
resync_repository { false }
resync_wiki { true }
end
trait :synced do
......@@ -30,27 +30,27 @@ FactoryBot.define do
last_repository_successful_sync_at { 5.days.ago }
last_wiki_synced_at { 5.days.ago }
last_wiki_successful_sync_at { 5.days.ago }
resync_repository false
resync_wiki false
resync_repository { false }
resync_wiki { false }
end
trait :sync_failed do
last_repository_synced_at { 5.days.ago }
last_repository_successful_sync_at nil
last_repository_successful_sync_at { nil }
last_wiki_synced_at { 5.days.ago }
last_wiki_successful_sync_at nil
resync_repository true
resync_wiki true
repository_retry_count 1
wiki_retry_count 1
last_wiki_successful_sync_at { nil }
resync_repository { true }
resync_wiki { true }
repository_retry_count { 1 }
wiki_retry_count { 1 }
end
trait :repository_sync_failed do
sync_failed
last_wiki_successful_sync_at { 5.days.ago }
resync_wiki false
wiki_retry_count nil
resync_wiki { false }
wiki_retry_count { nil }
end
trait :existing_repository_sync_failed do
......@@ -61,70 +61,70 @@ FactoryBot.define do
trait :repository_syncing do
repository_sync_failed
repository_retry_count 0
repository_retry_count { 0 }
end
trait :wiki_sync_failed do
sync_failed
last_repository_successful_sync_at { 5.days.ago }
resync_repository false
repository_retry_count nil
resync_repository { false }
repository_retry_count { nil }
end
trait :wiki_syncing do
wiki_sync_failed
wiki_retry_count 0
wiki_retry_count { 0 }
end
trait :repository_verified do
repository_verification_checksum_sha 'f079a831cab27bcda7d81cd9b48296d0c3dd92ee'
last_repository_verification_failure nil
repository_verification_checksum_sha { 'f079a831cab27bcda7d81cd9b48296d0c3dd92ee' }
last_repository_verification_failure { nil }
end
trait :repository_verification_failed do
repository_verification_checksum_sha nil
last_repository_verification_failure 'Repository checksum did not match'
repository_verification_checksum_sha { nil }
last_repository_verification_failure { 'Repository checksum did not match' }
end
trait :repository_checksum_mismatch do
last_repository_verification_failure 'Repository checksum mismatch'
repository_checksum_mismatch true
last_repository_verification_failure { 'Repository checksum mismatch' }
repository_checksum_mismatch { true }
end
trait :repository_verification_outdated do
repository_verification_checksum_sha nil
last_repository_verification_failure nil
repository_verification_checksum_sha { nil }
last_repository_verification_failure { nil }
end
trait :repository_retrying_verification do
repository_verification_retry_count 1
resync_repository true
repository_verification_retry_count { 1 }
resync_repository { true }
end
trait :wiki_verified do
wiki_verification_checksum_sha 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef'
last_wiki_verification_failure nil
wiki_verification_checksum_sha { 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef' }
last_wiki_verification_failure { nil }
end
trait :wiki_verification_failed do
wiki_verification_checksum_sha nil
last_wiki_verification_failure 'Wiki checksum did not match'
wiki_verification_checksum_sha { nil }
last_wiki_verification_failure { 'Wiki checksum did not match' }
end
trait :wiki_checksum_mismatch do
last_wiki_verification_failure 'Wiki checksum mismatch'
wiki_checksum_mismatch true
last_wiki_verification_failure { 'Wiki checksum mismatch' }
wiki_checksum_mismatch { true }
end
trait :wiki_verification_outdated do
wiki_verification_checksum_sha nil
last_wiki_verification_failure nil
wiki_verification_checksum_sha { nil }
last_wiki_verification_failure { nil }
end
trait :wiki_retrying_verification do
wiki_verification_retry_count 1
resync_wiki true
wiki_verification_retry_count { 1 }
resync_wiki { true }
end
end
end
......@@ -6,43 +6,43 @@ FactoryBot.define do
storage_shards { StorageShard.all }
trait :healthy do
status_message nil
attachments_count 329
attachments_failed_count 13
attachments_synced_count 141
attachments_synced_missing_on_primary_count 89
lfs_objects_count 256
lfs_objects_failed_count 12
lfs_objects_synced_count 123
lfs_objects_synced_missing_on_primary_count 90
job_artifacts_count 580
job_artifacts_failed_count 3
job_artifacts_synced_count 577
job_artifacts_synced_missing_on_primary_count 91
container_repositories_count 400
container_repositories_failed_count 3
container_repositories_synced_count 200
projects_count 10
repositories_synced_count 5
repositories_failed_count 0
wikis_synced_count 4
wikis_failed_count 1
repositories_checksummed_count 600
repositories_checksum_failed_count 120
wikis_checksummed_count 585
wikis_checksum_failed_count 55
repositories_verified_count 501
repositories_verification_failed_count 100
repositories_checksum_mismatch_count 15
wikis_verified_count 499
wikis_verification_failed_count 99
wikis_checksum_mismatch_count 10
repositories_retrying_verification_count 25
wikis_retrying_verification_count 3
repositories_checked_failed_count 1
last_event_id 2
status_message { nil }
attachments_count { 329 }
attachments_failed_count { 13 }
attachments_synced_count { 141 }
attachments_synced_missing_on_primary_count { 89 }
lfs_objects_count { 256 }
lfs_objects_failed_count { 12 }
lfs_objects_synced_count { 123 }
lfs_objects_synced_missing_on_primary_count { 90 }
job_artifacts_count { 580 }
job_artifacts_failed_count { 3 }
job_artifacts_synced_count { 577 }
job_artifacts_synced_missing_on_primary_count { 91 }
container_repositories_count { 400 }
container_repositories_failed_count { 3 }
container_repositories_synced_count { 200 }
projects_count { 10 }
repositories_synced_count { 5 }
repositories_failed_count { 0 }
wikis_synced_count { 4 }
wikis_failed_count { 1 }
repositories_checksummed_count { 600 }
repositories_checksum_failed_count { 120 }
wikis_checksummed_count { 585 }
wikis_checksum_failed_count { 55 }
repositories_verified_count { 501 }
repositories_verification_failed_count { 100 }
repositories_checksum_mismatch_count { 15 }
wikis_verified_count { 499 }
wikis_verification_failed_count { 99 }
wikis_checksum_mismatch_count { 10 }
repositories_retrying_verification_count { 25 }
wikis_retrying_verification_count { 3 }
repositories_checked_failed_count { 1 }
last_event_id { 2 }
last_event_timestamp { Time.now.to_i }
cursor_last_event_id 1
cursor_last_event_id { 1 }
cursor_last_event_timestamp { Time.now.to_i }
last_successful_status_check_timestamp { 2.minutes.ago }
version { Gitlab::VERSION }
......@@ -50,7 +50,7 @@ FactoryBot.define do
end
trait :unhealthy do
status_message "Could not connect to Geo node - HTTP Status Code: 401 Unauthorized\nTest"
status_message { "Could not connect to Geo node - HTTP Status Code: 401 Unauthorized\nTest" }
end
end
end
......@@ -10,17 +10,17 @@ FactoryBot.define do
"node_name_#{n}"
end
primary false
sync_object_storage true
primary { false }
sync_object_storage { true }
trait :primary do
primary true
minimum_reverification_interval 7
sync_object_storage false
primary { true }
minimum_reverification_interval { 7 }
sync_object_storage { false }
end
trait :local_storage_only do
sync_object_storage false
sync_object_storage { false }
end
end
end
......@@ -4,13 +4,13 @@ FactoryBot.define do
factory :gitlab_subscription do
namespace
association :hosted_plan, factory: :gold_plan
seats 10
seats { 10 }
start_date { Date.today }
end_date { Date.today.advance(years: 1) }
trial false
trial { false }
trait :free do
hosted_plan_id nil
hosted_plan_id { nil }
end
trait :early_adopter do
......
# frozen_string_literal: true
FactoryBot.define do
factory :group_saml_identity, class: Identity, parent: :identity do
provider 'group_saml'
provider { 'group_saml' }
extern_uid { generate(:username) }
saml_provider
user
......
......@@ -9,9 +9,9 @@ FactoryBot.define do
factory :group_with_ldap, parent: :group do
transient do
cn 'group1'
group_access Gitlab::Access::GUEST
provider 'ldapmain'
cn { 'group1' }
group_access { Gitlab::Access::GUEST }
provider { 'ldapmain' }
end
factory :group_with_ldap_group_link do
......
......@@ -4,7 +4,7 @@ FactoryBot.modify do
factory :import_state do
trait :mirror do
transient do
mirror true
mirror { true }
import_url { generate(:url) }
end
......@@ -32,7 +32,7 @@ FactoryBot.modify do
end
trait :hard_failed do
status :failed
status { :failed }
retry_count { Gitlab::Mirror::MAX_RETRY + 1 }
last_update_at { Time.now - 1.minute }
end
......
......@@ -3,8 +3,8 @@
FactoryBot.define do
factory :project_incident_management_setting, class: IncidentManagement::ProjectIncidentManagementSetting do
project
create_issue false
issue_template_key nil
send_email false
create_issue { false }
issue_template_key { nil }
send_email { false }
end
end
......@@ -2,7 +2,7 @@
FactoryBot.define do
factory :ip_restriction do
range '192.168.0.0/24'
range { '192.168.0.0/24' }
group
end
end
......@@ -3,7 +3,7 @@
FactoryBot.define do
factory :jira_connect_installation do
sequence(:client_key) { |n| "atlassian-client-key-#{n}" }
shared_secret 'jrNarHaRYaumMvfV3UnYpwt8'
base_url 'https://sample.atlassian.net'
shared_secret { 'jrNarHaRYaumMvfV3UnYpwt8' }
base_url { 'https://sample.atlassian.net' }
end
end
......@@ -2,9 +2,9 @@
FactoryBot.define do
factory :ldap_group_link do
cn 'group1'
group_access Gitlab::Access::GUEST
provider 'ldapmain'
cn { 'group1' }
group_access { Gitlab::Access::GUEST }
provider { 'ldapmain' }
group
end
end
......@@ -5,7 +5,7 @@ FactoryBot.define do
skip_create
trait :trial do
block_changes_at nil
block_changes_at { nil }
restrictions do
{ trial: true }
end
......@@ -16,7 +16,7 @@ FactoryBot.define do
end
transient do
plan License::STARTER_PLAN
plan { License::STARTER_PLAN }
end
starts_at { Date.today - 1.month }
......@@ -42,9 +42,9 @@ FactoryBot.define do
factory :license do
transient do
plan nil
expired false
trial false
plan { nil }
expired { false }
trial { false }
end
data do
......
......@@ -2,15 +2,15 @@
FactoryBot.define do
factory :user_list, parent: :list do
list_type :assignee
label nil
list_type { :assignee }
label { nil }
user
end
factory :milestone_list, parent: :list do
list_type :milestone
label nil
user nil
list_type { :milestone }
label { nil }
user { nil }
milestone
end
end
......@@ -13,8 +13,8 @@ FactoryBot.modify do
train_creator { author }
end
auto_merge_enabled true
auto_merge_strategy AutoMergeService::STRATEGY_MERGE_TRAIN
auto_merge_enabled { true }
auto_merge_strategy { AutoMergeService::STRATEGY_MERGE_TRAIN }
merge_user { train_creator }
after :create do |merge_request, evaluator|
......@@ -34,14 +34,14 @@ FactoryBot.modify do
end
trait :add_to_merge_train_when_pipeline_succeeds do
auto_merge_enabled true
auto_merge_strategy AutoMergeService::STRATEGY_ADD_TO_MERGE_TRAIN_WHEN_PIPELINE_SUCCEEDS
auto_merge_enabled { true }
auto_merge_strategy { AutoMergeService::STRATEGY_ADD_TO_MERGE_TRAIN_WHEN_PIPELINE_SUCCEEDS }
merge_user { author }
end
trait :with_productivity_metrics do
transient do
metrics_data {}
metrics_data { {} }
end
after :build do |mr, evaluator|
......@@ -53,8 +53,8 @@ FactoryBot.modify do
end
transient do
approval_groups []
approval_users []
approval_groups { [] }
approval_users { [] }
end
after :create do |merge_request, evaluator|
......
......@@ -2,7 +2,7 @@
FactoryBot.define do
factory :merge_train do
target_branch 'master'
target_branch { 'master' }
target_project factory: :project
merge_request
user
......
......@@ -3,7 +3,7 @@
FactoryBot.modify do
factory :namespace do
transient do
plan nil
plan { nil }
end
before(:create) do |namespace, evaluator|
......@@ -17,17 +17,17 @@ FactoryBot.modify do
end
trait :with_build_minutes_limit do
shared_runners_minutes_limit 500
shared_runners_minutes_limit { 500 }
end
trait :with_not_used_build_minutes_limit do
namespace_statistics factory: :namespace_statistics, shared_runners_seconds: 300.minutes.to_i
shared_runners_minutes_limit 500
shared_runners_minutes_limit { 500 }
end
trait :with_used_build_minutes_limit do
namespace_statistics factory: :namespace_statistics, shared_runners_seconds: 1000.minutes.to_i
shared_runners_minutes_limit 500
shared_runners_minutes_limit { 500 }
end
end
end
......@@ -4,7 +4,7 @@ FactoryBot.modify do
factory :note do
trait :on_epic do
noteable { create(:epic) }
project nil
project { nil }
end
trait :with_review do
......
......@@ -3,8 +3,8 @@
FactoryBot.define do
factory :operations_feature_flag_scope, class: Operations::FeatureFlagScope do
association :feature_flag, factory: :operations_feature_flag
active true
strategies [{ name: "default", parameters: {} }]
active { true }
strategies { [{ name: "default", parameters: {} }] }
sequence(:environment_scope) { |n| "review/patch-#{n}" }
end
end
......@@ -4,6 +4,6 @@ FactoryBot.define do
factory :operations_feature_flag, class: Operations::FeatureFlag do
sequence(:name) { |n| "feature_flag_#{n}" }
project
active true
active { true }
end
end
......@@ -2,9 +2,9 @@
FactoryBot.define do
factory :package, class: Packages::Package do
project
name 'my/company/app/my-app'
version '1.0-SNAPSHOT'
package_type 'maven'
name { 'my/company/app/my-app' }
version { '1.0-SNAPSHOT' }
package_type { 'maven' }
factory :maven_package do
maven_metadatum
......@@ -22,8 +22,8 @@ FactoryBot.define do
factory :npm_package do
sequence(:name) { |n| "@#{project.root_namespace.path}/package-#{n}"}
version '1.0.0'
package_type 'npm'
version { '1.0.0' }
package_type { 'npm' }
after :create do |package|
create :package_file, :npm, package: package
......@@ -36,33 +36,33 @@ FactoryBot.define do
trait(:jar) do
file { fixture_file_upload('ee/spec/fixtures/maven/my-app-1.0-20180724.124855-1.jar') }
file_name 'my-app-1.0-20180724.124855-1.jar'
file_sha1 '4f0bfa298744d505383fbb57c554d4f5c12d88b3'
file_type 'jar'
file_name { 'my-app-1.0-20180724.124855-1.jar' }
file_sha1 { '4f0bfa298744d505383fbb57c554d4f5c12d88b3' }
file_type { 'jar' }
size { 100.kilobytes }
end
trait(:pom) do
file { fixture_file_upload('ee/spec/fixtures/maven/my-app-1.0-20180724.124855-1.pom') }
file_name 'my-app-1.0-20180724.124855-1.pom'
file_sha1 '19c975abd49e5102ca6c74a619f21e0cf0351c57'
file_type 'pom'
file_name { 'my-app-1.0-20180724.124855-1.pom' }
file_sha1 { '19c975abd49e5102ca6c74a619f21e0cf0351c57' }
file_type { 'pom' }
size { 200.kilobytes }
end
trait(:xml) do
file { fixture_file_upload('ee/spec/fixtures/maven/maven-metadata.xml') }
file_name 'maven-metadata.xml'
file_sha1 '42b1bdc80de64953b6876f5a8c644f20204011b0'
file_type 'xml'
file_name { 'maven-metadata.xml' }
file_sha1 { '42b1bdc80de64953b6876f5a8c644f20204011b0' }
file_type { 'xml' }
size { 300.kilobytes }
end
trait(:npm) do
file { fixture_file_upload('ee/spec/fixtures/npm/foo-1.0.1.tgz') }
file_name 'foo-1.0.1.tgz'
file_sha1 'be93151dc23ac34a82752444556fe79b32c7a1ad'
file_type 'tgz'
file_name { 'foo-1.0.1.tgz' }
file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' }
file_type { 'tgz' }
size { 400.kilobytes }
end
......@@ -73,9 +73,9 @@ FactoryBot.define do
factory :maven_metadatum, class: Packages::MavenMetadatum do
package
path 'my/company/app/my-app/1.0-SNAPSHOT'
app_group 'my.company.app'
app_name 'my-app'
app_version '1.0-SNAPSHOT'
path { 'my/company/app/my-app/1.0-SNAPSHOT' }
app_group { 'my.company.app' }
app_name { 'my-app' }
app_version { '1.0-SNAPSHOT' }
end
end
......@@ -4,13 +4,13 @@
FactoryBot.define do
factory :plan do
factory :free_plan do
name EE::Namespace::FREE_PLAN
name { EE::Namespace::FREE_PLAN }
title { name.titleize }
end
EE::Namespace::PLANS.each do |plan|
factory :"#{plan}_plan" do
name plan
name { plan }
title { name.titleize }
end
end
......
......@@ -3,6 +3,6 @@
FactoryBot.define do
factory :project_alerting_setting, class: Alerting::ProjectAlertingSetting do
project
token 'access_token_123'
token { 'access_token_123' }
end
end
......@@ -5,47 +5,47 @@ FactoryBot.define do
project
trait :repository_failed do
repository_verification_checksum nil
repository_verification_checksum { nil }
last_repository_verification_ran_at { Time.now }
last_repository_verification_failure 'Could not calculate the checksum'
repository_retry_count 1
last_repository_verification_failure { 'Could not calculate the checksum' }
repository_retry_count { 1 }
repository_retry_at { 5.minutes.ago }
end
trait :repository_outdated do
repository_verification_checksum nil
repository_verification_checksum { nil }
last_repository_verification_ran_at { 1.day.ago }
last_repository_verification_failure nil
last_repository_verification_failure { nil }
end
trait :repository_verified do
repository_verification_checksum 'f079a831cab27bcda7d81cd9b48296d0c3dd92ee'
repository_verification_checksum { 'f079a831cab27bcda7d81cd9b48296d0c3dd92ee' }
last_repository_verification_ran_at { 1.day.ago }
last_repository_verification_failure nil
repository_retry_count nil
repository_retry_at nil
last_repository_verification_failure { nil }
repository_retry_count { nil }
repository_retry_at { nil }
end
trait :wiki_failed do
wiki_verification_checksum nil
wiki_verification_checksum { nil }
last_wiki_verification_ran_at { Time.now }
last_wiki_verification_failure 'Could not calculate the checksum'
wiki_retry_count 1
last_wiki_verification_failure { 'Could not calculate the checksum' }
wiki_retry_count { 1 }
wiki_retry_at { 5.minutes.ago }
end
trait :wiki_outdated do
wiki_verification_checksum nil
wiki_verification_checksum { nil }
last_wiki_verification_ran_at { 1.day.ago }
last_wiki_verification_failure nil
last_wiki_verification_failure { nil }
end
trait :wiki_verified do
wiki_verification_checksum 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef'
wiki_verification_checksum { 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef' }
last_wiki_verification_ran_at { 1.day.ago }
last_wiki_verification_failure nil
wiki_retry_count nil
wiki_retry_at nil
last_wiki_verification_failure { nil }
wiki_retry_count { nil }
wiki_retry_at { nil }
end
end
end
......@@ -3,6 +3,6 @@
FactoryBot.define do
factory :project_tracing_setting do
project
external_url 'https://example.com'
external_url { 'https://example.com' }
end
end
......@@ -3,9 +3,9 @@
FactoryBot.modify do
factory :project do
transient do
last_update_at nil
last_successful_update_at nil
retry_count 0
last_update_at { nil }
last_successful_update_at { nil }
retry_count { 0 }
end
after(:create) do |project, evaluator|
......@@ -37,23 +37,23 @@ FactoryBot.modify do
end
trait :import_none do
import_status :none
import_status { :none }
end
trait :import_hard_failed do
import_status :failed
import_status { :failed }
last_update_at { Time.now - 1.minute }
retry_count { Gitlab::Mirror::MAX_RETRY + 1 }
end
trait :disabled_mirror do
mirror false
mirror { false }
import_url { generate(:url) }
mirror_user_id { creator_id }
end
trait :mirror do
mirror true
mirror { true }
import_url { generate(:url) }
mirror_user_id { creator_id }
end
......@@ -63,7 +63,7 @@ FactoryBot.modify do
end
trait :requiring_code_owner_approval do
merge_requests_require_code_owner_approval true
merge_requests_require_code_owner_approval { true }
end
trait :jira_dvcs_cloud do
......@@ -79,7 +79,7 @@ FactoryBot.modify do
end
trait :service_desk_disabled do
service_desk_enabled nil
service_desk_enabled { nil }
end
trait :github_imported do
......
......@@ -3,8 +3,8 @@
FactoryBot.define do
factory :prometheus_alert do
project
operator :gt
threshold 1
operator { :gt }
threshold { 1 }
environment do |alert|
build(:environment, project: alert.project)
......
......@@ -11,12 +11,12 @@ FactoryBot.define do
trait :resolved do
status { PrometheusAlertEvent.status_value_for(:resolved) }
ended_at { Time.now }
payload_key nil
payload_key { nil }
end
trait :none do
status nil
started_at nil
status { nil }
started_at { nil }
end
end
end
......@@ -3,12 +3,12 @@
FactoryBot.modify do
factory :protected_branch do
transient do
authorize_user_to_push nil
authorize_user_to_merge nil
authorize_user_to_unprotect nil
authorize_group_to_push nil
authorize_group_to_merge nil
authorize_group_to_unprotect nil
authorize_user_to_push { nil }
authorize_user_to_merge { nil }
authorize_user_to_unprotect { nil }
authorize_group_to_push { nil }
authorize_group_to_merge { nil }
authorize_group_to_unprotect { nil }
end
after(:build) do |protected_branch, evaluator|
......
......@@ -2,8 +2,8 @@
FactoryBot.define do
factory :protected_branch_merge_access_level, class: ProtectedBranch::MergeAccessLevel do
user nil
group nil
user { nil }
group { nil }
protected_branch
access_level { Gitlab::Access::DEVELOPER }
end
......
......@@ -2,8 +2,8 @@
FactoryBot.define do
factory :protected_branch_push_access_level, class: ProtectedBranch::PushAccessLevel do
user nil
group nil
user { nil }
group { nil }
protected_branch
access_level { Gitlab::Access::DEVELOPER }
end
......
......@@ -2,8 +2,8 @@
FactoryBot.define do
factory :protected_branch_unprotect_access_level, class: ProtectedBranch::UnprotectAccessLevel do
user nil
group nil
user { nil }
group { nil }
protected_branch
access_level { Gitlab::Access::DEVELOPER }
end
......
# frozen_string_literal: true
FactoryBot.define do
factory :protected_environment do
name 'production'
name { 'production' }
project
transient do
authorize_user_to_deploy nil
authorize_group_to_deploy nil
authorize_user_to_deploy { nil }
authorize_group_to_deploy { nil }
end
after(:build) do |protected_environment, evaluator|
......@@ -36,7 +36,7 @@ FactoryBot.define do
end
trait :staging do
name 'staging'
name { 'staging' }
end
end
end
# frozen_string_literal: true
FactoryBot.define do
factory :protected_environment_deploy_access_level, class: ProtectedEnvironment::DeployAccessLevel do
user nil
group nil
user { nil }
group { nil }
protected_environment
access_level { Gitlab::Access::DEVELOPER }
......
......@@ -3,13 +3,13 @@
FactoryBot.modify do
factory :protected_tag do
transient do
authorize_user_to_create nil
authorize_group_to_create nil
authorize_user_to_create { nil }
authorize_group_to_create { nil }
end
trait :developers_can_create do
transient do
default_access_level false
default_access_level { false }
end
after(:build) do |protected_tag|
......@@ -19,7 +19,7 @@ FactoryBot.modify do
trait :no_one_can_create do
transient do
default_access_level false
default_access_level { false }
end
after(:build) do |protected_tag|
......@@ -29,7 +29,7 @@ FactoryBot.modify do
trait :maintainers_can_create do
transient do
default_access_level false
default_access_level { false }
end
after(:build) do |protected_tag|
......
......@@ -2,8 +2,8 @@
FactoryBot.define do
factory :protected_tag_create_access_level, class: ProtectedTag::CreateAccessLevel do
user nil
group nil
user { nil }
group { nil }
protected_tag
access_level { Gitlab::Access::DEVELOPER }
end
......
......@@ -4,21 +4,21 @@
FactoryBot.define do
factory :push_rule do
force_push_regex 'feature\/.*'
deny_delete_tag false
delete_branch_regex 'bug\/.*'
force_push_regex { 'feature\/.*' }
deny_delete_tag { false }
delete_branch_regex { 'bug\/.*' }
project
trait :commit_message do
commit_message_regex "(f|F)ixes #\d+.*"
commit_message_regex { "(f|F)ixes #\d+.*" }
end
trait :author_email do
author_email_regex '.*@veryspecificedomain.com'
author_email_regex { '.*@veryspecificedomain.com' }
end
factory :push_rule_sample do
is_sample true
is_sample { true }
end
end
end
......@@ -3,13 +3,13 @@
FactoryBot.define do
factory :saml_provider do
group
certificate_fingerprint '55:44:33:22:11:aa:bb:cc:dd:ee:ff:11:22:33:44:55:66:77:88:99'
sso_url 'https://saml.example.com/adfs/ls'
certificate_fingerprint { '55:44:33:22:11:aa:bb:cc:dd:ee:ff:11:22:33:44:55:66:77:88:99' }
sso_url { 'https://saml.example.com/adfs/ls' }
trait :enforced_group_managed_accounts do
enabled true
enforced_sso true
enforced_group_managed_accounts true
enabled { true }
enforced_sso { true }
enforced_group_managed_accounts { true }
end
end
end
......@@ -3,17 +3,17 @@
FactoryBot.define do
factory :gitlab_slack_application_service do
project
active true
type 'GitlabSlackApplicationService'
active { true }
type { 'GitlabSlackApplicationService' }
end
factory :alerts_service do
project
type 'AlertsService'
active true
type { 'AlertsService' }
active { true }
trait :inactive do
active false
active { false }
end
end
end
......@@ -2,12 +2,12 @@
FactoryBot.define do
factory :software_license_policy, class: SoftwareLicensePolicy do
approval_status 1
approval_status { 1 }
project
software_license
trait :blacklist do
approval_status :blacklisted
approval_status { :blacklisted }
end
end
end
......@@ -3,7 +3,7 @@
FactoryBot.modify do
factory :user do
trait :auditor do
auditor true
auditor { true }
end
trait :group_managed do
......@@ -17,7 +17,7 @@ FactoryBot.modify do
factory :omniauth_user do
transient do
saml_provider nil
saml_provider { nil }
end
end
end
......
......@@ -10,48 +10,48 @@ FactoryBot.define do
factory :vulnerability_feedback, class: Vulnerabilities::Feedback do
project
author
issue nil
merge_request nil
issue { nil }
merge_request { nil }
association :pipeline, factory: :ci_pipeline
feedback_type 'dismissal'
category 'sast'
feedback_type { 'dismissal' }
category { 'sast' }
project_fingerprint { generate(:project_fingerprint) }
vulnerability_data { { category: 'sast' } }
trait :dismissal do
feedback_type 'dismissal'
feedback_type { 'dismissal' }
end
trait :comment do
comment 'a dismissal comment'
comment { 'a dismissal comment' }
comment_timestamp { Time.zone.now }
comment_author { author }
end
trait :issue do
feedback_type 'issue'
feedback_type { 'issue' }
issue { create(:issue, project: project) }
end
trait :merge_request do
feedback_type 'merge_request'
feedback_type { 'merge_request' }
merge_request { create(:merge_request, source_project: project) }
end
trait :sast do
category 'sast'
category { 'sast' }
end
trait :dependency_scanning do
category 'dependency_scanning'
category { 'dependency_scanning' }
end
trait :container_scanning do
category 'container_scanning'
category { 'container_scanning' }
end
trait :dast do
category 'dast'
category { 'dast' }
end
end
end
......@@ -2,11 +2,11 @@
FactoryBot.define do
factory :vulnerabilities_identifier, class: Vulnerabilities::Identifier do
external_type 'CVE'
external_id 'CVE-2018-1234'
fingerprint '52d084cede3db8fafcd6b8ae382ddf1970da3b7f'
name 'CVE-2018-1234'
url 'http://cve.mitre.org/cgi-bin/cvename.cgi?name=2018-1234'
external_type { 'CVE' }
external_id { 'CVE-2018-1234' }
fingerprint { '52d084cede3db8fafcd6b8ae382ddf1970da3b7f' }
name { 'CVE-2018-1234' }
url { 'http://cve.mitre.org/cgi-bin/cvename.cgi?name=2018-1234' }
project
end
end
......@@ -6,17 +6,17 @@ FactoryBot.define do
end
factory :vulnerabilities_occurrence, class: Vulnerabilities::Occurrence do
name 'Cipher with no integrity'
name { 'Cipher with no integrity' }
project
sequence(:uuid) { generate(:vulnerability_occurrence_uuid) }
project_fingerprint { generate(:project_fingerprint) }
primary_identifier factory: :vulnerabilities_identifier
location_fingerprint '4e5b6966dd100170b4b1ad599c7058cce91b57b4'
report_type :sast
severity :high
confidence :medium
location_fingerprint { '4e5b6966dd100170b4b1ad599c7058cce91b57b4' }
report_type { :sast }
severity { :high }
confidence { :medium }
scanner factory: :vulnerabilities_scanner
metadata_version 'sast:1.0'
metadata_version { 'sast:1.0' }
raw_metadata do
{
description: "The cipher does not provide data integrity update 1",
......
......@@ -2,8 +2,8 @@
FactoryBot.define do
factory :vulnerabilities_scanner, class: Vulnerabilities::Scanner do
external_id 'find_sec_bugs'
name 'Find Security Bugs'
external_id { 'find_sec_bugs' }
name { 'Find Security Bugs' }
project
end
end
......@@ -6,5 +6,9 @@ RSpec.configure do |config|
Rails.root.join('ee', 'spec', 'factories')
]
FactoryBot.find_definitions
# Use FactoryBot 4.x behavior:
# https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#associations
FactoryBot.use_parent_strategy = false
end
end
......@@ -4,6 +4,6 @@ FactoryBot.define do
factory :abuse_report do
reporter factory: :user
user
message 'User sends spam'
message { 'User sends spam' }
end
end
......@@ -4,9 +4,9 @@
FactoryBot.define do
factory :appearance do
title "GitLab Community Edition"
description "Open source software to collaborate on code"
new_project_guidelines "Custom project guidelines"
title { "GitLab Community Edition" }
description { "Open source software to collaborate on code" }
new_project_guidelines { "Custom project guidelines" }
end
trait :with_logo do
......
......@@ -2,6 +2,6 @@
FactoryBot.define do
factory :application_setting do
default_projects_limit 42
default_projects_limit { 42 }
end
end
......@@ -2,7 +2,7 @@
FactoryBot.define do
factory :award_emoji do
name "thumbsup"
name { "thumbsup" }
user
awardable factory: :issue
......@@ -12,7 +12,7 @@ FactoryBot.define do
trait :upvote
trait :downvote do
name "thumbsdown"
name { "thumbsdown" }
end
end
end
......@@ -3,11 +3,11 @@
FactoryBot.define do
factory :board do
transient do
project nil
group nil
project_id nil
group_id nil
parent nil
project { nil }
group { nil }
project_id { nil }
group_id { nil }
parent { nil }
end
after(:build, :stub) do |board, evaluator|
......
......@@ -2,7 +2,7 @@
FactoryBot.define do
factory :broadcast_message do
message "MyText"
message { "MyText" }
starts_at { 1.day.ago }
ends_at { 1.day.from_now }
......
......@@ -5,8 +5,8 @@ FactoryBot.define do
user factory: :user
service factory: :service
team_id 'T0001'
team_domain 'Awesome Team'
team_id { 'T0001' }
team_domain { 'Awesome Team' }
sequence(:chat_id) { |n| "U#{n}" }
chat_name { generate(:username) }
......
......@@ -2,22 +2,26 @@
FactoryBot.define do
factory :ci_bridge, class: Ci::Bridge do
name 'bridge'
stage 'test'
stage_idx 0
ref 'master'
tag false
created_at 'Di 29. Okt 09:50:00 CET 2013'
status :created
name { 'bridge' }
stage { 'test' }
stage_idx { 0 }
ref { 'master' }
tag { false }
created_at { 'Di 29. Okt 09:50:00 CET 2013' }
status { :created }
pipeline factory: :ci_pipeline
trait :variables do
yaml_variables [{ key: 'BRIDGE', value: 'cross', public: true }]
yaml_variables do
[{ key: 'BRIDGE', value: 'cross', public: true }]
end
end
transient { downstream nil }
transient { upstream nil }
transient do
downstream { nil }
upstream { nil }
end
after(:build) do |bridge, evaluator|
bridge.project ||= bridge.pipeline.project
......
......@@ -3,14 +3,14 @@
FactoryBot.define do
factory :ci_build_trace_chunk, class: Ci::BuildTraceChunk do
build factory: :ci_build
chunk_index 0
data_store :redis
chunk_index { 0 }
data_store { :redis }
trait :redis_with_data do
data_store :redis
data_store { :redis }
transient do
initial_data 'test data'
initial_data { 'test data' }
end
after(:create) do |build_trace_chunk, evaluator|
......@@ -19,14 +19,14 @@ FactoryBot.define do
end
trait :redis_without_data do
data_store :redis
data_store { :redis }
end
trait :database_with_data do
data_store :database
data_store { :database}
transient do
initial_data 'test data'
initial_data { 'test data' }
end
after(:build) do |build_trace_chunk, evaluator|
......@@ -35,14 +35,14 @@ FactoryBot.define do
end
trait :database_without_data do
data_store :database
data_store { :database }
end
trait :fog_with_data do
data_store :fog
data_store { :fog }
transient do
initial_data 'test data'
initial_data { 'test data' }
end
after(:create) do |build_trace_chunk, evaluator|
......@@ -51,7 +51,7 @@ FactoryBot.define do
end
trait :fog_without_data do
data_store :fog
data_store { :fog }
end
end
end
......@@ -4,13 +4,13 @@ include ActionDispatch::TestProcess
FactoryBot.define do
factory :ci_build, class: Ci::Build do
name 'test'
stage 'test'
stage_idx 0
ref 'master'
tag false
protected false
created_at 'Di 29. Okt 09:50:00 CET 2013'
name { 'test' }
stage { 'test' }
stage_idx { 0 }
ref { 'master' }
tag { false }
add_attribute(:protected) { false }
created_at { 'Di 29. Okt 09:50:00 CET 2013' }
pending
options do
......@@ -30,76 +30,76 @@ FactoryBot.define do
pipeline factory: :ci_pipeline
trait :degenerated do
options nil
yaml_variables nil
options { nil }
yaml_variables { nil }
end
trait :started do
started_at 'Di 29. Okt 09:51:28 CET 2013'
started_at { 'Di 29. Okt 09:51:28 CET 2013' }
end
trait :finished do
started
finished_at 'Di 29. Okt 09:53:28 CET 2013'
finished_at { 'Di 29. Okt 09:53:28 CET 2013' }
end
trait :success do
finished
status 'success'
status { 'success' }
end
trait :failed do
finished
status 'failed'
status { 'failed' }
end
trait :canceled do
finished
status 'canceled'
status { 'canceled' }
end
trait :skipped do
started
status 'skipped'
status { 'skipped' }
end
trait :running do
started
status 'running'
status { 'running' }
end
trait :pending do
queued_at 'Di 29. Okt 09:50:59 CET 2013'
status 'pending'
queued_at { 'Di 29. Okt 09:50:59 CET 2013' }
status { 'pending' }
end
trait :created do
status 'created'
status { 'created' }
end
trait :preparing do
status 'preparing'
status { 'preparing' }
end
trait :scheduled do
schedulable
status 'scheduled'
status { 'scheduled' }
scheduled_at { 1.minute.since }
end
trait :expired_scheduled do
schedulable
status 'scheduled'
status { 'scheduled' }
scheduled_at { 1.minute.ago }
end
trait :manual do
status 'manual'
self.when 'manual'
status { 'manual' }
self.when { 'manual' }
end
trait :teardown_environment do
environment 'staging'
environment { 'staging' }
options do
{
script: %w(ls),
......@@ -111,7 +111,7 @@ FactoryBot.define do
end
trait :deploy_to_production do
environment 'production'
environment { 'production' }
options do
{
......@@ -123,7 +123,7 @@ FactoryBot.define do
end
trait :start_review_app do
environment 'review/$CI_COMMIT_REF_NAME'
environment { 'review/$CI_COMMIT_REF_NAME' }
options do
{
......@@ -136,8 +136,8 @@ FactoryBot.define do
end
trait :stop_review_app do
name 'stop_review_app'
environment 'review/$CI_COMMIT_REF_NAME'
name { 'stop_review_app' }
environment { 'review/$CI_COMMIT_REF_NAME' }
options do
{
......@@ -150,7 +150,7 @@ FactoryBot.define do
end
trait :allowed_to_fail do
allow_failure true
allow_failure { true }
end
trait :ignored do
......@@ -166,7 +166,7 @@ FactoryBot.define do
end
trait :schedulable do
self.when 'delayed'
self.when { 'delayed' }
options do
{
......@@ -177,11 +177,11 @@ FactoryBot.define do
end
trait :actionable do
self.when 'manual'
self.when { 'manual' }
end
trait :retried do
retried true
retried { true }
end
trait :cancelable do
......@@ -194,11 +194,13 @@ FactoryBot.define do
end
trait :tags do
tag_list [:docker, :ruby]
tag_list do
[:docker, :ruby]
end
end
trait :on_tag do
tag true
tag { true }
end
trait :triggered do
......@@ -210,12 +212,12 @@ FactoryBot.define do
end
trait :tag do
tag true
tag { true }
end
trait :coverage do
coverage 99.9
coverage_regex '/(d+)/'
coverage { 99.9 }
coverage_regex { '/(d+)/' }
end
trait :trace_live do
......@@ -329,27 +331,27 @@ FactoryBot.define do
end
trait :non_playable do
status 'created'
self.when 'manual'
status { 'created' }
self.when { 'manual' }
end
trait :protected do
protected true
add_attribute(:protected) { true }
end
trait :script_failure do
failed
failure_reason 1
failure_reason { 1 }
end
trait :api_failure do
failed
failure_reason 2
failure_reason { 2 }
end
trait :prerequisite_failure do
failed
failure_reason 10
failure_reason { 10 }
end
trait :with_runner_session do
......
......@@ -3,11 +3,11 @@
FactoryBot.define do
factory :ci_group_variable, class: Ci::GroupVariable do
sequence(:key) { |n| "VARIABLE_#{n}" }
value 'VARIABLE_VALUE'
masked false
value { 'VARIABLE_VALUE' }
masked { false }
trait(:protected) do
protected true
add_attribute(:protected) { true }
end
group factory: :group
......
......@@ -5,15 +5,15 @@ include ActionDispatch::TestProcess
FactoryBot.define do
factory :ci_job_artifact, class: Ci::JobArtifact do
job factory: :ci_build
file_type :archive
file_format :zip
file_type { :archive }
file_format { :zip }
trait :expired do
expire_at { Date.yesterday }
end
trait :remote_store do
file_store JobArtifactUploader::Store::REMOTE
file_store { JobArtifactUploader::Store::REMOTE}
end
after :build do |artifact|
......@@ -21,7 +21,7 @@ FactoryBot.define do
end
trait :raw do
file_format :raw
file_format { :raw }
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
......@@ -30,7 +30,7 @@ FactoryBot.define do
end
trait :zip do
file_format :zip
file_format { :zip }
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
......@@ -39,7 +39,7 @@ FactoryBot.define do
end
trait :gzip do
file_format :gzip
file_format { :gzip }
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
......@@ -48,8 +48,8 @@ FactoryBot.define do
end
trait :archive do
file_type :archive
file_format :zip
file_type { :archive }
file_format { :zip }
transient do
file { fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), 'application/zip') }
......@@ -63,12 +63,12 @@ FactoryBot.define do
trait :legacy_archive do
archive
file_location :legacy_path
file_location { :legacy_path }
end
trait :metadata do
file_type :metadata
file_format :gzip
file_type { :metadata }
file_format { :gzip }
transient do
file { fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'), 'application/x-gzip') }
......@@ -80,8 +80,8 @@ FactoryBot.define do
end
trait :trace do
file_type :trace
file_format :raw
file_type { :trace }
file_format { :raw }
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
......@@ -90,8 +90,8 @@ FactoryBot.define do
end
trait :junit do
file_type :junit
file_format :gzip
file_type { :junit }
file_format { :gzip }
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
......@@ -100,8 +100,8 @@ FactoryBot.define do
end
trait :junit_with_ant do
file_type :junit
file_format :gzip
file_type { :junit }
file_format { :gzip }
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
......@@ -110,8 +110,8 @@ FactoryBot.define do
end
trait :junit_with_three_testsuites do
file_type :junit
file_format :gzip
file_type { :junit }
file_format { :gzip }
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
......@@ -120,8 +120,8 @@ FactoryBot.define do
end
trait :junit_with_corrupted_data do
file_type :junit
file_format :gzip
file_type { :junit }
file_format { :gzip }
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
......@@ -130,8 +130,8 @@ FactoryBot.define do
end
trait :codequality do
file_type :codequality
file_format :raw
file_type { :codequality }
file_format { :raw }
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
......
......@@ -3,7 +3,7 @@
FactoryBot.define do
factory :ci_job_variable, class: Ci::JobVariable do
sequence(:key) { |n| "VARIABLE_#{n}" }
value 'VARIABLE_VALUE'
value { 'VARIABLE_VALUE' }
job factory: :ci_build
end
......
......@@ -2,40 +2,40 @@
FactoryBot.define do
factory :ci_pipeline_schedule, class: Ci::PipelineSchedule do
cron '0 1 * * *'
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE
ref 'master'
active true
description "pipeline schedule"
cron { '0 1 * * *' }
cron_timezone { Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE }
ref { 'master' }
active { true }
description { "pipeline schedule" }
project
trait :every_minute do
cron '*/1 * * * *'
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE
cron { '*/1 * * * *' }
cron_timezone { Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE }
end
trait :hourly do
cron '* */1 * * *'
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE
cron { '* */1 * * *' }
cron_timezone { Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE }
end
trait :nightly do
cron '0 1 * * *'
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE
cron { '0 1 * * *' }
cron_timezone { Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE }
end
trait :weekly do
cron '0 1 * * 6'
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE
cron { '0 1 * * 6' }
cron_timezone { Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE }
end
trait :monthly do
cron '0 1 22 * *'
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE
cron { '0 1 22 * *' }
cron_timezone { Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE }
end
trait :inactive do
active false
active { false }
end
end
end
......@@ -3,8 +3,8 @@
FactoryBot.define do
factory :ci_pipeline_schedule_variable, class: Ci::PipelineScheduleVariable do
sequence(:key) { |n| "VARIABLE_#{n}" }
value 'VARIABLE_VALUE'
variable_type 'env_var'
value { 'VARIABLE_VALUE' }
variable_type { 'env_var' }
pipeline_schedule factory: :ci_pipeline_schedule
end
......
......@@ -3,7 +3,7 @@
FactoryBot.define do
factory :ci_pipeline_variable, class: Ci::PipelineVariable do
sequence(:key) { |n| "VARIABLE_#{n}" }
value 'VARIABLE_VALUE'
value { 'VARIABLE_VALUE' }
pipeline factory: :ci_empty_pipeline
end
......
......@@ -2,11 +2,11 @@
FactoryBot.define do
factory :ci_empty_pipeline, class: Ci::Pipeline do
source :push
ref 'master'
sha '97de212e80737a608d939f648d959671fb0a0142'
status 'pending'
protected false
source { :push }
ref { 'master' }
sha { '97de212e80737a608d939f648d959671fb0a0142' }
status { 'pending' }
add_attribute(:protected) { false }
project
......@@ -26,7 +26,7 @@ FactoryBot.define do
# Persist merge request head_pipeline_id
# on pipeline factories to avoid circular references
transient { head_pipeline_of nil }
transient { head_pipeline_of { nil } }
after(:create) do |pipeline, evaluator|
merge_request = evaluator.head_pipeline_of
......@@ -34,7 +34,7 @@ FactoryBot.define do
end
factory :ci_pipeline do
transient { config nil }
transient { config { nil } }
after(:build) do |pipeline, evaluator|
if evaluator.config
......@@ -48,44 +48,47 @@ FactoryBot.define do
end
trait :invalid do
config(rspec: nil)
failure_reason :config_error
config do
{ rspec: nil }
end
failure_reason { :config_error }
end
trait :created do
status :created
status { :created }
end
trait :preparing do
status :preparing
status { :preparing }
end
trait :blocked do
status :manual
status { :manual }
end
trait :scheduled do
status :scheduled
status { :scheduled }
end
trait :success do
status :success
status { :success }
end
trait :running do
status :running
status { :running }
end
trait :failed do
status :failed
status { :failed }
end
trait :protected do
protected true
add_attribute(:protected) { true }
end
trait :with_test_reports do
status :success
status { :success }
after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ci_build, :test_reports, pipeline: pipeline, project: pipeline.project)
......
......@@ -4,22 +4,22 @@ FactoryBot.define do
factory :ci_runner, class: Ci::Runner do
sequence(:description) { |n| "My runner#{n}" }
platform "darwin"
active true
access_level :not_protected
platform { "darwin" }
active { true }
access_level { :not_protected }
runner_type :instance_type
runner_type { :instance_type }
trait :online do
contacted_at { Time.now }
end
trait :instance do
runner_type :instance_type
runner_type { :instance_type }
end
trait :group do
runner_type :group_type
runner_type { :group_type }
after(:build) do |runner, evaluator|
runner.groups << build(:group) if runner.groups.empty?
......@@ -27,7 +27,7 @@ FactoryBot.define do
end
trait :project do
runner_type :project_type
runner_type { :project_type }
after(:build) do |runner, evaluator|
runner.projects << build(:project) if runner.projects.empty?
......@@ -43,21 +43,21 @@ FactoryBot.define do
end
trait :inactive do
active false
active { false }
end
trait :ref_protected do
access_level :ref_protected
access_level { :ref_protected }
end
trait :tagged_only do
run_untagged false
run_untagged { false }
tag_list %w(tag1 tag2)
tag_list { %w(tag1 tag2) }
end
trait :locked do
locked true
locked { true }
end
end
end
......@@ -5,9 +5,9 @@ FactoryBot.define do
skip_create
transient do
name 'test'
status nil
warnings nil
name { 'test' }
status { nil }
warnings { nil }
pipeline factory: :ci_empty_pipeline
end
......@@ -22,8 +22,8 @@ FactoryBot.define do
project factory: :project
pipeline factory: :ci_empty_pipeline
name 'test'
position 1
status 'pending'
name { 'test' }
position { 1 }
status { 'pending' }
end
end
......@@ -3,11 +3,11 @@
FactoryBot.define do
factory :ci_variable, class: Ci::Variable do
sequence(:key) { |n| "VARIABLE_#{n}" }
value 'VARIABLE_VALUE'
masked false
value { 'VARIABLE_VALUE' }
masked { false }
trait(:protected) do
protected true
add_attribute(:protected) { true }
end
project
......
......@@ -19,50 +19,50 @@ FactoryBot.define do
end
trait :not_installable do
status(-2)
status { -2 }
end
trait :errored do
status(-1)
status_reason 'something went wrong'
status { -1 }
status_reason { 'something went wrong' }
end
trait :installable do
status 0
status { 0 }
end
trait :scheduled do
status 1
status { 1 }
end
trait :installing do
status 2
status { 2 }
end
trait :installed do
status 3
status { 3 }
end
trait :updating do
status 4
status { 4 }
end
trait :updated do
status 5
status { 5 }
end
trait :update_errored do
status(6)
status_reason 'something went wrong'
status { 6 }
status_reason { 'something went wrong' }
end
trait :uninstalling do
status 7
status { 7 }
end
trait :uninstall_errored do
status(8)
status_reason 'something went wrong'
status { 8 }
status_reason { 'something went wrong' }
end
trait :timed_out do
......@@ -75,7 +75,7 @@ FactoryBot.define do
end
factory :clusters_applications_cert_manager, class: Clusters::Applications::CertManager do
email 'admin@example.com'
email { 'admin@example.com' }
cluster factory: %i(cluster with_installed_helm provided_by_gcp)
end
......@@ -89,7 +89,7 @@ FactoryBot.define do
end
factory :clusters_applications_knative, class: Clusters::Applications::Knative do
hostname 'example.com'
hostname { 'example.com' }
cluster factory: %i(cluster with_installed_helm provided_by_gcp)
end
......
......@@ -3,10 +3,10 @@
FactoryBot.define do
factory :cluster, class: Clusters::Cluster do
user
name 'test-cluster'
cluster_type :project_type
managed true
namespace_per_environment true
name { 'test-cluster' }
cluster_type { :project_type }
managed { true }
namespace_per_environment { true }
factory :cluster_for_group, traits: [:provided_by_gcp, :group]
......@@ -31,26 +31,26 @@ FactoryBot.define do
end
trait :namespace_per_environment_disabled do
namespace_per_environment false
namespace_per_environment { false }
end
trait :provided_by_user do
provider_type :user
platform_type :kubernetes
provider_type { :user }
platform_type { :kubernetes }
platform_kubernetes factory: [:cluster_platform_kubernetes, :configured]
end
trait :provided_by_gcp do
provider_type :gcp
platform_type :kubernetes
provider_type { :gcp }
platform_type { :kubernetes }
provider_gcp factory: [:cluster_provider_gcp, :created]
platform_kubernetes factory: [:cluster_platform_kubernetes, :configured]
end
trait :providing_by_gcp do
provider_type :gcp
provider_type { :gcp }
provider_gcp factory: [:cluster_provider_gcp, :creating]
end
......@@ -63,7 +63,7 @@ FactoryBot.define do
end
trait :disabled do
enabled false
enabled { false }
end
trait :production_environment do
......@@ -75,11 +75,11 @@ FactoryBot.define do
end
trait :with_domain do
domain 'example.com'
domain { 'example.com' }
end
trait :not_managed do
managed false
managed { false }
end
end
end
......@@ -27,7 +27,7 @@ FactoryBot.define do
end
trait :without_token do
service_account_token nil
service_account_token { nil }
end
end
end
......@@ -3,14 +3,14 @@
FactoryBot.define do
factory :cluster_platform_kubernetes, class: Clusters::Platforms::Kubernetes do
cluster
namespace nil
api_url 'https://kubernetes.example.com'
namespace { nil }
api_url { 'https://kubernetes.example.com' }
token { 'a' * 40 }
trait :configured do
api_url 'https://kubernetes.example.com'
username 'xxxxxx'
password 'xxxxxx'
api_url { 'https://kubernetes.example.com' }
username { 'xxxxxx' }
password { 'xxxxxx' }
before(:create) do |platform_kubernetes, evaluator|
pem_file = File.expand_path(Rails.root.join('spec/fixtures/clusters/sample_cert.pem'))
......@@ -19,7 +19,7 @@ FactoryBot.define do
end
trait :rbac_disabled do
authorization_type :abac
authorization_type { :abac }
end
end
end
......@@ -3,14 +3,14 @@
FactoryBot.define do
factory :cluster_provider_gcp, class: Clusters::Providers::Gcp do
cluster
gcp_project_id 'test-gcp-project'
gcp_project_id { 'test-gcp-project' }
trait :scheduled do
access_token 'access_token_123'
access_token { 'access_token_123' }
end
trait :creating do
access_token 'access_token_123'
access_token { 'access_token_123' }
after(:build) do |gcp, evaluator|
gcp.make_creating('operation-123')
......@@ -18,7 +18,7 @@ FactoryBot.define do
end
trait :created do
endpoint '111.111.111.111'
endpoint { '111.111.111.111' }
after(:build) do |gcp, evaluator|
gcp.make_created
......@@ -32,11 +32,11 @@ FactoryBot.define do
end
trait :abac_enabled do
legacy_abac true
legacy_abac { true }
end
trait :cloud_run_enabled do
cloud_run true
cloud_run { true }
end
end
end
......@@ -2,53 +2,53 @@
FactoryBot.define do
factory :commit_status, class: CommitStatus do
name 'default'
stage 'test'
stage_idx 0
status 'success'
description 'commit status'
name { 'default' }
stage { 'test' }
stage_idx { 0 }
status { 'success' }
description { 'commit status'}
pipeline factory: :ci_pipeline_with_one_job
started_at 'Tue, 26 Jan 2016 08:21:42 +0100'
finished_at 'Tue, 26 Jan 2016 08:23:42 +0100'
started_at { 'Tue, 26 Jan 2016 08:21:42 +0100'}
finished_at { 'Tue, 26 Jan 2016 08:23:42 +0100'}
trait :success do
status 'success'
status { 'success' }
end
trait :failed do
status 'failed'
status { 'failed' }
end
trait :canceled do
status 'canceled'
status { 'canceled' }
end
trait :skipped do
status 'skipped'
status { 'skipped' }
end
trait :running do
status 'running'
status { 'running' }
end
trait :pending do
status 'pending'
status { 'pending' }
end
trait :preparing do
status 'preparing'
status { 'preparing' }
end
trait :created do
status 'created'
status { 'created' }
end
trait :manual do
status 'manual'
status { 'manual' }
end
trait :scheduled do
status 'scheduled'
status { 'scheduled' }
end
after(:build) do |build, evaluator|
......@@ -56,8 +56,8 @@ FactoryBot.define do
end
factory :generic_commit_status, class: GenericCommitStatus do
name 'generic'
description 'external commit status'
name { 'generic' }
description { 'external commit status' }
end
end
end
......@@ -5,7 +5,7 @@ require_relative '../support/helpers/repo_helpers'
FactoryBot.define do
factory :commit do
transient do
author nil
author { nil }
end
git_commit do
......
......@@ -6,11 +6,11 @@ FactoryBot.define do
project
transient do
tags []
tags { [] }
end
trait :root do
name ''
name { '' }
end
after(:build) do |repository, evaluator|
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment