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 ...@@ -355,7 +355,7 @@ group :development, :test do
gem 'fuubar', '~> 2.2.0' gem 'fuubar', '~> 2.2.0'
gem 'database_cleaner', '~> 1.7.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-rails', '~> 3.8.0'
gem 'rspec-retry', '~> 0.6.1' gem 'rspec-retry', '~> 0.6.1'
gem 'rspec_profiling', '~> 0.0.5' gem 'rspec_profiling', '~> 0.0.5'
......
...@@ -254,7 +254,7 @@ GEM ...@@ -254,7 +254,7 @@ GEM
mail (~> 2.7) mail (~> 2.7)
encryptor (3.0.0) encryptor (3.0.0)
equalizer (0.0.11) equalizer (0.0.11)
erubi (1.8.0) erubi (1.9.0)
escape_utils (1.2.1) escape_utils (1.2.1)
et-orbi (1.2.1) et-orbi (1.2.1)
tzinfo tzinfo
...@@ -264,11 +264,11 @@ GEM ...@@ -264,11 +264,11 @@ GEM
expression_parser (0.9.0) expression_parser (0.9.0)
extended-markdown-filter (0.6.0) extended-markdown-filter (0.6.0)
html-pipeline (~> 2.0) html-pipeline (~> 2.0)
factory_bot (4.8.2) factory_bot (5.1.0)
activesupport (>= 3.0.0) activesupport (>= 4.2.0)
factory_bot_rails (4.8.2) factory_bot_rails (5.1.0)
factory_bot (~> 4.8.2) factory_bot (~> 5.1.0)
railties (>= 3.0.0) railties (>= 4.2.0)
faraday (0.12.2) faraday (0.12.2)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
faraday-http-cache (2.0.0) faraday-http-cache (2.0.0)
...@@ -565,7 +565,7 @@ GEM ...@@ -565,7 +565,7 @@ GEM
activesupport (>= 4) activesupport (>= 4)
railties (>= 4) railties (>= 4)
request_store (~> 1.0) request_store (~> 1.0)
loofah (2.2.3) loofah (2.3.0)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.7.1) mail (2.7.1)
...@@ -783,7 +783,7 @@ GEM ...@@ -783,7 +783,7 @@ GEM
thor (>= 0.19.0, < 2.0) thor (>= 0.19.0, < 2.0)
rainbow (3.0.0) rainbow (3.0.0)
raindrops (0.19.0) raindrops (0.19.0)
rake (12.3.2) rake (12.3.3)
rb-fsevent (0.10.2) rb-fsevent (0.10.2)
rb-inotify (0.9.10) rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2) ffi (>= 0.5.0, < 2)
...@@ -1144,7 +1144,7 @@ DEPENDENCIES ...@@ -1144,7 +1144,7 @@ DEPENDENCIES
email_reply_trimmer (~> 0.1) email_reply_trimmer (~> 0.1)
email_spec (~> 2.2.0) email_spec (~> 2.2.0)
escape_utils (~> 1.1) escape_utils (~> 1.1)
factory_bot_rails (~> 4.8.2) factory_bot_rails (~> 5.1.0)
faraday (~> 0.12) faraday (~> 0.12)
faraday_middleware-aws-signers-v4 faraday_middleware-aws-signers-v4
fast_blank fast_blank
......
...@@ -6,7 +6,7 @@ FactoryBot.define do ...@@ -6,7 +6,7 @@ FactoryBot.define do
payload { {} } payload { {} }
transient do transient do
metric_id nil metric_id { nil }
after(:build) do |alert, evaluator| after(:build) do |alert, evaluator|
unless alert.payload.key?('startsAt') unless alert.payload.key?('startsAt')
......
...@@ -8,15 +8,15 @@ FactoryBot.define do ...@@ -8,15 +8,15 @@ FactoryBot.define do
factory :code_owner_rule, parent: :approval_merge_request_rule do factory :code_owner_rule, parent: :approval_merge_request_rule do
merge_request merge_request
rule_type :code_owner rule_type { :code_owner }
code_owner true # deprecated, replaced with `rule_type: :code_owner` code_owner { true } # deprecated, replaced with `rule_type: :code_owner`
sequence(:name) { |n| "*-#{n}.js" } sequence(:name) { |n| "*-#{n}.js" }
end end
factory :report_approver_rule, parent: :approval_merge_request_rule do factory :report_approver_rule, parent: :approval_merge_request_rule do
merge_request merge_request
rule_type :report_approver rule_type { :report_approver }
report_type :security report_type { :security }
sequence(:name) { |n| "*-#{n}.js" } sequence(:name) { |n| "*-#{n}.js" }
trait :requires_approval do trait :requires_approval do
...@@ -24,23 +24,23 @@ FactoryBot.define do ...@@ -24,23 +24,23 @@ FactoryBot.define do
end end
trait :license_management do trait :license_management do
name ApprovalRuleLike::DEFAULT_NAME_FOR_LICENSE_REPORT name { ApprovalRuleLike::DEFAULT_NAME_FOR_LICENSE_REPORT }
report_type :license_management report_type { :license_management }
end end
end end
factory :approval_project_rule do factory :approval_project_rule do
project project
sequence(:name) { |n| "#{ApprovalRuleLike::DEFAULT_NAME}-#{n}" } sequence(:name) { |n| "#{ApprovalRuleLike::DEFAULT_NAME}-#{n}" }
rule_type :regular rule_type { :regular }
trait :requires_approval do trait :requires_approval do
approvals_required { rand(1..ApprovalProjectRule::APPROVALS_REQUIRED_MAX) } approvals_required { rand(1..ApprovalProjectRule::APPROVALS_REQUIRED_MAX) }
end end
trait :security_report do trait :security_report do
rule_type :report_approver rule_type { :report_approver }
name ApprovalRuleLike::DEFAULT_NAME_FOR_SECURITY_REPORT name { ApprovalRuleLike::DEFAULT_NAME_FOR_SECURITY_REPORT }
end end
trait :security do trait :security do
...@@ -48,8 +48,8 @@ FactoryBot.define do ...@@ -48,8 +48,8 @@ FactoryBot.define do
end end
trait :license_management do trait :license_management do
name ApprovalRuleLike::DEFAULT_NAME_FOR_LICENSE_REPORT name { ApprovalRuleLike::DEFAULT_NAME_FOR_LICENSE_REPORT }
rule_type :report_approver rule_type { :report_approver }
end end
end end
end end
...@@ -4,7 +4,7 @@ FactoryBot.define do ...@@ -4,7 +4,7 @@ FactoryBot.define do
factory :audit_event, class: 'SecurityEvent', aliases: [:user_audit_event] do factory :audit_event, class: 'SecurityEvent', aliases: [:user_audit_event] do
user user
entity_type 'User' entity_type { 'User' }
entity_id { user.id } entity_id { user.id }
details do details do
{ {
...@@ -21,7 +21,7 @@ FactoryBot.define do ...@@ -21,7 +21,7 @@ FactoryBot.define do
end end
trait :project_event do trait :project_event do
entity_type 'Project' entity_type { 'Project' }
entity_id { create(:project).id } entity_id { create(:project).id }
details do details do
{ {
...@@ -38,7 +38,7 @@ FactoryBot.define do ...@@ -38,7 +38,7 @@ FactoryBot.define do
end end
trait :group_event do trait :group_event do
entity_type 'Group' entity_type { 'Group' }
entity_id { create(:group).id } entity_id { create(:group).id }
details do details do
{ {
......
...@@ -10,7 +10,7 @@ FactoryBot.define do ...@@ -10,7 +10,7 @@ FactoryBot.define do
trait "legacy_#{report_type}".to_sym do trait "legacy_#{report_type}".to_sym do
success success
artifacts artifacts
name report_type name { report_type }
options do options do
{ {
...@@ -29,7 +29,7 @@ FactoryBot.define do ...@@ -29,7 +29,7 @@ FactoryBot.define do
end end
trait :dependency_list do trait :dependency_list do
name :dependency_scanning name { :dependency_scanning }
after(:build) do |build| after(:build) do |build|
build.job_artifacts << build(:ee_ci_job_artifact, :dependency_list, job: build) build.job_artifacts << build(:ee_ci_job_artifact, :dependency_list, job: build)
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
FactoryBot.define do FactoryBot.define do
factory :ee_ci_job_artifact, class: ::Ci::JobArtifact, parent: :ci_job_artifact do factory :ee_ci_job_artifact, class: ::Ci::JobArtifact, parent: :ci_job_artifact do
trait :sast do trait :sast do
file_type :sast file_type { :sast }
file_format :raw file_format { :raw }
after(:build) do |artifact, evaluator| after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -13,8 +13,8 @@ FactoryBot.define do ...@@ -13,8 +13,8 @@ FactoryBot.define do
end end
trait :sast_feature_branch do trait :sast_feature_branch do
file_format :raw file_format { :raw }
file_type :sast file_type { :sast }
after(:build) do |artifact, _| after(:build) do |artifact, _|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -23,8 +23,8 @@ FactoryBot.define do ...@@ -23,8 +23,8 @@ FactoryBot.define do
end end
trait :sast_deprecated do trait :sast_deprecated do
file_type :sast file_type { :sast }
file_format :raw file_format { :raw }
after(:build) do |artifact, evaluator| after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -33,8 +33,8 @@ FactoryBot.define do ...@@ -33,8 +33,8 @@ FactoryBot.define do
end end
trait :sast_with_corrupted_data do trait :sast_with_corrupted_data do
file_type :sast file_type { :sast }
file_format :raw file_format { :raw }
after(:build) do |artifact, evaluator| after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -43,8 +43,8 @@ FactoryBot.define do ...@@ -43,8 +43,8 @@ FactoryBot.define do
end end
trait :license_management do trait :license_management do
file_type :license_management file_type { :license_management }
file_format :raw file_format { :raw }
after(:build) do |artifact, evaluator| after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -53,8 +53,8 @@ FactoryBot.define do ...@@ -53,8 +53,8 @@ FactoryBot.define do
end end
trait :license_management_feature_branch do trait :license_management_feature_branch do
file_type :license_management file_type { :license_management }
file_format :raw file_format { :raw }
after(:build) do |artifact, evaluator| after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -63,8 +63,8 @@ FactoryBot.define do ...@@ -63,8 +63,8 @@ FactoryBot.define do
end end
trait :corrupted_license_management_report do trait :corrupted_license_management_report do
file_type :license_management file_type { :license_management }
file_format :raw file_format { :raw }
after(:build) do |artifact, evaluator| after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -73,8 +73,8 @@ FactoryBot.define do ...@@ -73,8 +73,8 @@ FactoryBot.define do
end end
trait :performance do trait :performance do
file_format :raw file_format { :raw }
file_type :performance file_type { :performance }
after(:build) do |artifact, _| after(:build) do |artifact, _|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -83,8 +83,8 @@ FactoryBot.define do ...@@ -83,8 +83,8 @@ FactoryBot.define do
end end
trait :license_management do trait :license_management do
file_format :raw file_format { :raw }
file_type :license_management file_type { :license_management }
after(:build) do |artifact, _| after(:build) do |artifact, _|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -93,8 +93,8 @@ FactoryBot.define do ...@@ -93,8 +93,8 @@ FactoryBot.define do
end end
trait :dependency_scanning do trait :dependency_scanning do
file_format :raw file_format { :raw }
file_type :dependency_scanning file_type { :dependency_scanning }
after(:build) do |artifact, _| after(:build) do |artifact, _|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -103,8 +103,8 @@ FactoryBot.define do ...@@ -103,8 +103,8 @@ FactoryBot.define do
end end
trait :dependency_scanning_remediation do trait :dependency_scanning_remediation do
file_format :raw file_format { :raw }
file_type :dependency_scanning file_type { :dependency_scanning }
after(:build) do |artifact, _| after(:build) do |artifact, _|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -113,8 +113,8 @@ FactoryBot.define do ...@@ -113,8 +113,8 @@ FactoryBot.define do
end end
trait :dependency_scanning_deprecated do trait :dependency_scanning_deprecated do
file_format :raw file_format { :raw }
file_type :dependency_scanning file_type { :dependency_scanning }
after(:build) do |artifact, _| after(:build) do |artifact, _|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -123,8 +123,8 @@ FactoryBot.define do ...@@ -123,8 +123,8 @@ FactoryBot.define do
end end
trait :dependency_scanning_feature_branch do trait :dependency_scanning_feature_branch do
file_format :raw file_format { :raw }
file_type :dependency_scanning file_type { :dependency_scanning }
after(:build) do |artifact, _| after(:build) do |artifact, _|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -133,8 +133,8 @@ FactoryBot.define do ...@@ -133,8 +133,8 @@ FactoryBot.define do
end end
trait :corrupted_dependency_scanning_report do trait :corrupted_dependency_scanning_report do
file_format :raw file_format { :raw }
file_type :dependency_scanning file_type { :dependency_scanning }
after(:build) do |artifact, evaluator| after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -143,8 +143,8 @@ FactoryBot.define do ...@@ -143,8 +143,8 @@ FactoryBot.define do
end end
trait :container_scanning do trait :container_scanning do
file_format :raw file_format { :raw }
file_type :container_scanning file_type { :container_scanning }
after(:build) do |artifact, _| after(:build) do |artifact, _|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -153,8 +153,8 @@ FactoryBot.define do ...@@ -153,8 +153,8 @@ FactoryBot.define do
end end
trait :container_scanning_feature_branch do trait :container_scanning_feature_branch do
file_format :raw file_format { :raw }
file_type :container_scanning file_type { :container_scanning }
after(:build) do |artifact, _| after(:build) do |artifact, _|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -163,8 +163,8 @@ FactoryBot.define do ...@@ -163,8 +163,8 @@ FactoryBot.define do
end end
trait :corrupted_container_scanning_report do trait :corrupted_container_scanning_report do
file_format :raw file_format { :raw }
file_type :container_scanning file_type { :container_scanning }
after(:build) do |artifact, evaluator| after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -173,8 +173,8 @@ FactoryBot.define do ...@@ -173,8 +173,8 @@ FactoryBot.define do
end end
trait :dast do trait :dast do
file_format :raw file_format { :raw }
file_type :dast file_type { :dast }
after(:build) do |artifact, _| after(:build) do |artifact, _|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -183,8 +183,8 @@ FactoryBot.define do ...@@ -183,8 +183,8 @@ FactoryBot.define do
end end
trait :metrics do trait :metrics do
file_format :gzip file_format { :gzip }
file_type :metrics file_type { :metrics }
after(:build) do |artifact, _| after(:build) do |artifact, _|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -193,8 +193,8 @@ FactoryBot.define do ...@@ -193,8 +193,8 @@ FactoryBot.define do
end end
trait :metrics_alternate do trait :metrics_alternate do
file_format :gzip file_format { :gzip }
file_type :metrics file_type { :metrics }
after(:build) do |artifact, _| after(:build) do |artifact, _|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -203,8 +203,8 @@ FactoryBot.define do ...@@ -203,8 +203,8 @@ FactoryBot.define do
end end
trait :dependency_list do trait :dependency_list do
file_format :raw file_format { :raw }
file_type :dependency_scanning file_type { :dependency_scanning }
after(:build) do |artifact, _| after(:build) do |artifact, _|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
FactoryBot.define do FactoryBot.define do
factory :ee_ci_pipeline, class: Ci::Pipeline, parent: :ci_pipeline do factory :ee_ci_pipeline, class: Ci::Pipeline, parent: :ci_pipeline do
trait :webide do trait :webide do
source :webide source { :webide }
config_source :webide_source config_source { :webide_source }
end end
%i[license_management dependency_list dependency_scanning sast container_scanning].each do |report_type| %i[license_management dependency_list dependency_scanning sast container_scanning].each do |report_type|
trait "with_#{report_type}_report".to_sym do trait "with_#{report_type}_report".to_sym do
status :success status { :success }
after(:build) do |pipeline, evaluator| after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, report_type, :success, pipeline: pipeline, project: pipeline.project) pipeline.builds << build(:ee_ci_build, report_type, :success, pipeline: pipeline, project: pipeline.project)
...@@ -18,7 +18,7 @@ FactoryBot.define do ...@@ -18,7 +18,7 @@ FactoryBot.define do
end end
trait :with_container_scanning_feature_branch do trait :with_container_scanning_feature_branch do
status :success status { :success }
after(:build) do |pipeline, evaluator| after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :container_scanning_feature_branch, pipeline: pipeline, project: pipeline.project) pipeline.builds << build(:ee_ci_build, :container_scanning_feature_branch, pipeline: pipeline, project: pipeline.project)
...@@ -26,7 +26,7 @@ FactoryBot.define do ...@@ -26,7 +26,7 @@ FactoryBot.define do
end end
trait :with_corrupted_container_scanning_report do trait :with_corrupted_container_scanning_report do
status :success status { :success }
after(:build) do |pipeline, evaluator| after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :corrupted_container_scanning_report, pipeline: pipeline, project: pipeline.project) pipeline.builds << build(:ee_ci_build, :corrupted_container_scanning_report, pipeline: pipeline, project: pipeline.project)
...@@ -34,7 +34,7 @@ FactoryBot.define do ...@@ -34,7 +34,7 @@ FactoryBot.define do
end end
trait :with_dependency_scanning_feature_branch do trait :with_dependency_scanning_feature_branch do
status :success status { :success }
after(:build) do |pipeline, evaluator| after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :dependency_scanning_feature_branch, pipeline: pipeline, project: pipeline.project) pipeline.builds << build(:ee_ci_build, :dependency_scanning_feature_branch, pipeline: pipeline, project: pipeline.project)
...@@ -42,7 +42,7 @@ FactoryBot.define do ...@@ -42,7 +42,7 @@ FactoryBot.define do
end end
trait :with_corrupted_dependency_scanning_report do trait :with_corrupted_dependency_scanning_report do
status :success status { :success }
after(:build) do |pipeline, evaluator| after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :corrupted_dependency_scanning_report, pipeline: pipeline, project: pipeline.project) pipeline.builds << build(:ee_ci_build, :corrupted_dependency_scanning_report, pipeline: pipeline, project: pipeline.project)
...@@ -50,7 +50,7 @@ FactoryBot.define do ...@@ -50,7 +50,7 @@ FactoryBot.define do
end end
trait :with_sast_feature_branch do trait :with_sast_feature_branch do
status :success status { :success }
after(:build) do |pipeline, evaluator| after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :sast_feature_branch, pipeline: pipeline, project: pipeline.project) pipeline.builds << build(:ee_ci_build, :sast_feature_branch, pipeline: pipeline, project: pipeline.project)
...@@ -58,7 +58,7 @@ FactoryBot.define do ...@@ -58,7 +58,7 @@ FactoryBot.define do
end end
trait :with_license_management_feature_branch do trait :with_license_management_feature_branch do
status :success status { :success }
after(:build) do |pipeline, evaluator| after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :license_management_feature_branch, pipeline: pipeline, project: pipeline.project) pipeline.builds << build(:ee_ci_build, :license_management_feature_branch, pipeline: pipeline, project: pipeline.project)
...@@ -66,7 +66,7 @@ FactoryBot.define do ...@@ -66,7 +66,7 @@ FactoryBot.define do
end end
trait :with_corrupted_license_management_report do trait :with_corrupted_license_management_report do
status :success status { :success }
after(:build) do |pipeline, evaluator| after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :corrupted_license_management_report, pipeline: pipeline, project: pipeline.project) pipeline.builds << build(:ee_ci_build, :corrupted_license_management_report, pipeline: pipeline, project: pipeline.project)
...@@ -74,7 +74,7 @@ FactoryBot.define do ...@@ -74,7 +74,7 @@ FactoryBot.define do
end end
trait :with_metrics_report do trait :with_metrics_report do
status :success status { :success }
after(:build) do |pipeline, evaluator| after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :metrics, pipeline: pipeline, project: pipeline.project) pipeline.builds << build(:ee_ci_build, :metrics, pipeline: pipeline, project: pipeline.project)
...@@ -82,7 +82,7 @@ FactoryBot.define do ...@@ -82,7 +82,7 @@ FactoryBot.define do
end end
trait :with_metrics_alternate_report do trait :with_metrics_alternate_report do
status :success status { :success }
after(:build) do |pipeline, evaluator| after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ee_ci_build, :metrics_alternate, pipeline: pipeline, project: pipeline.project) pipeline.builds << build(:ee_ci_build, :metrics_alternate, pipeline: pipeline, project: pipeline.project)
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
FactoryBot.define do FactoryBot.define do
factory :ci_reports_security_identifier, class: ::Gitlab::Ci::Reports::Security::Identifier do factory :ci_reports_security_identifier, class: ::Gitlab::Ci::Reports::Security::Identifier do
external_id 'PREDICTABLE_RANDOM' external_id { 'PREDICTABLE_RANDOM' }
external_type 'find_sec_bugs_type' external_type { 'find_sec_bugs_type' }
name { "#{external_type}-#{external_id}" } name { "#{external_type}-#{external_id}" }
skip_create skip_create
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
FactoryBot.define do FactoryBot.define do
factory :ci_reports_security_locations_container_scanning, class: ::Gitlab::Ci::Reports::Security::Locations::ContainerScanning do factory :ci_reports_security_locations_container_scanning, class: ::Gitlab::Ci::Reports::Security::Locations::ContainerScanning do
image 'registry.gitlab.com/my/project:latest' image { 'registry.gitlab.com/my/project:latest' }
operating_system 'debian:9' operating_system { 'debian:9' }
package_name 'glibc' package_name { 'glibc' }
package_version '1.2.3' package_version { '1.2.3' }
skip_create skip_create
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
FactoryBot.define do FactoryBot.define do
factory :ci_reports_security_locations_dast, class: ::Gitlab::Ci::Reports::Security::Locations::Dast do factory :ci_reports_security_locations_dast, class: ::Gitlab::Ci::Reports::Security::Locations::Dast do
hostname 'my-app.com' hostname { 'my-app.com' }
method_name 'GET' method_name { 'GET' }
param 'X-Content-Type-Options' param { 'X-Content-Type-Options' }
path '/some/path' path { '/some/path' }
skip_create skip_create
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
FactoryBot.define do FactoryBot.define do
factory :ci_reports_security_locations_dependency_scanning, class: ::Gitlab::Ci::Reports::Security::Locations::DependencyScanning do factory :ci_reports_security_locations_dependency_scanning, class: ::Gitlab::Ci::Reports::Security::Locations::DependencyScanning do
file_path 'app/pom.xml' file_path { 'app/pom.xml' }
package_name 'io.netty/netty' package_name { 'io.netty/netty' }
package_version '1.2.3' package_version { '1.2.3' }
skip_create skip_create
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
FactoryBot.define do FactoryBot.define do
factory :ci_reports_security_locations_sast, class: ::Gitlab::Ci::Reports::Security::Locations::Sast 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' file_path { 'maven/src/main/java/com/gitlab/security_products/tests/App.java' }
start_line 29 start_line { 29 }
end_line 31 end_line { 31 }
class_name 'com.gitlab.security_products.tests.App' class_name { 'com.gitlab.security_products.tests.App' }
method_name 'insecureCypher' method_name { 'insecureCypher' }
skip_create skip_create
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
FactoryBot.define do FactoryBot.define do
factory :ci_reports_security_occurrence, class: ::Gitlab::Ci::Reports::Security::Occurrence 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}" } 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) } } identifiers { Array.new(1) { FactoryBot.build(:ci_reports_security_identifier) } }
location factory: :ci_reports_security_locations_sast location factory: :ci_reports_security_locations_sast
metadata_version 'sast:1.0' metadata_version { 'sast:1.0' }
name 'Cipher with no integrity' name { 'Cipher with no integrity' }
report_type :sast report_type { :sast }
raw_metadata do raw_metadata do
{ {
description: "The cipher does not provide data integrity update 1", description: "The cipher does not provide data integrity update 1",
...@@ -29,7 +29,7 @@ FactoryBot.define do ...@@ -29,7 +29,7 @@ FactoryBot.define do
}.to_json }.to_json
end end
scanner factory: :ci_reports_security_scanner scanner factory: :ci_reports_security_scanner
severity :high severity { :high }
sequence(:uuid) { generate(:vulnerability_occurrence_uuid) } sequence(:uuid) { generate(:vulnerability_occurrence_uuid) }
skip_create skip_create
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
FactoryBot.define do FactoryBot.define do
factory :ci_reports_security_report, class: ::Gitlab::Ci::Reports::Security::Report do factory :ci_reports_security_report, class: ::Gitlab::Ci::Reports::Security::Report do
type :sast type { :sast }
commit_sha { Digest::SHA1.hexdigest(SecureRandom.hex) } commit_sha { Digest::SHA1.hexdigest(SecureRandom.hex) }
transient do transient do
occurrences [] occurrences { [] }
scanners [] scanners { [] }
identifiers [] identifiers { [] }
end end
after :build do |report, evaluator| after :build do |report, evaluator|
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
FactoryBot.define do FactoryBot.define do
factory :ci_reports_security_scanner, class: ::Gitlab::Ci::Reports::Security::Scanner do factory :ci_reports_security_scanner, class: ::Gitlab::Ci::Reports::Security::Scanner do
external_id 'find_sec_bugs' external_id { 'find_sec_bugs' }
name 'Find Security Bugs' name { 'Find Security Bugs' }
skip_create skip_create
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
FactoryBot.define do FactoryBot.define do
factory :dependency, class: Hash do factory :dependency, class: Hash do
name 'nokogiri' name { 'nokogiri' }
packager 'Ruby (Bundler)' packager { 'Ruby (Bundler)' }
version '1.8.0' version { '1.8.0' }
licenses { [] } licenses { [] }
location do location do
{ {
......
...@@ -3,6 +3,6 @@ FactoryBot.define do ...@@ -3,6 +3,6 @@ FactoryBot.define do
factory :dependency_proxy_blob, class: DependencyProxy::Blob do factory :dependency_proxy_blob, class: DependencyProxy::Blob do
group group
file { fixture_file_upload('ee/spec/fixtures/dependency_proxy/a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4.gz') } file { fixture_file_upload('ee/spec/fixtures/dependency_proxy/a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4.gz') }
file_name 'a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4.gz' file_name { 'a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4.gz' }
end end
end end
...@@ -38,7 +38,7 @@ FactoryBot.define do ...@@ -38,7 +38,7 @@ FactoryBot.define do
with_file with_file
transient do transient do
file Gitlab::Git::LfsPointerFile.new('').pointer file { Gitlab::Git::LfsPointerFile.new('').pointer }
end end
end end
...@@ -46,8 +46,8 @@ FactoryBot.define do ...@@ -46,8 +46,8 @@ FactoryBot.define do
# want to pay for gitlay calls. # want to pay for gitlay calls.
trait :with_versions do trait :with_versions do
transient do transient do
deleted false deleted { false }
versions_count 1 versions_count { 1 }
sequence(:file) { |n| "some-file-content-#{n}" } sequence(:file) { |n| "some-file-content-#{n}" }
end end
...@@ -67,9 +67,9 @@ FactoryBot.define do ...@@ -67,9 +67,9 @@ FactoryBot.define do
# with correctly made commits in the repository and files that can be retrieved. # with correctly made commits in the repository and files that can be retrieved.
trait :with_file do trait :with_file do
transient do transient do
deleted false deleted { false }
versions_count 1 versions_count { 1 }
file File.join(Rails.root, 'spec/fixtures/dk.png') file { File.join(Rails.root, 'spec/fixtures/dk.png') }
end end
after :create do |design, evaluator| after :create do |design, evaluator|
......
...@@ -6,15 +6,15 @@ FactoryBot.define do ...@@ -6,15 +6,15 @@ FactoryBot.define do
issue { designs.first&.issue || create(:issue) } issue { designs.first&.issue || create(:issue) }
transient do transient do
designs_count 1 designs_count { 1 }
created_designs [] created_designs { [] }
modified_designs [] modified_designs { [] }
deleted_designs [] deleted_designs { [] }
end end
# Warning: this will intentionally result in an invalid version! # Warning: this will intentionally result in an invalid version!
trait :empty do trait :empty do
designs_count 0 designs_count { 0 }
end end
after(:build) do |version, evaluator| after(:build) do |version, evaluator|
...@@ -62,7 +62,7 @@ FactoryBot.define do ...@@ -62,7 +62,7 @@ FactoryBot.define do
trait :committed do trait :committed do
transient do transient do
author { create(:user) } author { create(:user) }
file File.join(Rails.root, 'spec/fixtures/dk.png') file { File.join(Rails.root, 'spec/fixtures/dk.png') }
end end
after :create do |version, evaluator| after :create do |version, evaluator|
......
...@@ -4,9 +4,9 @@ FactoryBot.define do ...@@ -4,9 +4,9 @@ FactoryBot.define do
factory :doorkeeper_access_grant, class: Doorkeeper::AccessGrant do factory :doorkeeper_access_grant, class: Doorkeeper::AccessGrant do
sequence(:resource_owner_id) { |n| n } sequence(:resource_owner_id) { |n| n }
association :application, factory: :doorkeeper_application association :application, factory: :doorkeeper_application
redirect_uri 'https://app.com/callback' redirect_uri { 'https://app.com/callback' }
expires_in 100 expires_in { 100 }
scopes 'public write' scopes { 'public write' }
end end
factory :doorkeeper_access_token, class: Doorkeeper::AccessToken do factory :doorkeeper_access_token, class: Doorkeeper::AccessToken do
...@@ -15,12 +15,12 @@ FactoryBot.define do ...@@ -15,12 +15,12 @@ FactoryBot.define do
expires_in { 2.hours } expires_in { 2.hours }
factory :clientless_access_token do factory :clientless_access_token do
application nil application { nil }
end end
end end
factory :doorkeeper_application, class: Doorkeeper::Application do factory :doorkeeper_application, class: Doorkeeper::Application do
sequence(:name) { |n| "Application #{n}" } sequence(:name) { |n| "Application #{n}" }
redirect_uri 'https://app.com/callback' redirect_uri { 'https://app.com/callback' }
end end
end end
...@@ -7,7 +7,7 @@ FactoryBot.define do ...@@ -7,7 +7,7 @@ FactoryBot.define do
factory :draft_note_on_text_diff do factory :draft_note_on_text_diff do
transient do transient do
line_number 14 line_number { 14 }
diff_refs { merge_request.try(:diff_refs) } diff_refs { merge_request.try(:diff_refs) }
end end
......
...@@ -9,24 +9,24 @@ FactoryBot.define do ...@@ -9,24 +9,24 @@ FactoryBot.define do
trait :use_fixed_dates do trait :use_fixed_dates do
start_date { Date.new(2010, 1, 1) } start_date { Date.new(2010, 1, 1) }
start_date_fixed { 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) } end_date { Date.new(2010, 1, 3) }
due_date_fixed { Date.new(2010, 1, 3) } due_date_fixed { Date.new(2010, 1, 3) }
due_date_is_fixed true due_date_is_fixed { true }
end end
trait :opened do trait :opened do
state :opened state { :opened }
end end
trait :closed do trait :closed do
state :closed state { :closed }
closed_at { Time.now } closed_at { Time.now }
end end
factory :labeled_epic do factory :labeled_epic do
transient do transient do
labels [] labels { [] }
end end
after(:create) do |epic, evaluator| after(:create) do |epic, evaluator|
......
...@@ -3,30 +3,30 @@ ...@@ -3,30 +3,30 @@
FactoryBot.define do FactoryBot.define do
factory :container_repository_registry, class: Geo::ContainerRepositoryRegistry do factory :container_repository_registry, class: Geo::ContainerRepositoryRegistry do
container_repository container_repository
last_sync_failure nil last_sync_failure { nil }
last_synced_at nil last_synced_at { nil }
state :pending state { :pending }
trait :started do trait :started do
state :started state { :started }
end end
trait :synced do trait :synced do
state :synced state { :synced }
last_synced_at { 5.days.ago } last_synced_at { 5.days.ago }
end end
trait :sync_failed do trait :sync_failed do
state :failed state { :failed }
last_synced_at { 1.day.ago } last_synced_at { 1.day.ago }
retry_count 2 retry_count { 2 }
last_sync_failure 'Random error' last_sync_failure { 'Random error' }
end end
trait :sync_started do trait :sync_started do
state :started state { :started }
last_synced_at { 1.day.ago } last_synced_at { 1.day.ago }
retry_count 0 retry_count { 0 }
end end
end end
end end
...@@ -63,9 +63,9 @@ FactoryBot.define do ...@@ -63,9 +63,9 @@ FactoryBot.define do
factory :geo_repository_updated_event, class: Geo::RepositoryUpdatedEvent do factory :geo_repository_updated_event, class: Geo::RepositoryUpdatedEvent do
project project
source 0 source { 0 }
branches_affected 0 branches_affected { 0 }
tags_affected 0 tags_affected { 0 }
end end
factory :geo_repository_deleted_event, class: Geo::RepositoryDeletedEvent do factory :geo_repository_deleted_event, class: Geo::RepositoryDeletedEvent do
......
...@@ -3,23 +3,23 @@ ...@@ -3,23 +3,23 @@
FactoryBot.define do FactoryBot.define do
factory :geo_file_registry, class: Geo::FileRegistry do factory :geo_file_registry, class: Geo::FileRegistry do
sequence(:file_id) sequence(:file_id)
file_type :file file_type { :file }
success true success { true }
trait(:attachment) { file_type :attachment } trait(:attachment) { file_type { :attachment } }
trait(:avatar) { file_type :avatar } trait(:avatar) { file_type { :avatar } }
trait(:file) { file_type :file } trait(:file) { file_type { :file } }
trait(:lfs) { file_type :lfs } trait(:lfs) { file_type { :lfs } }
trait(:namespace_file) { file_type :namespace_file } trait(:namespace_file) { file_type { :namespace_file } }
trait(:personal_file) { file_type :personal_file } trait(:personal_file) { file_type { :personal_file } }
trait(:favicon) { file_type :favicon } trait(:favicon) { file_type { :favicon } }
trait(:import_export) { file_type :import_export } trait(:import_export) { file_type { :import_export } }
factory :geo_upload_registry, class: Geo::UploadRegistry factory :geo_upload_registry, class: Geo::UploadRegistry
trait :failed do trait :failed do
success false success { false }
retry_count 1 retry_count { 1 }
end end
trait :with_file do trait :with_file do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
FactoryBot.define do FactoryBot.define do
factory :geo_job_artifact_registry, class: Geo::JobArtifactRegistry do factory :geo_job_artifact_registry, class: Geo::JobArtifactRegistry do
sequence(:artifact_id) sequence(:artifact_id)
success true success { true }
trait :with_artifact do trait :with_artifact do
transient do transient do
......
...@@ -3,26 +3,26 @@ ...@@ -3,26 +3,26 @@
FactoryBot.define do FactoryBot.define do
factory :geo_project_registry, class: Geo::ProjectRegistry do factory :geo_project_registry, class: Geo::ProjectRegistry do
project project
last_repository_synced_at nil last_repository_synced_at { nil }
last_repository_successful_sync_at nil last_repository_successful_sync_at { nil }
last_wiki_synced_at nil last_wiki_synced_at { nil }
last_wiki_successful_sync_at nil last_wiki_successful_sync_at { nil }
resync_repository true resync_repository { true }
resync_wiki true resync_wiki { true }
trait :dirty do trait :dirty do
resync_repository true resync_repository { true }
resync_wiki true resync_wiki { true }
end end
trait :repository_dirty do trait :repository_dirty do
resync_repository true resync_repository { true }
resync_wiki false resync_wiki { false }
end end
trait :wiki_dirty do trait :wiki_dirty do
resync_repository false resync_repository { false }
resync_wiki true resync_wiki { true }
end end
trait :synced do trait :synced do
...@@ -30,27 +30,27 @@ FactoryBot.define do ...@@ -30,27 +30,27 @@ FactoryBot.define do
last_repository_successful_sync_at { 5.days.ago } last_repository_successful_sync_at { 5.days.ago }
last_wiki_synced_at { 5.days.ago } last_wiki_synced_at { 5.days.ago }
last_wiki_successful_sync_at { 5.days.ago } last_wiki_successful_sync_at { 5.days.ago }
resync_repository false resync_repository { false }
resync_wiki false resync_wiki { false }
end end
trait :sync_failed do trait :sync_failed do
last_repository_synced_at { 5.days.ago } 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_synced_at { 5.days.ago }
last_wiki_successful_sync_at nil last_wiki_successful_sync_at { nil }
resync_repository true resync_repository { true }
resync_wiki true resync_wiki { true }
repository_retry_count 1 repository_retry_count { 1 }
wiki_retry_count 1 wiki_retry_count { 1 }
end end
trait :repository_sync_failed do trait :repository_sync_failed do
sync_failed sync_failed
last_wiki_successful_sync_at { 5.days.ago } last_wiki_successful_sync_at { 5.days.ago }
resync_wiki false resync_wiki { false }
wiki_retry_count nil wiki_retry_count { nil }
end end
trait :existing_repository_sync_failed do trait :existing_repository_sync_failed do
...@@ -61,70 +61,70 @@ FactoryBot.define do ...@@ -61,70 +61,70 @@ FactoryBot.define do
trait :repository_syncing do trait :repository_syncing do
repository_sync_failed repository_sync_failed
repository_retry_count 0 repository_retry_count { 0 }
end end
trait :wiki_sync_failed do trait :wiki_sync_failed do
sync_failed sync_failed
last_repository_successful_sync_at { 5.days.ago } last_repository_successful_sync_at { 5.days.ago }
resync_repository false resync_repository { false }
repository_retry_count nil repository_retry_count { nil }
end end
trait :wiki_syncing do trait :wiki_syncing do
wiki_sync_failed wiki_sync_failed
wiki_retry_count 0 wiki_retry_count { 0 }
end end
trait :repository_verified do trait :repository_verified do
repository_verification_checksum_sha 'f079a831cab27bcda7d81cd9b48296d0c3dd92ee' repository_verification_checksum_sha { 'f079a831cab27bcda7d81cd9b48296d0c3dd92ee' }
last_repository_verification_failure nil last_repository_verification_failure { nil }
end end
trait :repository_verification_failed do trait :repository_verification_failed do
repository_verification_checksum_sha nil repository_verification_checksum_sha { nil }
last_repository_verification_failure 'Repository checksum did not match' last_repository_verification_failure { 'Repository checksum did not match' }
end end
trait :repository_checksum_mismatch do trait :repository_checksum_mismatch do
last_repository_verification_failure 'Repository checksum mismatch' last_repository_verification_failure { 'Repository checksum mismatch' }
repository_checksum_mismatch true repository_checksum_mismatch { true }
end end
trait :repository_verification_outdated do trait :repository_verification_outdated do
repository_verification_checksum_sha nil repository_verification_checksum_sha { nil }
last_repository_verification_failure nil last_repository_verification_failure { nil }
end end
trait :repository_retrying_verification do trait :repository_retrying_verification do
repository_verification_retry_count 1 repository_verification_retry_count { 1 }
resync_repository true resync_repository { true }
end end
trait :wiki_verified do trait :wiki_verified do
wiki_verification_checksum_sha 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef' wiki_verification_checksum_sha { 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef' }
last_wiki_verification_failure nil last_wiki_verification_failure { nil }
end end
trait :wiki_verification_failed do trait :wiki_verification_failed do
wiki_verification_checksum_sha nil wiki_verification_checksum_sha { nil }
last_wiki_verification_failure 'Wiki checksum did not match' last_wiki_verification_failure { 'Wiki checksum did not match' }
end end
trait :wiki_checksum_mismatch do trait :wiki_checksum_mismatch do
last_wiki_verification_failure 'Wiki checksum mismatch' last_wiki_verification_failure { 'Wiki checksum mismatch' }
wiki_checksum_mismatch true wiki_checksum_mismatch { true }
end end
trait :wiki_verification_outdated do trait :wiki_verification_outdated do
wiki_verification_checksum_sha nil wiki_verification_checksum_sha { nil }
last_wiki_verification_failure nil last_wiki_verification_failure { nil }
end end
trait :wiki_retrying_verification do trait :wiki_retrying_verification do
wiki_verification_retry_count 1 wiki_verification_retry_count { 1 }
resync_wiki true resync_wiki { true }
end end
end end
end end
...@@ -6,43 +6,43 @@ FactoryBot.define do ...@@ -6,43 +6,43 @@ FactoryBot.define do
storage_shards { StorageShard.all } storage_shards { StorageShard.all }
trait :healthy do trait :healthy do
status_message nil status_message { nil }
attachments_count 329 attachments_count { 329 }
attachments_failed_count 13 attachments_failed_count { 13 }
attachments_synced_count 141 attachments_synced_count { 141 }
attachments_synced_missing_on_primary_count 89 attachments_synced_missing_on_primary_count { 89 }
lfs_objects_count 256 lfs_objects_count { 256 }
lfs_objects_failed_count 12 lfs_objects_failed_count { 12 }
lfs_objects_synced_count 123 lfs_objects_synced_count { 123 }
lfs_objects_synced_missing_on_primary_count 90 lfs_objects_synced_missing_on_primary_count { 90 }
job_artifacts_count 580 job_artifacts_count { 580 }
job_artifacts_failed_count 3 job_artifacts_failed_count { 3 }
job_artifacts_synced_count 577 job_artifacts_synced_count { 577 }
job_artifacts_synced_missing_on_primary_count 91 job_artifacts_synced_missing_on_primary_count { 91 }
container_repositories_count 400 container_repositories_count { 400 }
container_repositories_failed_count 3 container_repositories_failed_count { 3 }
container_repositories_synced_count 200 container_repositories_synced_count { 200 }
projects_count 10 projects_count { 10 }
repositories_synced_count 5 repositories_synced_count { 5 }
repositories_failed_count 0 repositories_failed_count { 0 }
wikis_synced_count 4 wikis_synced_count { 4 }
wikis_failed_count 1 wikis_failed_count { 1 }
repositories_checksummed_count 600 repositories_checksummed_count { 600 }
repositories_checksum_failed_count 120 repositories_checksum_failed_count { 120 }
wikis_checksummed_count 585 wikis_checksummed_count { 585 }
wikis_checksum_failed_count 55 wikis_checksum_failed_count { 55 }
repositories_verified_count 501 repositories_verified_count { 501 }
repositories_verification_failed_count 100 repositories_verification_failed_count { 100 }
repositories_checksum_mismatch_count 15 repositories_checksum_mismatch_count { 15 }
wikis_verified_count 499 wikis_verified_count { 499 }
wikis_verification_failed_count 99 wikis_verification_failed_count { 99 }
wikis_checksum_mismatch_count 10 wikis_checksum_mismatch_count { 10 }
repositories_retrying_verification_count 25 repositories_retrying_verification_count { 25 }
wikis_retrying_verification_count 3 wikis_retrying_verification_count { 3 }
repositories_checked_failed_count 1 repositories_checked_failed_count { 1 }
last_event_id 2 last_event_id { 2 }
last_event_timestamp { Time.now.to_i } 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 } cursor_last_event_timestamp { Time.now.to_i }
last_successful_status_check_timestamp { 2.minutes.ago } last_successful_status_check_timestamp { 2.minutes.ago }
version { Gitlab::VERSION } version { Gitlab::VERSION }
...@@ -50,7 +50,7 @@ FactoryBot.define do ...@@ -50,7 +50,7 @@ FactoryBot.define do
end end
trait :unhealthy do 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 end
end end
...@@ -10,17 +10,17 @@ FactoryBot.define do ...@@ -10,17 +10,17 @@ FactoryBot.define do
"node_name_#{n}" "node_name_#{n}"
end end
primary false primary { false }
sync_object_storage true sync_object_storage { true }
trait :primary do trait :primary do
primary true primary { true }
minimum_reverification_interval 7 minimum_reverification_interval { 7 }
sync_object_storage false sync_object_storage { false }
end end
trait :local_storage_only do trait :local_storage_only do
sync_object_storage false sync_object_storage { false }
end end
end end
end end
...@@ -4,13 +4,13 @@ FactoryBot.define do ...@@ -4,13 +4,13 @@ FactoryBot.define do
factory :gitlab_subscription do factory :gitlab_subscription do
namespace namespace
association :hosted_plan, factory: :gold_plan association :hosted_plan, factory: :gold_plan
seats 10 seats { 10 }
start_date { Date.today } start_date { Date.today }
end_date { Date.today.advance(years: 1) } end_date { Date.today.advance(years: 1) }
trial false trial { false }
trait :free do trait :free do
hosted_plan_id nil hosted_plan_id { nil }
end end
trait :early_adopter do trait :early_adopter do
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :group_saml_identity, class: Identity, parent: :identity do factory :group_saml_identity, class: Identity, parent: :identity do
provider 'group_saml' provider { 'group_saml' }
extern_uid { generate(:username) } extern_uid { generate(:username) }
saml_provider saml_provider
user user
......
...@@ -9,9 +9,9 @@ FactoryBot.define do ...@@ -9,9 +9,9 @@ FactoryBot.define do
factory :group_with_ldap, parent: :group do factory :group_with_ldap, parent: :group do
transient do transient do
cn 'group1' cn { 'group1' }
group_access Gitlab::Access::GUEST group_access { Gitlab::Access::GUEST }
provider 'ldapmain' provider { 'ldapmain' }
end end
factory :group_with_ldap_group_link do factory :group_with_ldap_group_link do
......
...@@ -4,7 +4,7 @@ FactoryBot.modify do ...@@ -4,7 +4,7 @@ FactoryBot.modify do
factory :import_state do factory :import_state do
trait :mirror do trait :mirror do
transient do transient do
mirror true mirror { true }
import_url { generate(:url) } import_url { generate(:url) }
end end
...@@ -32,7 +32,7 @@ FactoryBot.modify do ...@@ -32,7 +32,7 @@ FactoryBot.modify do
end end
trait :hard_failed do trait :hard_failed do
status :failed status { :failed }
retry_count { Gitlab::Mirror::MAX_RETRY + 1 } retry_count { Gitlab::Mirror::MAX_RETRY + 1 }
last_update_at { Time.now - 1.minute } last_update_at { Time.now - 1.minute }
end end
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
FactoryBot.define do FactoryBot.define do
factory :project_incident_management_setting, class: IncidentManagement::ProjectIncidentManagementSetting do factory :project_incident_management_setting, class: IncidentManagement::ProjectIncidentManagementSetting do
project project
create_issue false create_issue { false }
issue_template_key nil issue_template_key { nil }
send_email false send_email { false }
end end
end end
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
FactoryBot.define do FactoryBot.define do
factory :ip_restriction do factory :ip_restriction do
range '192.168.0.0/24' range { '192.168.0.0/24' }
group group
end end
end end
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
FactoryBot.define do FactoryBot.define do
factory :jira_connect_installation do factory :jira_connect_installation do
sequence(:client_key) { |n| "atlassian-client-key-#{n}" } sequence(:client_key) { |n| "atlassian-client-key-#{n}" }
shared_secret 'jrNarHaRYaumMvfV3UnYpwt8' shared_secret { 'jrNarHaRYaumMvfV3UnYpwt8' }
base_url 'https://sample.atlassian.net' base_url { 'https://sample.atlassian.net' }
end end
end end
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
FactoryBot.define do FactoryBot.define do
factory :ldap_group_link do factory :ldap_group_link do
cn 'group1' cn { 'group1' }
group_access Gitlab::Access::GUEST group_access { Gitlab::Access::GUEST }
provider 'ldapmain' provider { 'ldapmain' }
group group
end end
end end
...@@ -5,7 +5,7 @@ FactoryBot.define do ...@@ -5,7 +5,7 @@ FactoryBot.define do
skip_create skip_create
trait :trial do trait :trial do
block_changes_at nil block_changes_at { nil }
restrictions do restrictions do
{ trial: true } { trial: true }
end end
...@@ -16,7 +16,7 @@ FactoryBot.define do ...@@ -16,7 +16,7 @@ FactoryBot.define do
end end
transient do transient do
plan License::STARTER_PLAN plan { License::STARTER_PLAN }
end end
starts_at { Date.today - 1.month } starts_at { Date.today - 1.month }
...@@ -42,9 +42,9 @@ FactoryBot.define do ...@@ -42,9 +42,9 @@ FactoryBot.define do
factory :license do factory :license do
transient do transient do
plan nil plan { nil }
expired false expired { false }
trial false trial { false }
end end
data do data do
......
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
FactoryBot.define do FactoryBot.define do
factory :user_list, parent: :list do factory :user_list, parent: :list do
list_type :assignee list_type { :assignee }
label nil label { nil }
user user
end end
factory :milestone_list, parent: :list do factory :milestone_list, parent: :list do
list_type :milestone list_type { :milestone }
label nil label { nil }
user nil user { nil }
milestone milestone
end end
end end
...@@ -13,8 +13,8 @@ FactoryBot.modify do ...@@ -13,8 +13,8 @@ FactoryBot.modify do
train_creator { author } train_creator { author }
end end
auto_merge_enabled true auto_merge_enabled { true }
auto_merge_strategy AutoMergeService::STRATEGY_MERGE_TRAIN auto_merge_strategy { AutoMergeService::STRATEGY_MERGE_TRAIN }
merge_user { train_creator } merge_user { train_creator }
after :create do |merge_request, evaluator| after :create do |merge_request, evaluator|
...@@ -34,14 +34,14 @@ FactoryBot.modify do ...@@ -34,14 +34,14 @@ FactoryBot.modify do
end end
trait :add_to_merge_train_when_pipeline_succeeds do trait :add_to_merge_train_when_pipeline_succeeds do
auto_merge_enabled true auto_merge_enabled { true }
auto_merge_strategy AutoMergeService::STRATEGY_ADD_TO_MERGE_TRAIN_WHEN_PIPELINE_SUCCEEDS auto_merge_strategy { AutoMergeService::STRATEGY_ADD_TO_MERGE_TRAIN_WHEN_PIPELINE_SUCCEEDS }
merge_user { author } merge_user { author }
end end
trait :with_productivity_metrics do trait :with_productivity_metrics do
transient do transient do
metrics_data {} metrics_data { {} }
end end
after :build do |mr, evaluator| after :build do |mr, evaluator|
...@@ -53,8 +53,8 @@ FactoryBot.modify do ...@@ -53,8 +53,8 @@ FactoryBot.modify do
end end
transient do transient do
approval_groups [] approval_groups { [] }
approval_users [] approval_users { [] }
end end
after :create do |merge_request, evaluator| after :create do |merge_request, evaluator|
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
FactoryBot.define do FactoryBot.define do
factory :merge_train do factory :merge_train do
target_branch 'master' target_branch { 'master' }
target_project factory: :project target_project factory: :project
merge_request merge_request
user user
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
FactoryBot.modify do FactoryBot.modify do
factory :namespace do factory :namespace do
transient do transient do
plan nil plan { nil }
end end
before(:create) do |namespace, evaluator| before(:create) do |namespace, evaluator|
...@@ -17,17 +17,17 @@ FactoryBot.modify do ...@@ -17,17 +17,17 @@ FactoryBot.modify do
end end
trait :with_build_minutes_limit do trait :with_build_minutes_limit do
shared_runners_minutes_limit 500 shared_runners_minutes_limit { 500 }
end end
trait :with_not_used_build_minutes_limit do trait :with_not_used_build_minutes_limit do
namespace_statistics factory: :namespace_statistics, shared_runners_seconds: 300.minutes.to_i namespace_statistics factory: :namespace_statistics, shared_runners_seconds: 300.minutes.to_i
shared_runners_minutes_limit 500 shared_runners_minutes_limit { 500 }
end end
trait :with_used_build_minutes_limit do trait :with_used_build_minutes_limit do
namespace_statistics factory: :namespace_statistics, shared_runners_seconds: 1000.minutes.to_i 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 end
end end
...@@ -4,7 +4,7 @@ FactoryBot.modify do ...@@ -4,7 +4,7 @@ FactoryBot.modify do
factory :note do factory :note do
trait :on_epic do trait :on_epic do
noteable { create(:epic) } noteable { create(:epic) }
project nil project { nil }
end end
trait :with_review do trait :with_review do
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
FactoryBot.define do FactoryBot.define do
factory :operations_feature_flag_scope, class: Operations::FeatureFlagScope do factory :operations_feature_flag_scope, class: Operations::FeatureFlagScope do
association :feature_flag, factory: :operations_feature_flag association :feature_flag, factory: :operations_feature_flag
active true active { true }
strategies [{ name: "default", parameters: {} }] strategies { [{ name: "default", parameters: {} }] }
sequence(:environment_scope) { |n| "review/patch-#{n}" } sequence(:environment_scope) { |n| "review/patch-#{n}" }
end end
end end
...@@ -4,6 +4,6 @@ FactoryBot.define do ...@@ -4,6 +4,6 @@ FactoryBot.define do
factory :operations_feature_flag, class: Operations::FeatureFlag do factory :operations_feature_flag, class: Operations::FeatureFlag do
sequence(:name) { |n| "feature_flag_#{n}" } sequence(:name) { |n| "feature_flag_#{n}" }
project project
active true active { true }
end end
end end
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
FactoryBot.define do FactoryBot.define do
factory :package, class: Packages::Package do factory :package, class: Packages::Package do
project project
name 'my/company/app/my-app' name { 'my/company/app/my-app' }
version '1.0-SNAPSHOT' version { '1.0-SNAPSHOT' }
package_type 'maven' package_type { 'maven' }
factory :maven_package do factory :maven_package do
maven_metadatum maven_metadatum
...@@ -22,8 +22,8 @@ FactoryBot.define do ...@@ -22,8 +22,8 @@ FactoryBot.define do
factory :npm_package do factory :npm_package do
sequence(:name) { |n| "@#{project.root_namespace.path}/package-#{n}"} sequence(:name) { |n| "@#{project.root_namespace.path}/package-#{n}"}
version '1.0.0' version { '1.0.0' }
package_type 'npm' package_type { 'npm' }
after :create do |package| after :create do |package|
create :package_file, :npm, package: package create :package_file, :npm, package: package
...@@ -36,33 +36,33 @@ FactoryBot.define do ...@@ -36,33 +36,33 @@ FactoryBot.define do
trait(:jar) do trait(:jar) do
file { fixture_file_upload('ee/spec/fixtures/maven/my-app-1.0-20180724.124855-1.jar') } 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_name { 'my-app-1.0-20180724.124855-1.jar' }
file_sha1 '4f0bfa298744d505383fbb57c554d4f5c12d88b3' file_sha1 { '4f0bfa298744d505383fbb57c554d4f5c12d88b3' }
file_type 'jar' file_type { 'jar' }
size { 100.kilobytes } size { 100.kilobytes }
end end
trait(:pom) do trait(:pom) do
file { fixture_file_upload('ee/spec/fixtures/maven/my-app-1.0-20180724.124855-1.pom') } 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_name { 'my-app-1.0-20180724.124855-1.pom' }
file_sha1 '19c975abd49e5102ca6c74a619f21e0cf0351c57' file_sha1 { '19c975abd49e5102ca6c74a619f21e0cf0351c57' }
file_type 'pom' file_type { 'pom' }
size { 200.kilobytes } size { 200.kilobytes }
end end
trait(:xml) do trait(:xml) do
file { fixture_file_upload('ee/spec/fixtures/maven/maven-metadata.xml') } file { fixture_file_upload('ee/spec/fixtures/maven/maven-metadata.xml') }
file_name 'maven-metadata.xml' file_name { 'maven-metadata.xml' }
file_sha1 '42b1bdc80de64953b6876f5a8c644f20204011b0' file_sha1 { '42b1bdc80de64953b6876f5a8c644f20204011b0' }
file_type 'xml' file_type { 'xml' }
size { 300.kilobytes } size { 300.kilobytes }
end end
trait(:npm) do trait(:npm) do
file { fixture_file_upload('ee/spec/fixtures/npm/foo-1.0.1.tgz') } file { fixture_file_upload('ee/spec/fixtures/npm/foo-1.0.1.tgz') }
file_name 'foo-1.0.1.tgz' file_name { 'foo-1.0.1.tgz' }
file_sha1 'be93151dc23ac34a82752444556fe79b32c7a1ad' file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' }
file_type 'tgz' file_type { 'tgz' }
size { 400.kilobytes } size { 400.kilobytes }
end end
...@@ -73,9 +73,9 @@ FactoryBot.define do ...@@ -73,9 +73,9 @@ FactoryBot.define do
factory :maven_metadatum, class: Packages::MavenMetadatum do factory :maven_metadatum, class: Packages::MavenMetadatum do
package package
path 'my/company/app/my-app/1.0-SNAPSHOT' path { 'my/company/app/my-app/1.0-SNAPSHOT' }
app_group 'my.company.app' app_group { 'my.company.app' }
app_name 'my-app' app_name { 'my-app' }
app_version '1.0-SNAPSHOT' app_version { '1.0-SNAPSHOT' }
end end
end end
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
FactoryBot.define do FactoryBot.define do
factory :plan do factory :plan do
factory :free_plan do factory :free_plan do
name EE::Namespace::FREE_PLAN name { EE::Namespace::FREE_PLAN }
title { name.titleize } title { name.titleize }
end end
EE::Namespace::PLANS.each do |plan| EE::Namespace::PLANS.each do |plan|
factory :"#{plan}_plan" do factory :"#{plan}_plan" do
name plan name { plan }
title { name.titleize } title { name.titleize }
end end
end end
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
FactoryBot.define do FactoryBot.define do
factory :project_alerting_setting, class: Alerting::ProjectAlertingSetting do factory :project_alerting_setting, class: Alerting::ProjectAlertingSetting do
project project
token 'access_token_123' token { 'access_token_123' }
end end
end end
...@@ -5,47 +5,47 @@ FactoryBot.define do ...@@ -5,47 +5,47 @@ FactoryBot.define do
project project
trait :repository_failed do trait :repository_failed do
repository_verification_checksum nil repository_verification_checksum { nil }
last_repository_verification_ran_at { Time.now } last_repository_verification_ran_at { Time.now }
last_repository_verification_failure 'Could not calculate the checksum' last_repository_verification_failure { 'Could not calculate the checksum' }
repository_retry_count 1 repository_retry_count { 1 }
repository_retry_at { 5.minutes.ago } repository_retry_at { 5.minutes.ago }
end end
trait :repository_outdated do trait :repository_outdated do
repository_verification_checksum nil repository_verification_checksum { nil }
last_repository_verification_ran_at { 1.day.ago } last_repository_verification_ran_at { 1.day.ago }
last_repository_verification_failure nil last_repository_verification_failure { nil }
end end
trait :repository_verified do trait :repository_verified do
repository_verification_checksum 'f079a831cab27bcda7d81cd9b48296d0c3dd92ee' repository_verification_checksum { 'f079a831cab27bcda7d81cd9b48296d0c3dd92ee' }
last_repository_verification_ran_at { 1.day.ago } last_repository_verification_ran_at { 1.day.ago }
last_repository_verification_failure nil last_repository_verification_failure { nil }
repository_retry_count nil repository_retry_count { nil }
repository_retry_at nil repository_retry_at { nil }
end end
trait :wiki_failed do trait :wiki_failed do
wiki_verification_checksum nil wiki_verification_checksum { nil }
last_wiki_verification_ran_at { Time.now } last_wiki_verification_ran_at { Time.now }
last_wiki_verification_failure 'Could not calculate the checksum' last_wiki_verification_failure { 'Could not calculate the checksum' }
wiki_retry_count 1 wiki_retry_count { 1 }
wiki_retry_at { 5.minutes.ago } wiki_retry_at { 5.minutes.ago }
end end
trait :wiki_outdated do trait :wiki_outdated do
wiki_verification_checksum nil wiki_verification_checksum { nil }
last_wiki_verification_ran_at { 1.day.ago } last_wiki_verification_ran_at { 1.day.ago }
last_wiki_verification_failure nil last_wiki_verification_failure { nil }
end end
trait :wiki_verified do trait :wiki_verified do
wiki_verification_checksum 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef' wiki_verification_checksum { 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef' }
last_wiki_verification_ran_at { 1.day.ago } last_wiki_verification_ran_at { 1.day.ago }
last_wiki_verification_failure nil last_wiki_verification_failure { nil }
wiki_retry_count nil wiki_retry_count { nil }
wiki_retry_at nil wiki_retry_at { nil }
end end
end end
end end
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
FactoryBot.define do FactoryBot.define do
factory :project_tracing_setting do factory :project_tracing_setting do
project project
external_url 'https://example.com' external_url { 'https://example.com' }
end end
end end
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
FactoryBot.modify do FactoryBot.modify do
factory :project do factory :project do
transient do transient do
last_update_at nil last_update_at { nil }
last_successful_update_at nil last_successful_update_at { nil }
retry_count 0 retry_count { 0 }
end end
after(:create) do |project, evaluator| after(:create) do |project, evaluator|
...@@ -37,23 +37,23 @@ FactoryBot.modify do ...@@ -37,23 +37,23 @@ FactoryBot.modify do
end end
trait :import_none do trait :import_none do
import_status :none import_status { :none }
end end
trait :import_hard_failed do trait :import_hard_failed do
import_status :failed import_status { :failed }
last_update_at { Time.now - 1.minute } last_update_at { Time.now - 1.minute }
retry_count { Gitlab::Mirror::MAX_RETRY + 1 } retry_count { Gitlab::Mirror::MAX_RETRY + 1 }
end end
trait :disabled_mirror do trait :disabled_mirror do
mirror false mirror { false }
import_url { generate(:url) } import_url { generate(:url) }
mirror_user_id { creator_id } mirror_user_id { creator_id }
end end
trait :mirror do trait :mirror do
mirror true mirror { true }
import_url { generate(:url) } import_url { generate(:url) }
mirror_user_id { creator_id } mirror_user_id { creator_id }
end end
...@@ -63,7 +63,7 @@ FactoryBot.modify do ...@@ -63,7 +63,7 @@ FactoryBot.modify do
end end
trait :requiring_code_owner_approval do trait :requiring_code_owner_approval do
merge_requests_require_code_owner_approval true merge_requests_require_code_owner_approval { true }
end end
trait :jira_dvcs_cloud do trait :jira_dvcs_cloud do
...@@ -79,7 +79,7 @@ FactoryBot.modify do ...@@ -79,7 +79,7 @@ FactoryBot.modify do
end end
trait :service_desk_disabled do trait :service_desk_disabled do
service_desk_enabled nil service_desk_enabled { nil }
end end
trait :github_imported do trait :github_imported do
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
FactoryBot.define do FactoryBot.define do
factory :prometheus_alert do factory :prometheus_alert do
project project
operator :gt operator { :gt }
threshold 1 threshold { 1 }
environment do |alert| environment do |alert|
build(:environment, project: alert.project) build(:environment, project: alert.project)
......
...@@ -11,12 +11,12 @@ FactoryBot.define do ...@@ -11,12 +11,12 @@ FactoryBot.define do
trait :resolved do trait :resolved do
status { PrometheusAlertEvent.status_value_for(:resolved) } status { PrometheusAlertEvent.status_value_for(:resolved) }
ended_at { Time.now } ended_at { Time.now }
payload_key nil payload_key { nil }
end end
trait :none do trait :none do
status nil status { nil }
started_at nil started_at { nil }
end end
end end
end end
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
FactoryBot.modify do FactoryBot.modify do
factory :protected_branch do factory :protected_branch do
transient do transient do
authorize_user_to_push nil authorize_user_to_push { nil }
authorize_user_to_merge nil authorize_user_to_merge { nil }
authorize_user_to_unprotect nil authorize_user_to_unprotect { nil }
authorize_group_to_push nil authorize_group_to_push { nil }
authorize_group_to_merge nil authorize_group_to_merge { nil }
authorize_group_to_unprotect nil authorize_group_to_unprotect { nil }
end end
after(:build) do |protected_branch, evaluator| after(:build) do |protected_branch, evaluator|
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
FactoryBot.define do FactoryBot.define do
factory :protected_branch_merge_access_level, class: ProtectedBranch::MergeAccessLevel do factory :protected_branch_merge_access_level, class: ProtectedBranch::MergeAccessLevel do
user nil user { nil }
group nil group { nil }
protected_branch protected_branch
access_level { Gitlab::Access::DEVELOPER } access_level { Gitlab::Access::DEVELOPER }
end end
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
FactoryBot.define do FactoryBot.define do
factory :protected_branch_push_access_level, class: ProtectedBranch::PushAccessLevel do factory :protected_branch_push_access_level, class: ProtectedBranch::PushAccessLevel do
user nil user { nil }
group nil group { nil }
protected_branch protected_branch
access_level { Gitlab::Access::DEVELOPER } access_level { Gitlab::Access::DEVELOPER }
end end
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
FactoryBot.define do FactoryBot.define do
factory :protected_branch_unprotect_access_level, class: ProtectedBranch::UnprotectAccessLevel do factory :protected_branch_unprotect_access_level, class: ProtectedBranch::UnprotectAccessLevel do
user nil user { nil }
group nil group { nil }
protected_branch protected_branch
access_level { Gitlab::Access::DEVELOPER } access_level { Gitlab::Access::DEVELOPER }
end end
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :protected_environment do factory :protected_environment do
name 'production' name { 'production' }
project project
transient do transient do
authorize_user_to_deploy nil authorize_user_to_deploy { nil }
authorize_group_to_deploy nil authorize_group_to_deploy { nil }
end end
after(:build) do |protected_environment, evaluator| after(:build) do |protected_environment, evaluator|
...@@ -36,7 +36,7 @@ FactoryBot.define do ...@@ -36,7 +36,7 @@ FactoryBot.define do
end end
trait :staging do trait :staging do
name 'staging' name { 'staging' }
end end
end end
end end
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :protected_environment_deploy_access_level, class: ProtectedEnvironment::DeployAccessLevel do factory :protected_environment_deploy_access_level, class: ProtectedEnvironment::DeployAccessLevel do
user nil user { nil }
group nil group { nil }
protected_environment protected_environment
access_level { Gitlab::Access::DEVELOPER } access_level { Gitlab::Access::DEVELOPER }
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
FactoryBot.modify do FactoryBot.modify do
factory :protected_tag do factory :protected_tag do
transient do transient do
authorize_user_to_create nil authorize_user_to_create { nil }
authorize_group_to_create nil authorize_group_to_create { nil }
end end
trait :developers_can_create do trait :developers_can_create do
transient do transient do
default_access_level false default_access_level { false }
end end
after(:build) do |protected_tag| after(:build) do |protected_tag|
...@@ -19,7 +19,7 @@ FactoryBot.modify do ...@@ -19,7 +19,7 @@ FactoryBot.modify do
trait :no_one_can_create do trait :no_one_can_create do
transient do transient do
default_access_level false default_access_level { false }
end end
after(:build) do |protected_tag| after(:build) do |protected_tag|
...@@ -29,7 +29,7 @@ FactoryBot.modify do ...@@ -29,7 +29,7 @@ FactoryBot.modify do
trait :maintainers_can_create do trait :maintainers_can_create do
transient do transient do
default_access_level false default_access_level { false }
end end
after(:build) do |protected_tag| after(:build) do |protected_tag|
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
FactoryBot.define do FactoryBot.define do
factory :protected_tag_create_access_level, class: ProtectedTag::CreateAccessLevel do factory :protected_tag_create_access_level, class: ProtectedTag::CreateAccessLevel do
user nil user { nil }
group nil group { nil }
protected_tag protected_tag
access_level { Gitlab::Access::DEVELOPER } access_level { Gitlab::Access::DEVELOPER }
end end
......
...@@ -4,21 +4,21 @@ ...@@ -4,21 +4,21 @@
FactoryBot.define do FactoryBot.define do
factory :push_rule do factory :push_rule do
force_push_regex 'feature\/.*' force_push_regex { 'feature\/.*' }
deny_delete_tag false deny_delete_tag { false }
delete_branch_regex 'bug\/.*' delete_branch_regex { 'bug\/.*' }
project project
trait :commit_message do trait :commit_message do
commit_message_regex "(f|F)ixes #\d+.*" commit_message_regex { "(f|F)ixes #\d+.*" }
end end
trait :author_email do trait :author_email do
author_email_regex '.*@veryspecificedomain.com' author_email_regex { '.*@veryspecificedomain.com' }
end end
factory :push_rule_sample do factory :push_rule_sample do
is_sample true is_sample { true }
end end
end end
end end
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
FactoryBot.define do FactoryBot.define do
factory :saml_provider do factory :saml_provider do
group group
certificate_fingerprint '55:44:33:22:11:aa:bb:cc:dd:ee:ff:11:22:33:44:55:66:77:88:99' 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' sso_url { 'https://saml.example.com/adfs/ls' }
trait :enforced_group_managed_accounts do trait :enforced_group_managed_accounts do
enabled true enabled { true }
enforced_sso true enforced_sso { true }
enforced_group_managed_accounts true enforced_group_managed_accounts { true }
end end
end end
end end
...@@ -3,17 +3,17 @@ ...@@ -3,17 +3,17 @@
FactoryBot.define do FactoryBot.define do
factory :gitlab_slack_application_service do factory :gitlab_slack_application_service do
project project
active true active { true }
type 'GitlabSlackApplicationService' type { 'GitlabSlackApplicationService' }
end end
factory :alerts_service do factory :alerts_service do
project project
type 'AlertsService' type { 'AlertsService' }
active true active { true }
trait :inactive do trait :inactive do
active false active { false }
end end
end end
end end
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
FactoryBot.define do FactoryBot.define do
factory :software_license_policy, class: SoftwareLicensePolicy do factory :software_license_policy, class: SoftwareLicensePolicy do
approval_status 1 approval_status { 1 }
project project
software_license software_license
trait :blacklist do trait :blacklist do
approval_status :blacklisted approval_status { :blacklisted }
end end
end end
end end
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
FactoryBot.modify do FactoryBot.modify do
factory :user do factory :user do
trait :auditor do trait :auditor do
auditor true auditor { true }
end end
trait :group_managed do trait :group_managed do
...@@ -17,7 +17,7 @@ FactoryBot.modify do ...@@ -17,7 +17,7 @@ FactoryBot.modify do
factory :omniauth_user do factory :omniauth_user do
transient do transient do
saml_provider nil saml_provider { nil }
end end
end end
end end
......
...@@ -10,48 +10,48 @@ FactoryBot.define do ...@@ -10,48 +10,48 @@ FactoryBot.define do
factory :vulnerability_feedback, class: Vulnerabilities::Feedback do factory :vulnerability_feedback, class: Vulnerabilities::Feedback do
project project
author author
issue nil issue { nil }
merge_request nil merge_request { nil }
association :pipeline, factory: :ci_pipeline association :pipeline, factory: :ci_pipeline
feedback_type 'dismissal' feedback_type { 'dismissal' }
category 'sast' category { 'sast' }
project_fingerprint { generate(:project_fingerprint) } project_fingerprint { generate(:project_fingerprint) }
vulnerability_data { { category: 'sast' } } vulnerability_data { { category: 'sast' } }
trait :dismissal do trait :dismissal do
feedback_type 'dismissal' feedback_type { 'dismissal' }
end end
trait :comment do trait :comment do
comment 'a dismissal comment' comment { 'a dismissal comment' }
comment_timestamp { Time.zone.now } comment_timestamp { Time.zone.now }
comment_author { author } comment_author { author }
end end
trait :issue do trait :issue do
feedback_type 'issue' feedback_type { 'issue' }
issue { create(:issue, project: project) } issue { create(:issue, project: project) }
end end
trait :merge_request do trait :merge_request do
feedback_type 'merge_request' feedback_type { 'merge_request' }
merge_request { create(:merge_request, source_project: project) } merge_request { create(:merge_request, source_project: project) }
end end
trait :sast do trait :sast do
category 'sast' category { 'sast' }
end end
trait :dependency_scanning do trait :dependency_scanning do
category 'dependency_scanning' category { 'dependency_scanning' }
end end
trait :container_scanning do trait :container_scanning do
category 'container_scanning' category { 'container_scanning' }
end end
trait :dast do trait :dast do
category 'dast' category { 'dast' }
end end
end end
end end
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
FactoryBot.define do FactoryBot.define do
factory :vulnerabilities_identifier, class: Vulnerabilities::Identifier do factory :vulnerabilities_identifier, class: Vulnerabilities::Identifier do
external_type 'CVE' external_type { 'CVE' }
external_id 'CVE-2018-1234' external_id { 'CVE-2018-1234' }
fingerprint '52d084cede3db8fafcd6b8ae382ddf1970da3b7f' fingerprint { '52d084cede3db8fafcd6b8ae382ddf1970da3b7f' }
name 'CVE-2018-1234' name { 'CVE-2018-1234' }
url 'http://cve.mitre.org/cgi-bin/cvename.cgi?name=2018-1234' url { 'http://cve.mitre.org/cgi-bin/cvename.cgi?name=2018-1234' }
project project
end end
end end
...@@ -6,17 +6,17 @@ FactoryBot.define do ...@@ -6,17 +6,17 @@ FactoryBot.define do
end end
factory :vulnerabilities_occurrence, class: Vulnerabilities::Occurrence do factory :vulnerabilities_occurrence, class: Vulnerabilities::Occurrence do
name 'Cipher with no integrity' name { 'Cipher with no integrity' }
project project
sequence(:uuid) { generate(:vulnerability_occurrence_uuid) } sequence(:uuid) { generate(:vulnerability_occurrence_uuid) }
project_fingerprint { generate(:project_fingerprint) } project_fingerprint { generate(:project_fingerprint) }
primary_identifier factory: :vulnerabilities_identifier primary_identifier factory: :vulnerabilities_identifier
location_fingerprint '4e5b6966dd100170b4b1ad599c7058cce91b57b4' location_fingerprint { '4e5b6966dd100170b4b1ad599c7058cce91b57b4' }
report_type :sast report_type { :sast }
severity :high severity { :high }
confidence :medium confidence { :medium }
scanner factory: :vulnerabilities_scanner scanner factory: :vulnerabilities_scanner
metadata_version 'sast:1.0' metadata_version { 'sast:1.0' }
raw_metadata do raw_metadata do
{ {
description: "The cipher does not provide data integrity update 1", description: "The cipher does not provide data integrity update 1",
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
FactoryBot.define do FactoryBot.define do
factory :vulnerabilities_scanner, class: Vulnerabilities::Scanner do factory :vulnerabilities_scanner, class: Vulnerabilities::Scanner do
external_id 'find_sec_bugs' external_id { 'find_sec_bugs' }
name 'Find Security Bugs' name { 'Find Security Bugs' }
project project
end end
end end
...@@ -6,5 +6,9 @@ RSpec.configure do |config| ...@@ -6,5 +6,9 @@ RSpec.configure do |config|
Rails.root.join('ee', 'spec', 'factories') Rails.root.join('ee', 'spec', 'factories')
] ]
FactoryBot.find_definitions 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
end end
...@@ -4,6 +4,6 @@ FactoryBot.define do ...@@ -4,6 +4,6 @@ FactoryBot.define do
factory :abuse_report do factory :abuse_report do
reporter factory: :user reporter factory: :user
user user
message 'User sends spam' message { 'User sends spam' }
end end
end end
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
FactoryBot.define do FactoryBot.define do
factory :appearance do factory :appearance do
title "GitLab Community Edition" title { "GitLab Community Edition" }
description "Open source software to collaborate on code" description { "Open source software to collaborate on code" }
new_project_guidelines "Custom project guidelines" new_project_guidelines { "Custom project guidelines" }
end end
trait :with_logo do trait :with_logo do
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
FactoryBot.define do FactoryBot.define do
factory :application_setting do factory :application_setting do
default_projects_limit 42 default_projects_limit { 42 }
end end
end end
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
FactoryBot.define do FactoryBot.define do
factory :award_emoji do factory :award_emoji do
name "thumbsup" name { "thumbsup" }
user user
awardable factory: :issue awardable factory: :issue
...@@ -12,7 +12,7 @@ FactoryBot.define do ...@@ -12,7 +12,7 @@ FactoryBot.define do
trait :upvote trait :upvote
trait :downvote do trait :downvote do
name "thumbsdown" name { "thumbsdown" }
end end
end end
end end
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
FactoryBot.define do FactoryBot.define do
factory :board do factory :board do
transient do transient do
project nil project { nil }
group nil group { nil }
project_id nil project_id { nil }
group_id nil group_id { nil }
parent nil parent { nil }
end end
after(:build, :stub) do |board, evaluator| after(:build, :stub) do |board, evaluator|
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
FactoryBot.define do FactoryBot.define do
factory :broadcast_message do factory :broadcast_message do
message "MyText" message { "MyText" }
starts_at { 1.day.ago } starts_at { 1.day.ago }
ends_at { 1.day.from_now } ends_at { 1.day.from_now }
......
...@@ -5,8 +5,8 @@ FactoryBot.define do ...@@ -5,8 +5,8 @@ FactoryBot.define do
user factory: :user user factory: :user
service factory: :service service factory: :service
team_id 'T0001' team_id { 'T0001' }
team_domain 'Awesome Team' team_domain { 'Awesome Team' }
sequence(:chat_id) { |n| "U#{n}" } sequence(:chat_id) { |n| "U#{n}" }
chat_name { generate(:username) } chat_name { generate(:username) }
......
...@@ -2,22 +2,26 @@ ...@@ -2,22 +2,26 @@
FactoryBot.define do FactoryBot.define do
factory :ci_bridge, class: Ci::Bridge do factory :ci_bridge, class: Ci::Bridge do
name 'bridge' name { 'bridge' }
stage 'test' stage { 'test' }
stage_idx 0 stage_idx { 0 }
ref 'master' ref { 'master' }
tag false tag { false }
created_at 'Di 29. Okt 09:50:00 CET 2013' created_at { 'Di 29. Okt 09:50:00 CET 2013' }
status :created status { :created }
pipeline factory: :ci_pipeline pipeline factory: :ci_pipeline
trait :variables do trait :variables do
yaml_variables [{ key: 'BRIDGE', value: 'cross', public: true }] yaml_variables do
[{ key: 'BRIDGE', value: 'cross', public: true }]
end
end end
transient { downstream nil } transient do
transient { upstream nil } downstream { nil }
upstream { nil }
end
after(:build) do |bridge, evaluator| after(:build) do |bridge, evaluator|
bridge.project ||= bridge.pipeline.project bridge.project ||= bridge.pipeline.project
......
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
FactoryBot.define do FactoryBot.define do
factory :ci_build_trace_chunk, class: Ci::BuildTraceChunk do factory :ci_build_trace_chunk, class: Ci::BuildTraceChunk do
build factory: :ci_build build factory: :ci_build
chunk_index 0 chunk_index { 0 }
data_store :redis data_store { :redis }
trait :redis_with_data do trait :redis_with_data do
data_store :redis data_store { :redis }
transient do transient do
initial_data 'test data' initial_data { 'test data' }
end end
after(:create) do |build_trace_chunk, evaluator| after(:create) do |build_trace_chunk, evaluator|
...@@ -19,14 +19,14 @@ FactoryBot.define do ...@@ -19,14 +19,14 @@ FactoryBot.define do
end end
trait :redis_without_data do trait :redis_without_data do
data_store :redis data_store { :redis }
end end
trait :database_with_data do trait :database_with_data do
data_store :database data_store { :database}
transient do transient do
initial_data 'test data' initial_data { 'test data' }
end end
after(:build) do |build_trace_chunk, evaluator| after(:build) do |build_trace_chunk, evaluator|
...@@ -35,14 +35,14 @@ FactoryBot.define do ...@@ -35,14 +35,14 @@ FactoryBot.define do
end end
trait :database_without_data do trait :database_without_data do
data_store :database data_store { :database }
end end
trait :fog_with_data do trait :fog_with_data do
data_store :fog data_store { :fog }
transient do transient do
initial_data 'test data' initial_data { 'test data' }
end end
after(:create) do |build_trace_chunk, evaluator| after(:create) do |build_trace_chunk, evaluator|
...@@ -51,7 +51,7 @@ FactoryBot.define do ...@@ -51,7 +51,7 @@ FactoryBot.define do
end end
trait :fog_without_data do trait :fog_without_data do
data_store :fog data_store { :fog }
end end
end end
end end
...@@ -4,13 +4,13 @@ include ActionDispatch::TestProcess ...@@ -4,13 +4,13 @@ include ActionDispatch::TestProcess
FactoryBot.define do FactoryBot.define do
factory :ci_build, class: Ci::Build do factory :ci_build, class: Ci::Build do
name 'test' name { 'test' }
stage 'test' stage { 'test' }
stage_idx 0 stage_idx { 0 }
ref 'master' ref { 'master' }
tag false tag { false }
protected false add_attribute(:protected) { false }
created_at 'Di 29. Okt 09:50:00 CET 2013' created_at { 'Di 29. Okt 09:50:00 CET 2013' }
pending pending
options do options do
...@@ -30,127 +30,127 @@ FactoryBot.define do ...@@ -30,127 +30,127 @@ FactoryBot.define do
pipeline factory: :ci_pipeline pipeline factory: :ci_pipeline
trait :degenerated do trait :degenerated do
options nil options { nil }
yaml_variables nil yaml_variables { nil }
end end
trait :started do trait :started do
started_at 'Di 29. Okt 09:51:28 CET 2013' started_at { 'Di 29. Okt 09:51:28 CET 2013' }
end end
trait :finished do trait :finished do
started started
finished_at 'Di 29. Okt 09:53:28 CET 2013' finished_at { 'Di 29. Okt 09:53:28 CET 2013' }
end end
trait :success do trait :success do
finished finished
status 'success' status { 'success' }
end end
trait :failed do trait :failed do
finished finished
status 'failed' status { 'failed' }
end end
trait :canceled do trait :canceled do
finished finished
status 'canceled' status { 'canceled' }
end end
trait :skipped do trait :skipped do
started started
status 'skipped' status { 'skipped' }
end end
trait :running do trait :running do
started started
status 'running' status { 'running' }
end end
trait :pending do trait :pending do
queued_at 'Di 29. Okt 09:50:59 CET 2013' queued_at { 'Di 29. Okt 09:50:59 CET 2013' }
status 'pending' status { 'pending' }
end end
trait :created do trait :created do
status 'created' status { 'created' }
end end
trait :preparing do trait :preparing do
status 'preparing' status { 'preparing' }
end end
trait :scheduled do trait :scheduled do
schedulable schedulable
status 'scheduled' status { 'scheduled' }
scheduled_at { 1.minute.since } scheduled_at { 1.minute.since }
end end
trait :expired_scheduled do trait :expired_scheduled do
schedulable schedulable
status 'scheduled' status { 'scheduled' }
scheduled_at { 1.minute.ago } scheduled_at { 1.minute.ago }
end end
trait :manual do trait :manual do
status 'manual' status { 'manual' }
self.when 'manual' self.when { 'manual' }
end end
trait :teardown_environment do trait :teardown_environment do
environment 'staging' environment { 'staging' }
options do options do
{ {
script: %w(ls), script: %w(ls),
environment: { name: 'staging', environment: { name: 'staging',
action: 'stop', action: 'stop',
url: 'http://staging.example.com/$CI_JOB_NAME' } url: 'http://staging.example.com/$CI_JOB_NAME' }
} }
end end
end end
trait :deploy_to_production do trait :deploy_to_production do
environment 'production' environment { 'production' }
options do options do
{ {
script: %w(ls), script: %w(ls),
environment: { name: 'production', environment: { name: 'production',
url: 'http://prd.example.com/$CI_JOB_NAME' } url: 'http://prd.example.com/$CI_JOB_NAME' }
} }
end end
end end
trait :start_review_app do trait :start_review_app do
environment 'review/$CI_COMMIT_REF_NAME' environment { 'review/$CI_COMMIT_REF_NAME' }
options do options do
{ {
script: %w(ls), script: %w(ls),
environment: { name: 'review/$CI_COMMIT_REF_NAME', environment: { name: 'review/$CI_COMMIT_REF_NAME',
url: 'http://staging.example.com/$CI_JOB_NAME', url: 'http://staging.example.com/$CI_JOB_NAME',
on_stop: 'stop_review_app' } on_stop: 'stop_review_app' }
} }
end end
end end
trait :stop_review_app do trait :stop_review_app do
name 'stop_review_app' name { 'stop_review_app' }
environment 'review/$CI_COMMIT_REF_NAME' environment { 'review/$CI_COMMIT_REF_NAME' }
options do options do
{ {
script: %w(ls), script: %w(ls),
environment: { name: 'review/$CI_COMMIT_REF_NAME', environment: { name: 'review/$CI_COMMIT_REF_NAME',
url: 'http://staging.example.com/$CI_JOB_NAME', url: 'http://staging.example.com/$CI_JOB_NAME',
action: 'stop' } action: 'stop' }
} }
end end
end end
trait :allowed_to_fail do trait :allowed_to_fail do
allow_failure true allow_failure { true }
end end
trait :ignored do trait :ignored do
...@@ -166,7 +166,7 @@ FactoryBot.define do ...@@ -166,7 +166,7 @@ FactoryBot.define do
end end
trait :schedulable do trait :schedulable do
self.when 'delayed' self.when { 'delayed' }
options do options do
{ {
...@@ -177,11 +177,11 @@ FactoryBot.define do ...@@ -177,11 +177,11 @@ FactoryBot.define do
end end
trait :actionable do trait :actionable do
self.when 'manual' self.when { 'manual' }
end end
trait :retried do trait :retried do
retried true retried { true }
end end
trait :cancelable do trait :cancelable do
...@@ -194,11 +194,13 @@ FactoryBot.define do ...@@ -194,11 +194,13 @@ FactoryBot.define do
end end
trait :tags do trait :tags do
tag_list [:docker, :ruby] tag_list do
[:docker, :ruby]
end
end end
trait :on_tag do trait :on_tag do
tag true tag { true }
end end
trait :triggered do trait :triggered do
...@@ -210,12 +212,12 @@ FactoryBot.define do ...@@ -210,12 +212,12 @@ FactoryBot.define do
end end
trait :tag do trait :tag do
tag true tag { true }
end end
trait :coverage do trait :coverage do
coverage 99.9 coverage { 99.9 }
coverage_regex '/(d+)/' coverage_regex { '/(d+)/' }
end end
trait :trace_live do trait :trace_live do
...@@ -303,23 +305,23 @@ FactoryBot.define do ...@@ -303,23 +305,23 @@ FactoryBot.define do
trait :extended_options do trait :extended_options do
options do options do
{ {
image: { name: 'ruby:2.1', entrypoint: '/bin/sh' }, image: { name: 'ruby:2.1', entrypoint: '/bin/sh' },
services: ['postgres', { name: 'docker:stable-dind', entrypoint: '/bin/sh', command: 'sleep 30', alias: 'docker' }], services: ['postgres', { name: 'docker:stable-dind', entrypoint: '/bin/sh', command: 'sleep 30', alias: 'docker' }],
script: %w(echo), script: %w(echo),
after_script: %w(ls date), after_script: %w(ls date),
artifacts: { artifacts: {
name: 'artifacts_file', name: 'artifacts_file',
untracked: false, untracked: false,
paths: ['out/'], paths: ['out/'],
when: 'always', when: 'always',
expire_in: '7d' expire_in: '7d'
}, },
cache: { cache: {
key: 'cache_key', key: 'cache_key',
untracked: false, untracked: false,
paths: ['vendor/*'], paths: ['vendor/*'],
policy: 'pull-push' policy: 'pull-push'
} }
} }
end end
end end
...@@ -329,27 +331,27 @@ FactoryBot.define do ...@@ -329,27 +331,27 @@ FactoryBot.define do
end end
trait :non_playable do trait :non_playable do
status 'created' status { 'created' }
self.when 'manual' self.when { 'manual' }
end end
trait :protected do trait :protected do
protected true add_attribute(:protected) { true }
end end
trait :script_failure do trait :script_failure do
failed failed
failure_reason 1 failure_reason { 1 }
end end
trait :api_failure do trait :api_failure do
failed failed
failure_reason 2 failure_reason { 2 }
end end
trait :prerequisite_failure do trait :prerequisite_failure do
failed failed
failure_reason 10 failure_reason { 10 }
end end
trait :with_runner_session do trait :with_runner_session do
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
FactoryBot.define do FactoryBot.define do
factory :ci_group_variable, class: Ci::GroupVariable do factory :ci_group_variable, class: Ci::GroupVariable do
sequence(:key) { |n| "VARIABLE_#{n}" } sequence(:key) { |n| "VARIABLE_#{n}" }
value 'VARIABLE_VALUE' value { 'VARIABLE_VALUE' }
masked false masked { false }
trait(:protected) do trait(:protected) do
protected true add_attribute(:protected) { true }
end end
group factory: :group group factory: :group
......
...@@ -5,15 +5,15 @@ include ActionDispatch::TestProcess ...@@ -5,15 +5,15 @@ include ActionDispatch::TestProcess
FactoryBot.define do FactoryBot.define do
factory :ci_job_artifact, class: Ci::JobArtifact do factory :ci_job_artifact, class: Ci::JobArtifact do
job factory: :ci_build job factory: :ci_build
file_type :archive file_type { :archive }
file_format :zip file_format { :zip }
trait :expired do trait :expired do
expire_at { Date.yesterday } expire_at { Date.yesterday }
end end
trait :remote_store do trait :remote_store do
file_store JobArtifactUploader::Store::REMOTE file_store { JobArtifactUploader::Store::REMOTE}
end end
after :build do |artifact| after :build do |artifact|
...@@ -21,7 +21,7 @@ FactoryBot.define do ...@@ -21,7 +21,7 @@ FactoryBot.define do
end end
trait :raw do trait :raw do
file_format :raw file_format { :raw }
after(:build) do |artifact, _| after(:build) do |artifact, _|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -30,7 +30,7 @@ FactoryBot.define do ...@@ -30,7 +30,7 @@ FactoryBot.define do
end end
trait :zip do trait :zip do
file_format :zip file_format { :zip }
after(:build) do |artifact, _| after(:build) do |artifact, _|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -39,7 +39,7 @@ FactoryBot.define do ...@@ -39,7 +39,7 @@ FactoryBot.define do
end end
trait :gzip do trait :gzip do
file_format :gzip file_format { :gzip }
after(:build) do |artifact, _| after(:build) do |artifact, _|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -48,8 +48,8 @@ FactoryBot.define do ...@@ -48,8 +48,8 @@ FactoryBot.define do
end end
trait :archive do trait :archive do
file_type :archive file_type { :archive }
file_format :zip file_format { :zip }
transient do transient do
file { fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), 'application/zip') } file { fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), 'application/zip') }
...@@ -63,12 +63,12 @@ FactoryBot.define do ...@@ -63,12 +63,12 @@ FactoryBot.define do
trait :legacy_archive do trait :legacy_archive do
archive archive
file_location :legacy_path file_location { :legacy_path }
end end
trait :metadata do trait :metadata do
file_type :metadata file_type { :metadata }
file_format :gzip file_format { :gzip }
transient do transient do
file { fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'), 'application/x-gzip') } file { fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'), 'application/x-gzip') }
...@@ -80,8 +80,8 @@ FactoryBot.define do ...@@ -80,8 +80,8 @@ FactoryBot.define do
end end
trait :trace do trait :trace do
file_type :trace file_type { :trace }
file_format :raw file_format { :raw }
after(:build) do |artifact, evaluator| after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -90,8 +90,8 @@ FactoryBot.define do ...@@ -90,8 +90,8 @@ FactoryBot.define do
end end
trait :junit do trait :junit do
file_type :junit file_type { :junit }
file_format :gzip file_format { :gzip }
after(:build) do |artifact, evaluator| after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -100,8 +100,8 @@ FactoryBot.define do ...@@ -100,8 +100,8 @@ FactoryBot.define do
end end
trait :junit_with_ant do trait :junit_with_ant do
file_type :junit file_type { :junit }
file_format :gzip file_format { :gzip }
after(:build) do |artifact, evaluator| after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -110,8 +110,8 @@ FactoryBot.define do ...@@ -110,8 +110,8 @@ FactoryBot.define do
end end
trait :junit_with_three_testsuites do trait :junit_with_three_testsuites do
file_type :junit file_type { :junit }
file_format :gzip file_format { :gzip }
after(:build) do |artifact, evaluator| after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -120,8 +120,8 @@ FactoryBot.define do ...@@ -120,8 +120,8 @@ FactoryBot.define do
end end
trait :junit_with_corrupted_data do trait :junit_with_corrupted_data do
file_type :junit file_type { :junit }
file_format :gzip file_format { :gzip }
after(:build) do |artifact, evaluator| after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
...@@ -130,8 +130,8 @@ FactoryBot.define do ...@@ -130,8 +130,8 @@ FactoryBot.define do
end end
trait :codequality do trait :codequality do
file_type :codequality file_type { :codequality }
file_format :raw file_format { :raw }
after(:build) do |artifact, evaluator| after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload( artifact.file = fixture_file_upload(
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
FactoryBot.define do FactoryBot.define do
factory :ci_job_variable, class: Ci::JobVariable do factory :ci_job_variable, class: Ci::JobVariable do
sequence(:key) { |n| "VARIABLE_#{n}" } sequence(:key) { |n| "VARIABLE_#{n}" }
value 'VARIABLE_VALUE' value { 'VARIABLE_VALUE' }
job factory: :ci_build job factory: :ci_build
end end
......
...@@ -2,40 +2,40 @@ ...@@ -2,40 +2,40 @@
FactoryBot.define do FactoryBot.define do
factory :ci_pipeline_schedule, class: Ci::PipelineSchedule do factory :ci_pipeline_schedule, class: Ci::PipelineSchedule do
cron '0 1 * * *' cron { '0 1 * * *' }
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE cron_timezone { Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE }
ref 'master' ref { 'master' }
active true active { true }
description "pipeline schedule" description { "pipeline schedule" }
project project
trait :every_minute do trait :every_minute do
cron '*/1 * * * *' cron { '*/1 * * * *' }
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE cron_timezone { Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE }
end end
trait :hourly do trait :hourly do
cron '* */1 * * *' cron { '* */1 * * *' }
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE cron_timezone { Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE }
end end
trait :nightly do trait :nightly do
cron '0 1 * * *' cron { '0 1 * * *' }
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE cron_timezone { Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE }
end end
trait :weekly do trait :weekly do
cron '0 1 * * 6' cron { '0 1 * * 6' }
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE cron_timezone { Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE }
end end
trait :monthly do trait :monthly do
cron '0 1 22 * *' cron { '0 1 22 * *' }
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE cron_timezone { Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE }
end end
trait :inactive do trait :inactive do
active false active { false }
end end
end end
end end
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
FactoryBot.define do FactoryBot.define do
factory :ci_pipeline_schedule_variable, class: Ci::PipelineScheduleVariable do factory :ci_pipeline_schedule_variable, class: Ci::PipelineScheduleVariable do
sequence(:key) { |n| "VARIABLE_#{n}" } sequence(:key) { |n| "VARIABLE_#{n}" }
value 'VARIABLE_VALUE' value { 'VARIABLE_VALUE' }
variable_type 'env_var' variable_type { 'env_var' }
pipeline_schedule factory: :ci_pipeline_schedule pipeline_schedule factory: :ci_pipeline_schedule
end end
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
FactoryBot.define do FactoryBot.define do
factory :ci_pipeline_variable, class: Ci::PipelineVariable do factory :ci_pipeline_variable, class: Ci::PipelineVariable do
sequence(:key) { |n| "VARIABLE_#{n}" } sequence(:key) { |n| "VARIABLE_#{n}" }
value 'VARIABLE_VALUE' value { 'VARIABLE_VALUE' }
pipeline factory: :ci_empty_pipeline pipeline factory: :ci_empty_pipeline
end end
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
FactoryBot.define do FactoryBot.define do
factory :ci_empty_pipeline, class: Ci::Pipeline do factory :ci_empty_pipeline, class: Ci::Pipeline do
source :push source { :push }
ref 'master' ref { 'master' }
sha '97de212e80737a608d939f648d959671fb0a0142' sha { '97de212e80737a608d939f648d959671fb0a0142' }
status 'pending' status { 'pending' }
protected false add_attribute(:protected) { false }
project project
...@@ -26,7 +26,7 @@ FactoryBot.define do ...@@ -26,7 +26,7 @@ FactoryBot.define do
# Persist merge request head_pipeline_id # Persist merge request head_pipeline_id
# on pipeline factories to avoid circular references # on pipeline factories to avoid circular references
transient { head_pipeline_of nil } transient { head_pipeline_of { nil } }
after(:create) do |pipeline, evaluator| after(:create) do |pipeline, evaluator|
merge_request = evaluator.head_pipeline_of merge_request = evaluator.head_pipeline_of
...@@ -34,7 +34,7 @@ FactoryBot.define do ...@@ -34,7 +34,7 @@ FactoryBot.define do
end end
factory :ci_pipeline do factory :ci_pipeline do
transient { config nil } transient { config { nil } }
after(:build) do |pipeline, evaluator| after(:build) do |pipeline, evaluator|
if evaluator.config if evaluator.config
...@@ -48,44 +48,47 @@ FactoryBot.define do ...@@ -48,44 +48,47 @@ FactoryBot.define do
end end
trait :invalid do trait :invalid do
config(rspec: nil) config do
failure_reason :config_error { rspec: nil }
end
failure_reason { :config_error }
end end
trait :created do trait :created do
status :created status { :created }
end end
trait :preparing do trait :preparing do
status :preparing status { :preparing }
end end
trait :blocked do trait :blocked do
status :manual status { :manual }
end end
trait :scheduled do trait :scheduled do
status :scheduled status { :scheduled }
end end
trait :success do trait :success do
status :success status { :success }
end end
trait :running do trait :running do
status :running status { :running }
end end
trait :failed do trait :failed do
status :failed status { :failed }
end end
trait :protected do trait :protected do
protected true add_attribute(:protected) { true }
end end
trait :with_test_reports do trait :with_test_reports do
status :success status { :success }
after(:build) do |pipeline, evaluator| after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ci_build, :test_reports, pipeline: pipeline, project: pipeline.project) pipeline.builds << build(:ci_build, :test_reports, pipeline: pipeline, project: pipeline.project)
......
...@@ -4,22 +4,22 @@ FactoryBot.define do ...@@ -4,22 +4,22 @@ FactoryBot.define do
factory :ci_runner, class: Ci::Runner do factory :ci_runner, class: Ci::Runner do
sequence(:description) { |n| "My runner#{n}" } sequence(:description) { |n| "My runner#{n}" }
platform "darwin" platform { "darwin" }
active true active { true }
access_level :not_protected access_level { :not_protected }
runner_type :instance_type runner_type { :instance_type }
trait :online do trait :online do
contacted_at { Time.now } contacted_at { Time.now }
end end
trait :instance do trait :instance do
runner_type :instance_type runner_type { :instance_type }
end end
trait :group do trait :group do
runner_type :group_type runner_type { :group_type }
after(:build) do |runner, evaluator| after(:build) do |runner, evaluator|
runner.groups << build(:group) if runner.groups.empty? runner.groups << build(:group) if runner.groups.empty?
...@@ -27,7 +27,7 @@ FactoryBot.define do ...@@ -27,7 +27,7 @@ FactoryBot.define do
end end
trait :project do trait :project do
runner_type :project_type runner_type { :project_type }
after(:build) do |runner, evaluator| after(:build) do |runner, evaluator|
runner.projects << build(:project) if runner.projects.empty? runner.projects << build(:project) if runner.projects.empty?
...@@ -43,21 +43,21 @@ FactoryBot.define do ...@@ -43,21 +43,21 @@ FactoryBot.define do
end end
trait :inactive do trait :inactive do
active false active { false }
end end
trait :ref_protected do trait :ref_protected do
access_level :ref_protected access_level { :ref_protected }
end end
trait :tagged_only do trait :tagged_only do
run_untagged false run_untagged { false }
tag_list %w(tag1 tag2) tag_list { %w(tag1 tag2) }
end end
trait :locked do trait :locked do
locked true locked { true }
end end
end end
end end
...@@ -5,16 +5,16 @@ FactoryBot.define do ...@@ -5,16 +5,16 @@ FactoryBot.define do
skip_create skip_create
transient do transient do
name 'test' name { 'test' }
status nil status { nil }
warnings nil warnings { nil }
pipeline factory: :ci_empty_pipeline pipeline factory: :ci_empty_pipeline
end end
initialize_with do initialize_with do
Ci::LegacyStage.new(pipeline, name: name, Ci::LegacyStage.new(pipeline, name: name,
status: status, status: status,
warnings: warnings) warnings: warnings)
end end
end end
...@@ -22,8 +22,8 @@ FactoryBot.define do ...@@ -22,8 +22,8 @@ FactoryBot.define do
project factory: :project project factory: :project
pipeline factory: :ci_empty_pipeline pipeline factory: :ci_empty_pipeline
name 'test' name { 'test' }
position 1 position { 1 }
status 'pending' status { 'pending' }
end end
end end
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
FactoryBot.define do FactoryBot.define do
factory :ci_variable, class: Ci::Variable do factory :ci_variable, class: Ci::Variable do
sequence(:key) { |n| "VARIABLE_#{n}" } sequence(:key) { |n| "VARIABLE_#{n}" }
value 'VARIABLE_VALUE' value { 'VARIABLE_VALUE' }
masked false masked { false }
trait(:protected) do trait(:protected) do
protected true add_attribute(:protected) { true }
end end
project project
......
...@@ -19,50 +19,50 @@ FactoryBot.define do ...@@ -19,50 +19,50 @@ FactoryBot.define do
end end
trait :not_installable do trait :not_installable do
status(-2) status { -2 }
end end
trait :errored do trait :errored do
status(-1) status { -1 }
status_reason 'something went wrong' status_reason { 'something went wrong' }
end end
trait :installable do trait :installable do
status 0 status { 0 }
end end
trait :scheduled do trait :scheduled do
status 1 status { 1 }
end end
trait :installing do trait :installing do
status 2 status { 2 }
end end
trait :installed do trait :installed do
status 3 status { 3 }
end end
trait :updating do trait :updating do
status 4 status { 4 }
end end
trait :updated do trait :updated do
status 5 status { 5 }
end end
trait :update_errored do trait :update_errored do
status(6) status { 6 }
status_reason 'something went wrong' status_reason { 'something went wrong' }
end end
trait :uninstalling do trait :uninstalling do
status 7 status { 7 }
end end
trait :uninstall_errored do trait :uninstall_errored do
status(8) status { 8 }
status_reason 'something went wrong' status_reason { 'something went wrong' }
end end
trait :timed_out do trait :timed_out do
...@@ -75,7 +75,7 @@ FactoryBot.define do ...@@ -75,7 +75,7 @@ FactoryBot.define do
end end
factory :clusters_applications_cert_manager, class: Clusters::Applications::CertManager do 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) cluster factory: %i(cluster with_installed_helm provided_by_gcp)
end end
...@@ -89,7 +89,7 @@ FactoryBot.define do ...@@ -89,7 +89,7 @@ FactoryBot.define do
end end
factory :clusters_applications_knative, class: Clusters::Applications::Knative do 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) cluster factory: %i(cluster with_installed_helm provided_by_gcp)
end end
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
FactoryBot.define do FactoryBot.define do
factory :cluster, class: Clusters::Cluster do factory :cluster, class: Clusters::Cluster do
user user
name 'test-cluster' name { 'test-cluster' }
cluster_type :project_type cluster_type { :project_type }
managed true managed { true }
namespace_per_environment true namespace_per_environment { true }
factory :cluster_for_group, traits: [:provided_by_gcp, :group] factory :cluster_for_group, traits: [:provided_by_gcp, :group]
...@@ -31,26 +31,26 @@ FactoryBot.define do ...@@ -31,26 +31,26 @@ FactoryBot.define do
end end
trait :namespace_per_environment_disabled do trait :namespace_per_environment_disabled do
namespace_per_environment false namespace_per_environment { false }
end end
trait :provided_by_user do trait :provided_by_user do
provider_type :user provider_type { :user }
platform_type :kubernetes platform_type { :kubernetes }
platform_kubernetes factory: [:cluster_platform_kubernetes, :configured] platform_kubernetes factory: [:cluster_platform_kubernetes, :configured]
end end
trait :provided_by_gcp do trait :provided_by_gcp do
provider_type :gcp provider_type { :gcp }
platform_type :kubernetes platform_type { :kubernetes }
provider_gcp factory: [:cluster_provider_gcp, :created] provider_gcp factory: [:cluster_provider_gcp, :created]
platform_kubernetes factory: [:cluster_platform_kubernetes, :configured] platform_kubernetes factory: [:cluster_platform_kubernetes, :configured]
end end
trait :providing_by_gcp do trait :providing_by_gcp do
provider_type :gcp provider_type { :gcp }
provider_gcp factory: [:cluster_provider_gcp, :creating] provider_gcp factory: [:cluster_provider_gcp, :creating]
end end
...@@ -63,7 +63,7 @@ FactoryBot.define do ...@@ -63,7 +63,7 @@ FactoryBot.define do
end end
trait :disabled do trait :disabled do
enabled false enabled { false }
end end
trait :production_environment do trait :production_environment do
...@@ -75,11 +75,11 @@ FactoryBot.define do ...@@ -75,11 +75,11 @@ FactoryBot.define do
end end
trait :with_domain do trait :with_domain do
domain 'example.com' domain { 'example.com' }
end end
trait :not_managed do trait :not_managed do
managed false managed { false }
end end
end end
end end
...@@ -27,7 +27,7 @@ FactoryBot.define do ...@@ -27,7 +27,7 @@ FactoryBot.define do
end end
trait :without_token do trait :without_token do
service_account_token nil service_account_token { nil }
end end
end end
end end
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
FactoryBot.define do FactoryBot.define do
factory :cluster_platform_kubernetes, class: Clusters::Platforms::Kubernetes do factory :cluster_platform_kubernetes, class: Clusters::Platforms::Kubernetes do
cluster cluster
namespace nil namespace { nil }
api_url 'https://kubernetes.example.com' api_url { 'https://kubernetes.example.com' }
token { 'a' * 40 } token { 'a' * 40 }
trait :configured do trait :configured do
api_url 'https://kubernetes.example.com' api_url { 'https://kubernetes.example.com' }
username 'xxxxxx' username { 'xxxxxx' }
password 'xxxxxx' password { 'xxxxxx' }
before(:create) do |platform_kubernetes, evaluator| before(:create) do |platform_kubernetes, evaluator|
pem_file = File.expand_path(Rails.root.join('spec/fixtures/clusters/sample_cert.pem')) pem_file = File.expand_path(Rails.root.join('spec/fixtures/clusters/sample_cert.pem'))
...@@ -19,7 +19,7 @@ FactoryBot.define do ...@@ -19,7 +19,7 @@ FactoryBot.define do
end end
trait :rbac_disabled do trait :rbac_disabled do
authorization_type :abac authorization_type { :abac }
end end
end end
end end
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
FactoryBot.define do FactoryBot.define do
factory :cluster_provider_gcp, class: Clusters::Providers::Gcp do factory :cluster_provider_gcp, class: Clusters::Providers::Gcp do
cluster cluster
gcp_project_id 'test-gcp-project' gcp_project_id { 'test-gcp-project' }
trait :scheduled do trait :scheduled do
access_token 'access_token_123' access_token { 'access_token_123' }
end end
trait :creating do trait :creating do
access_token 'access_token_123' access_token { 'access_token_123' }
after(:build) do |gcp, evaluator| after(:build) do |gcp, evaluator|
gcp.make_creating('operation-123') gcp.make_creating('operation-123')
...@@ -18,7 +18,7 @@ FactoryBot.define do ...@@ -18,7 +18,7 @@ FactoryBot.define do
end end
trait :created do trait :created do
endpoint '111.111.111.111' endpoint { '111.111.111.111' }
after(:build) do |gcp, evaluator| after(:build) do |gcp, evaluator|
gcp.make_created gcp.make_created
...@@ -32,11 +32,11 @@ FactoryBot.define do ...@@ -32,11 +32,11 @@ FactoryBot.define do
end end
trait :abac_enabled do trait :abac_enabled do
legacy_abac true legacy_abac { true }
end end
trait :cloud_run_enabled do trait :cloud_run_enabled do
cloud_run true cloud_run { true }
end end
end end
end end
...@@ -2,53 +2,53 @@ ...@@ -2,53 +2,53 @@
FactoryBot.define do FactoryBot.define do
factory :commit_status, class: CommitStatus do factory :commit_status, class: CommitStatus do
name 'default' name { 'default' }
stage 'test' stage { 'test' }
stage_idx 0 stage_idx { 0 }
status 'success' status { 'success' }
description 'commit status' description { 'commit status'}
pipeline factory: :ci_pipeline_with_one_job pipeline factory: :ci_pipeline_with_one_job
started_at 'Tue, 26 Jan 2016 08:21:42 +0100' started_at { 'Tue, 26 Jan 2016 08:21:42 +0100'}
finished_at 'Tue, 26 Jan 2016 08:23:42 +0100' finished_at { 'Tue, 26 Jan 2016 08:23:42 +0100'}
trait :success do trait :success do
status 'success' status { 'success' }
end end
trait :failed do trait :failed do
status 'failed' status { 'failed' }
end end
trait :canceled do trait :canceled do
status 'canceled' status { 'canceled' }
end end
trait :skipped do trait :skipped do
status 'skipped' status { 'skipped' }
end end
trait :running do trait :running do
status 'running' status { 'running' }
end end
trait :pending do trait :pending do
status 'pending' status { 'pending' }
end end
trait :preparing do trait :preparing do
status 'preparing' status { 'preparing' }
end end
trait :created do trait :created do
status 'created' status { 'created' }
end end
trait :manual do trait :manual do
status 'manual' status { 'manual' }
end end
trait :scheduled do trait :scheduled do
status 'scheduled' status { 'scheduled' }
end end
after(:build) do |build, evaluator| after(:build) do |build, evaluator|
...@@ -56,8 +56,8 @@ FactoryBot.define do ...@@ -56,8 +56,8 @@ FactoryBot.define do
end end
factory :generic_commit_status, class: GenericCommitStatus do factory :generic_commit_status, class: GenericCommitStatus do
name 'generic' name { 'generic' }
description 'external commit status' description { 'external commit status' }
end end
end end
end end
...@@ -5,7 +5,7 @@ require_relative '../support/helpers/repo_helpers' ...@@ -5,7 +5,7 @@ require_relative '../support/helpers/repo_helpers'
FactoryBot.define do FactoryBot.define do
factory :commit do factory :commit do
transient do transient do
author nil author { nil }
end end
git_commit do git_commit do
......
...@@ -6,11 +6,11 @@ FactoryBot.define do ...@@ -6,11 +6,11 @@ FactoryBot.define do
project project
transient do transient do
tags [] tags { [] }
end end
trait :root do trait :root do
name '' name { '' }
end end
after(:build) do |repository, evaluator| after(:build) do |repository, evaluator|
......
...@@ -2,44 +2,44 @@ ...@@ -2,44 +2,44 @@
FactoryBot.define do FactoryBot.define do
factory :conversational_development_index_metric, class: ConversationalDevelopmentIndex::Metric do factory :conversational_development_index_metric, class: ConversationalDevelopmentIndex::Metric do
leader_issues 9.256 leader_issues { 9.256 }
instance_issues 1.234 instance_issues { 1.234 }
percentage_issues 13.331 percentage_issues { 13.331 }
leader_notes 30.33333 leader_notes { 30.33333 }
instance_notes 28.123 instance_notes { 28.123 }
percentage_notes 92.713 percentage_notes { 92.713 }
leader_milestones 16.2456 leader_milestones { 16.2456 }
instance_milestones 1.234 instance_milestones { 1.234 }
percentage_milestones 7.595 percentage_milestones { 7.595 }
leader_boards 5.2123 leader_boards { 5.2123 }
instance_boards 3.254 instance_boards { 3.254 }
percentage_boards 62.429 percentage_boards { 62.429 }
leader_merge_requests 1.2 leader_merge_requests { 1.2 }
instance_merge_requests 0.6 instance_merge_requests { 0.6 }
percentage_merge_requests 50.0 percentage_merge_requests { 50.0 }
leader_ci_pipelines 12.1234 leader_ci_pipelines { 12.1234 }
instance_ci_pipelines 2.344 instance_ci_pipelines { 2.344 }
percentage_ci_pipelines 19.334 percentage_ci_pipelines { 19.334 }
leader_environments 3.3333 leader_environments { 3.3333 }
instance_environments 2.2222 instance_environments { 2.2222 }
percentage_environments 66.672 percentage_environments { 66.672 }
leader_deployments 1.200 leader_deployments { 1.200 }
instance_deployments 0.771 instance_deployments { 0.771 }
percentage_deployments 64.25 percentage_deployments { 64.25 }
leader_projects_prometheus_active 0.111 leader_projects_prometheus_active { 0.111 }
instance_projects_prometheus_active 0.109 instance_projects_prometheus_active { 0.109 }
percentage_projects_prometheus_active 98.198 percentage_projects_prometheus_active { 98.198 }
leader_service_desk_issues 15.891 leader_service_desk_issues { 15.891 }
instance_service_desk_issues 13.345 instance_service_desk_issues { 13.345 }
percentage_service_desk_issues 83.978 percentage_service_desk_issues { 83.978 }
end end
end end
...@@ -6,7 +6,7 @@ FactoryBot.define do ...@@ -6,7 +6,7 @@ FactoryBot.define do
project project
trait :write_access do trait :write_access do
can_push true can_push { true }
end end
end end
end end
...@@ -2,20 +2,20 @@ ...@@ -2,20 +2,20 @@
FactoryBot.define do FactoryBot.define do
factory :deploy_token do factory :deploy_token do
token nil token { nil }
token_encrypted { Gitlab::CryptoHelper.aes256_gcm_encrypt( SecureRandom.hex(50) ) } token_encrypted { Gitlab::CryptoHelper.aes256_gcm_encrypt(SecureRandom.hex(50)) }
sequence(:name) { |n| "PDT #{n}" } sequence(:name) { |n| "PDT #{n}" }
read_repository true read_repository { true }
read_registry true read_registry { true }
revoked false revoked { false }
expires_at { 5.days.from_now } expires_at { 5.days.from_now }
trait :revoked do trait :revoked do
revoked true revoked { true }
end end
trait :gitlab_deploy_token do trait :gitlab_deploy_token do
name DeployToken::GITLAB_DEPLOY_TOKEN_NAME name { DeployToken::GITLAB_DEPLOY_TOKEN_NAME }
end end
trait :expired do trait :expired do
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
FactoryBot.define do FactoryBot.define do
factory :deployment, class: Deployment do factory :deployment, class: Deployment do
sha 'b83d6e391c22777fca1ed3012fce84f633d7fed0' sha { 'b83d6e391c22777fca1ed3012fce84f633d7fed0' }
ref 'master' ref { 'master' }
tag false tag { false }
user nil user { nil }
project nil project { nil }
deployable factory: :ci_build deployable factory: :ci_build
environment factory: :environment environment factory: :environment
...@@ -25,7 +25,7 @@ FactoryBot.define do ...@@ -25,7 +25,7 @@ FactoryBot.define do
trait :review_app do trait :review_app do
sha { TestEnv::BRANCH_SHA['pages-deploy'] } sha { TestEnv::BRANCH_SHA['pages-deploy'] }
ref 'pages-deploy' ref { 'pages-deploy' }
end end
trait :on_cluster do trait :on_cluster do
...@@ -33,21 +33,21 @@ FactoryBot.define do ...@@ -33,21 +33,21 @@ FactoryBot.define do
end end
trait :running do trait :running do
status :running status { :running }
end end
trait :success do trait :success do
status :success status { :success }
finished_at { Time.now } finished_at { Time.now }
end end
trait :failed do trait :failed do
status :failed status { :failed }
finished_at { Time.now } finished_at { Time.now }
end end
trait :canceled do trait :canceled do
status :canceled status { :canceled }
finished_at { Time.now } finished_at { Time.now }
end end
......
...@@ -9,7 +9,7 @@ FactoryBot.define do ...@@ -9,7 +9,7 @@ FactoryBot.define do
trait :with_review_app do |environment| trait :with_review_app do |environment|
transient do transient do
ref 'master' ref { 'master' }
end end
# At this point `review app` is an ephemeral concept related to # At this point `review app` is an ephemeral concept related to
...@@ -41,8 +41,8 @@ FactoryBot.define do ...@@ -41,8 +41,8 @@ FactoryBot.define do
end end
trait :non_playable do trait :non_playable do
status 'created' status { 'created' }
self.when 'manual' self.when { 'manual' }
end end
end end
end end
...@@ -2,22 +2,22 @@ ...@@ -2,22 +2,22 @@
FactoryBot.define do FactoryBot.define do
factory :error_tracking_error, class: Gitlab::ErrorTracking::Error do factory :error_tracking_error, class: Gitlab::ErrorTracking::Error do
id 'id' id { 'id' }
title 'title' title { 'title' }
type 'error' type { 'error' }
user_count 1 user_count { 1 }
count 2 count { 2 }
first_seen { Time.now } first_seen { Time.now }
last_seen { Time.now } last_seen { Time.now }
message 'message' message { 'message' }
culprit 'culprit' culprit { 'culprit' }
external_url 'http://example.com/id' external_url { 'http://example.com/id' }
project_id 'project1' project_id { 'project1' }
project_name 'project name' project_name { 'project name' }
project_slug 'project_name' project_slug { 'project_name' }
short_id 'ID' short_id { 'ID' }
status 'unresolved' status { 'unresolved' }
frequency [] frequency { [] }
skip_create skip_create
end end
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
FactoryBot.define do FactoryBot.define do
factory :error_tracking_project, class: Gitlab::ErrorTracking::Project do factory :error_tracking_project, class: Gitlab::ErrorTracking::Project do
id '1' id { '1' }
name 'Sentry Example' name { 'Sentry Example' }
slug 'sentry-example' slug { 'sentry-example' }
status 'active' status { 'active' }
organization_name 'Sentry' organization_name { 'Sentry' }
organization_id '1' organization_id { '1' }
organization_slug 'sentry' organization_slug { 'sentry' }
skip_create skip_create
end end
......
...@@ -4,19 +4,19 @@ FactoryBot.define do ...@@ -4,19 +4,19 @@ FactoryBot.define do
factory :event do factory :event do
project project
author(factory: :user) { project.creator } author(factory: :user) { project.creator }
action Event::JOINED action { Event::JOINED }
trait(:created) { action Event::CREATED } trait(:created) { action { Event::CREATED } }
trait(:updated) { action Event::UPDATED } trait(:updated) { action { Event::UPDATED } }
trait(:closed) { action Event::CLOSED } trait(:closed) { action { Event::CLOSED } }
trait(:reopened) { action Event::REOPENED } trait(:reopened) { action { Event::REOPENED } }
trait(:pushed) { action Event::PUSHED } trait(:pushed) { action { Event::PUSHED } }
trait(:commented) { action Event::COMMENTED } trait(:commented) { action { Event::COMMENTED } }
trait(:merged) { action Event::MERGED } trait(:merged) { action { Event::MERGED } }
trait(:joined) { action Event::JOINED } trait(:joined) { action { Event::JOINED } }
trait(:left) { action Event::LEFT } trait(:left) { action { Event::LEFT } }
trait(:destroyed) { action Event::DESTROYED } trait(:destroyed) { action { Event::DESTROYED } }
trait(:expired) { action Event::EXPIRED } trait(:expired) { action { Event::EXPIRED } }
factory :closed_issue_event do factory :closed_issue_event do
action { Event::CLOSED } action { Event::CLOSED }
...@@ -27,15 +27,15 @@ FactoryBot.define do ...@@ -27,15 +27,15 @@ FactoryBot.define do
factory :push_event, class: PushEvent do factory :push_event, class: PushEvent do
project factory: :project_empty_repo project factory: :project_empty_repo
author(factory: :user) { project.creator } author(factory: :user) { project.creator }
action Event::PUSHED action { Event::PUSHED }
end end
factory :push_event_payload do factory :push_event_payload do
event event
commit_count 1 commit_count { 1 }
action :pushed action { :pushed }
ref_type :branch ref_type { :branch }
ref 'master' ref { 'master' }
commit_to '3cdce97ed87c91368561584e7358f4d46e3e173c' commit_to { '3cdce97ed87c91368561584e7358f4d46e3e173c' }
end end
end end
...@@ -4,14 +4,14 @@ FactoryBot.define do ...@@ -4,14 +4,14 @@ FactoryBot.define do
factory :external_pull_request do factory :external_pull_request do
sequence(:pull_request_iid) sequence(:pull_request_iid)
project project
source_branch 'feature' source_branch { 'feature' }
source_repository 'the-repository' source_repository { 'the-repository' }
source_sha '97de212e80737a608d939f648d959671fb0a0142' source_sha { '97de212e80737a608d939f648d959671fb0a0142' }
target_branch 'master' target_branch { 'master' }
target_repository 'the-repository' target_repository { 'the-repository' }
target_sha 'a09386439ca39abe575675ffd4b89ae824fec22f' target_sha { 'a09386439ca39abe575675ffd4b89ae824fec22f' }
status :open status { :open }
trait(:closed) { status 'closed' } trait(:closed) { status { 'closed'} }
end end
end end
...@@ -5,7 +5,7 @@ FactoryBot.define do ...@@ -5,7 +5,7 @@ FactoryBot.define do
skip_create skip_create
project project
secret nil secret { nil }
transient do transient do
fixture { 'rails_sample.jpg' } fixture { 'rails_sample.jpg' }
......
...@@ -6,6 +6,6 @@ FactoryBot.define do ...@@ -6,6 +6,6 @@ FactoryBot.define do
project project
gpg_key gpg_key
gpg_key_primary_keyid { gpg_key.keyid } gpg_key_primary_keyid { gpg_key.keyid }
verification_status :verified verification_status { :verified }
end end
end end
...@@ -6,23 +6,23 @@ FactoryBot.define do ...@@ -6,23 +6,23 @@ FactoryBot.define do
group group
user user
trait(:guest) { access_level GroupMember::GUEST } trait(:guest) { access_level { GroupMember::GUEST } }
trait(:reporter) { access_level GroupMember::REPORTER } trait(:reporter) { access_level { GroupMember::REPORTER } }
trait(:developer) { access_level GroupMember::DEVELOPER } trait(:developer) { access_level { GroupMember::DEVELOPER } }
trait(:maintainer) { access_level GroupMember::MAINTAINER } trait(:maintainer) { access_level { GroupMember::MAINTAINER } }
trait(:owner) { access_level GroupMember::OWNER } trait(:owner) { access_level { GroupMember::OWNER } }
trait(:access_request) { requested_at { Time.now } } trait(:access_request) { requested_at { Time.now } }
trait(:invited) do trait(:invited) do
user_id nil user_id { nil }
invite_token 'xxx' invite_token { 'xxx' }
sequence :invite_email do |n| sequence :invite_email do |n|
"email#{n}@email.com" "email#{n}@email.com"
end end
end end
trait(:ldap) do trait(:ldap) do
ldap true ldap { true }
end end
trait :blocked do trait :blocked do
......
...@@ -4,9 +4,9 @@ FactoryBot.define do ...@@ -4,9 +4,9 @@ FactoryBot.define do
factory :group, class: Group, parent: :namespace do factory :group, class: Group, parent: :namespace do
sequence(:name) { |n| "group#{n}" } sequence(:name) { |n| "group#{n}" }
path { name.downcase.gsub(/\s/, '_') } path { name.downcase.gsub(/\s/, '_') }
type 'Group' type { 'Group' }
owner nil owner { nil }
project_creation_level ::Gitlab::Access::MAINTAINER_PROJECT_ACCESS project_creation_level { ::Gitlab::Access::MAINTAINER_PROJECT_ACCESS}
after(:create) do |group| after(:create) do |group|
if group.owner if group.owner
...@@ -17,15 +17,15 @@ FactoryBot.define do ...@@ -17,15 +17,15 @@ FactoryBot.define do
end end
trait :public do trait :public do
visibility_level Gitlab::VisibilityLevel::PUBLIC visibility_level { Gitlab::VisibilityLevel::PUBLIC}
end end
trait :internal do trait :internal do
visibility_level Gitlab::VisibilityLevel::INTERNAL visibility_level {Gitlab::VisibilityLevel::INTERNAL}
end end
trait :private do trait :private do
visibility_level Gitlab::VisibilityLevel::PRIVATE visibility_level { Gitlab::VisibilityLevel::PRIVATE}
end end
trait :with_avatar do trait :with_avatar do
...@@ -33,7 +33,7 @@ FactoryBot.define do ...@@ -33,7 +33,7 @@ FactoryBot.define do
end end
trait :access_requestable do trait :access_requestable do
request_access_enabled true request_access_enabled { true }
end end
trait :nested do trait :nested do
...@@ -41,15 +41,15 @@ FactoryBot.define do ...@@ -41,15 +41,15 @@ FactoryBot.define do
end end
trait :auto_devops_enabled do trait :auto_devops_enabled do
auto_devops_enabled true auto_devops_enabled { true }
end end
trait :auto_devops_disabled do trait :auto_devops_disabled do
auto_devops_enabled false auto_devops_enabled { false }
end end
trait :owner_subgroup_creation_only do trait :owner_subgroup_creation_only do
subgroup_creation_level ::Gitlab::Access::OWNER_SUBGROUP_ACCESS subgroup_creation_level { ::Gitlab::Access::OWNER_SUBGROUP_ACCESS}
end end
end end
end end
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
FactoryBot.define do FactoryBot.define do
factory :identity do factory :identity do
provider 'ldapmain' provider { 'ldapmain' }
extern_uid 'my-ldap-id' extern_uid { 'my-ldap-id' }
end end
end end
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
FactoryBot.define do FactoryBot.define do
factory :import_state, class: ProjectImportState do factory :import_state, class: ProjectImportState do
status :none status { :none }
association :project, factory: :project association :project, factory: :project
transient do transient do
import_url { generate(:url) } import_url { generate(:url) }
import_type nil import_type { nil }
end end
trait :repository do trait :repository do
...@@ -15,23 +15,23 @@ FactoryBot.define do ...@@ -15,23 +15,23 @@ FactoryBot.define do
end end
trait :none do trait :none do
status :none status { :none }
end end
trait :scheduled do trait :scheduled do
status :scheduled status { :scheduled }
end end
trait :started do trait :started do
status :started status { :started }
end end
trait :finished do trait :finished do
status :finished status { :finished }
end end
trait :failed do trait :failed do
status :failed status { :failed }
end end
after(:create) do |import_state, evaluator| after(:create) do |import_state, evaluator|
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
FactoryBot.define do FactoryBot.define do
factory :internal_id do factory :internal_id do
project project
usage :issues usage { :issues }
last_value { project.issues.maximum(:iid) || 0 } last_value { project.issues.maximum(:iid) || 0 }
end end
end end
...@@ -8,19 +8,19 @@ FactoryBot.define do ...@@ -8,19 +8,19 @@ FactoryBot.define do
updated_by { author } updated_by { author }
trait :confidential do trait :confidential do
confidential true confidential { true }
end end
trait :opened do trait :opened do
state :opened state { :opened }
end end
trait :locked do trait :locked do
discussion_locked true discussion_locked { true }
end end
trait :closed do trait :closed do
state :closed state { :closed }
closed_at { Time.now } closed_at { Time.now }
end end
...@@ -29,7 +29,7 @@ FactoryBot.define do ...@@ -29,7 +29,7 @@ FactoryBot.define do
factory :labeled_issue do factory :labeled_issue do
transient do transient do
labels [] labels { [] }
end end
after(:create) do |issue, evaluator| after(:create) do |issue, evaluator|
......
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
FactoryBot.define do FactoryBot.define do
trait :base_label do trait :base_label do
title { generate(:label_title) } title { generate(:label_title) }
color "#990000" color { "#990000" }
end end
factory :label, traits: [:base_label], class: ProjectLabel do factory :label, traits: [:base_label], class: ProjectLabel do
project project
transient do transient do
priority nil priority { nil }
end end
after(:create) do |label, evaluator| after(:create) do |label, evaluator|
......
...@@ -4,6 +4,6 @@ FactoryBot.define do ...@@ -4,6 +4,6 @@ FactoryBot.define do
factory :lfs_file_lock do factory :lfs_file_lock do
user user
project project
path 'README.md' path { 'README.md' }
end end
end end
...@@ -5,7 +5,7 @@ include ActionDispatch::TestProcess ...@@ -5,7 +5,7 @@ include ActionDispatch::TestProcess
FactoryBot.define do FactoryBot.define do
factory :lfs_object do factory :lfs_object do
sequence(:oid) { |n| "b68143e6463773b1b6c6fd009a76c32aeec041faff32ba2ed42fd7f708a%05x" % n } sequence(:oid) { |n| "b68143e6463773b1b6c6fd009a76c32aeec041faff32ba2ed42fd7f708a%05x" % n }
size 499013 size { 499013 }
end end
trait :with_file do trait :with_file do
...@@ -15,8 +15,8 @@ FactoryBot.define do ...@@ -15,8 +15,8 @@ FactoryBot.define do
# The uniqueness constraint means we can't use the correct OID for all LFS # The uniqueness constraint means we can't use the correct OID for all LFS
# objects, so the test needs to decide which (if any) object gets it # objects, so the test needs to decide which (if any) object gets it
trait :correct_oid do trait :correct_oid do
oid 'b804383982bb89b00e828e3f44c038cc991d3d1768009fc39ba8e2c081b9fb75' oid { 'b804383982bb89b00e828e3f44c038cc991d3d1768009fc39ba8e2c081b9fb75' }
size 1062 size { 1062 }
end end
trait :object_storage do trait :object_storage do
......
...@@ -4,6 +4,6 @@ FactoryBot.define do ...@@ -4,6 +4,6 @@ FactoryBot.define do
factory :lfs_objects_project do factory :lfs_objects_project do
lfs_object lfs_object
project project
repository_type :project repository_type { :project }
end end
end end
...@@ -4,19 +4,19 @@ FactoryBot.define do ...@@ -4,19 +4,19 @@ FactoryBot.define do
factory :list do factory :list do
board board
label label
list_type :label list_type { :label }
sequence(:position) sequence(:position)
end end
factory :backlog_list, parent: :list do factory :backlog_list, parent: :list do
list_type :backlog list_type { :backlog }
label nil label { nil }
position nil position { nil }
end end
factory :closed_list, parent: :list do factory :closed_list, parent: :list do
list_type :closed list_type { :closed }
label nil label { nil }
position nil position { nil }
end end
end end
...@@ -4,44 +4,44 @@ FactoryBot.define do ...@@ -4,44 +4,44 @@ FactoryBot.define do
factory :merge_request_diff_file do factory :merge_request_diff_file do
association :merge_request_diff association :merge_request_diff
relative_order 0 relative_order { 0 }
new_file true new_file { true }
renamed_file false renamed_file { false }
deleted_file false deleted_file { false }
too_large false too_large { false }
a_mode 0 a_mode { 0 }
b_mode 100644 b_mode { 100644 }
new_path 'foo' new_path { 'foo' }
old_path 'foo' old_path { 'foo' }
diff '' diff { '' }
binary false binary { false }
trait :new_file do trait :new_file do
relative_order 0 relative_order { 0 }
new_file true new_file { true }
renamed_file false renamed_file { false }
deleted_file false deleted_file { false }
too_large false too_large { false }
a_mode 0 a_mode { 0 }
b_mode 100644 b_mode { 100644 }
new_path 'foo' new_path { 'foo' }
old_path 'foo' old_path { 'foo' }
diff '' diff { '' }
binary false binary { false }
end end
trait :renamed_file do trait :renamed_file do
relative_order 662 relative_order { 662 }
new_file false new_file { false }
renamed_file true renamed_file { true }
deleted_file false deleted_file { false }
too_large false too_large { false }
a_mode 100644 a_mode { 100644 }
b_mode 100644 b_mode { 100644 }
new_path 'bar' new_path { 'bar' }
old_path 'baz' old_path { 'baz' }
diff '' diff { '' }
binary false binary { false }
end end
end end
end end
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
FactoryBot.define do FactoryBot.define do
factory :merge_request_diff do factory :merge_request_diff do
association :merge_request association :merge_request
state :collected state { :collected }
commits_count 1 commits_count { 1 }
base_commit_sha { Digest::SHA1.hexdigest(SecureRandom.hex) } base_commit_sha { Digest::SHA1.hexdigest(SecureRandom.hex) }
head_commit_sha { Digest::SHA1.hexdigest(SecureRandom.hex) } head_commit_sha { Digest::SHA1.hexdigest(SecureRandom.hex) }
......
...@@ -16,36 +16,36 @@ FactoryBot.define do ...@@ -16,36 +16,36 @@ FactoryBot.define do
# #
# See also RepoHelpers.sample_compare # See also RepoHelpers.sample_compare
# #
source_branch "master" source_branch { "master" }
target_branch "feature" target_branch { "feature" }
merge_status "can_be_merged" merge_status { "can_be_merged" }
trait :with_diffs do trait :with_diffs do
end end
trait :with_image_diffs do trait :with_image_diffs do
source_branch "add_images_and_changes" source_branch { "add_images_and_changes" }
target_branch "master" target_branch { "master" }
end end
trait :without_diffs do trait :without_diffs do
source_branch "improve/awesome" source_branch { "improve/awesome" }
target_branch "master" target_branch { "master" }
end end
trait :conflict do trait :conflict do
source_branch "feature_conflict" source_branch { "feature_conflict" }
target_branch "feature" target_branch { "feature" }
end end
trait :merged do trait :merged do
state :merged state { :merged }
end end
trait :merged_target do trait :merged_target do
source_branch "merged-target" source_branch { "merged-target" }
target_branch "improve/awesome" target_branch { "improve/awesome" }
end end
trait :merged_last_month do trait :merged_last_month do
...@@ -57,7 +57,7 @@ FactoryBot.define do ...@@ -57,7 +57,7 @@ FactoryBot.define do
end end
trait :closed do trait :closed do
state :closed state { :closed }
end end
trait :closed_last_month do trait :closed_last_month do
...@@ -69,36 +69,36 @@ FactoryBot.define do ...@@ -69,36 +69,36 @@ FactoryBot.define do
end end
trait :opened do trait :opened do
state :opened state { :opened }
end end
trait :invalid do trait :invalid do
source_branch "feature_one" source_branch { "feature_one" }
target_branch "feature_two" target_branch { "feature_two" }
end end
trait :locked do trait :locked do
state :locked state { :locked }
end end
trait :simple do trait :simple do
source_branch "feature" source_branch { "feature" }
target_branch "master" target_branch { "master" }
end end
trait :rebased do trait :rebased do
source_branch "markdown" source_branch { "markdown" }
target_branch "improve/awesome" target_branch { "improve/awesome" }
end end
trait :diverged do trait :diverged do
source_branch "feature" source_branch { "feature" }
target_branch "master" target_branch { "master" }
end end
trait :merge_when_pipeline_succeeds do trait :merge_when_pipeline_succeeds do
auto_merge_enabled true auto_merge_enabled { true }
auto_merge_strategy AutoMergeService::STRATEGY_MERGE_WHEN_PIPELINE_SUCCEEDS auto_merge_strategy { AutoMergeService::STRATEGY_MERGE_WHEN_PIPELINE_SUCCEEDS }
merge_user { author } merge_user { author }
end end
...@@ -162,7 +162,7 @@ FactoryBot.define do ...@@ -162,7 +162,7 @@ FactoryBot.define do
end end
trait :deployed_review_app do trait :deployed_review_app do
target_branch 'pages-deploy-target' target_branch { 'pages-deploy-target' }
transient do transient do
deployment { create(:deployment, :review_app) } deployment { create(:deployment, :review_app) }
...@@ -203,7 +203,7 @@ FactoryBot.define do ...@@ -203,7 +203,7 @@ FactoryBot.define do
factory :labeled_merge_request do factory :labeled_merge_request do
transient do transient do
labels [] labels { [] }
end end
after(:create) do |merge_request, evaluator| after(:create) do |merge_request, evaluator|
......
...@@ -5,19 +5,19 @@ FactoryBot.define do ...@@ -5,19 +5,19 @@ FactoryBot.define do
title title
transient do transient do
project nil project { nil }
group nil group { nil }
project_id nil project_id { nil }
group_id nil group_id { nil }
parent nil parent { nil }
end end
trait :active do trait :active do
state "active" state { "active" }
end end
trait :closed do trait :closed do
state "closed" state { "closed" }
end end
trait :with_dates do trait :with_dates do
......
...@@ -41,14 +41,14 @@ FactoryBot.define do ...@@ -41,14 +41,14 @@ FactoryBot.define do
factory :legacy_diff_note_on_merge_request, traits: [:on_merge_request, :legacy_diff_note], class: LegacyDiffNote do factory :legacy_diff_note_on_merge_request, traits: [:on_merge_request, :legacy_diff_note], class: LegacyDiffNote do
association :project, :repository association :project, :repository
position '' position { '' }
end end
factory :diff_note_on_merge_request, traits: [:on_merge_request], class: DiffNote do factory :diff_note_on_merge_request, traits: [:on_merge_request], class: DiffNote do
association :project, :repository association :project, :repository
transient do transient do
line_number 14 line_number { 14 }
diff_refs { noteable.try(:diff_refs) } diff_refs { noteable.try(:diff_refs) }
end end
...@@ -87,7 +87,7 @@ FactoryBot.define do ...@@ -87,7 +87,7 @@ FactoryBot.define do
association :project, :repository association :project, :repository
transient do transient do
line_number 14 line_number { 14 }
diff_refs { project.commit(commit_id).try(:diff_refs) } diff_refs { project.commit(commit_id).try(:diff_refs) }
end end
...@@ -104,14 +104,14 @@ FactoryBot.define do ...@@ -104,14 +104,14 @@ FactoryBot.define do
trait :on_commit do trait :on_commit do
association :project, :repository association :project, :repository
noteable nil noteable { nil }
noteable_type 'Commit' noteable_type { 'Commit' }
noteable_id nil noteable_id { nil }
commit_id { RepoHelpers.sample_commit.id } commit_id { RepoHelpers.sample_commit.id }
end end
trait :legacy_diff_note do trait :legacy_diff_note do
line_code "0_184_184" line_code { "0_184_184" }
end end
trait :on_issue do trait :on_issue do
...@@ -132,19 +132,19 @@ FactoryBot.define do ...@@ -132,19 +132,19 @@ FactoryBot.define do
trait :on_personal_snippet do trait :on_personal_snippet do
noteable { create(:personal_snippet) } noteable { create(:personal_snippet) }
project nil project { nil }
end end
trait :system do trait :system do
system true system { true }
end end
trait :downvote do trait :downvote do
note "thumbsdown" note { "thumbsdown" }
end end
trait :upvote do trait :upvote do
note "thumbsup" note { "thumbsup" }
end end
trait :with_attachment do trait :with_attachment do
...@@ -156,7 +156,7 @@ FactoryBot.define do ...@@ -156,7 +156,7 @@ FactoryBot.define do
end end
transient do transient do
in_reply_to nil in_reply_to { nil }
end end
before(:create) do |note, evaluator| before(:create) do |note, evaluator|
......
...@@ -4,6 +4,6 @@ FactoryBot.define do ...@@ -4,6 +4,6 @@ FactoryBot.define do
factory :notification_setting do factory :notification_setting do
source factory: :project source factory: :project
user user
level 3 level { 3 }
end end
end end
...@@ -6,6 +6,6 @@ FactoryBot.define do ...@@ -6,6 +6,6 @@ FactoryBot.define do
uid { Doorkeeper::OAuth::Helpers::UniqueToken.generate } uid { Doorkeeper::OAuth::Helpers::UniqueToken.generate }
redirect_uri { generate(:url) } redirect_uri { generate(:url) }
owner owner
owner_type 'User' owner_type { 'User' }
end end
end end
...@@ -6,7 +6,8 @@ FactoryBot.define do ...@@ -6,7 +6,8 @@ FactoryBot.define do
verified_at { Time.now } verified_at { Time.now }
enabled_until { 1.week.from_now } enabled_until { 1.week.from_now }
certificate '-----BEGIN CERTIFICATE----- certificate do
'-----BEGIN CERTIFICATE-----
MIICGzCCAYSgAwIBAgIBATANBgkqhkiG9w0BAQUFADAbMRkwFwYDVQQDExB0ZXN0 MIICGzCCAYSgAwIBAgIBATANBgkqhkiG9w0BAQUFADAbMRkwFwYDVQQDExB0ZXN0
LWNlcnRpZmljYXRlMB4XDTE2MDIxMjE0MzIwMFoXDTIwMDQxMjE0MzIwMFowGzEZ LWNlcnRpZmljYXRlMB4XDTE2MDIxMjE0MzIwMFoXDTIwMDQxMjE0MzIwMFowGzEZ
MBcGA1UEAxMQdGVzdC1jZXJ0aWZpY2F0ZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw MBcGA1UEAxMQdGVzdC1jZXJ0aWZpY2F0ZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
...@@ -20,8 +21,10 @@ joZp2JHYvNlTPkRJ/J4TcXxBTJmArcQgTIuNoBtC+0A/SwdK4MfTCUY4vNWNdese ...@@ -20,8 +21,10 @@ joZp2JHYvNlTPkRJ/J4TcXxBTJmArcQgTIuNoBtC+0A/SwdK4MfTCUY4vNWNdese
5A4K65Nb7Oh1AdQieTBHNXXCdyFsva9/ScfQGEl7p55a52jOPs0StPd7g64uvjlg 5A4K65Nb7Oh1AdQieTBHNXXCdyFsva9/ScfQGEl7p55a52jOPs0StPd7g64uvjlg
YHi2yesCrOvVXt+lgPTd YHi2yesCrOvVXt+lgPTd
-----END CERTIFICATE-----' -----END CERTIFICATE-----'
end
key '-----BEGIN PRIVATE KEY----- key do
'-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKS+CfS9GcRSdYSN MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKS+CfS9GcRSdYSN
SzyH5QJQBr5umRL6E+KilOV39iYFO/9oHjUdapTRWkrwnNPCp7qaeck4Jr8iv14t SzyH5QJQBr5umRL6E+KilOV39iYFO/9oHjUdapTRWkrwnNPCp7qaeck4Jr8iv14t
PVNDfNr76eGb6/3YknOAP0QOjLWunoC8kjU+N/JHU52NrUeX3qEy8EKV9LeCDJcB PVNDfNr76eGb6/3YknOAP0QOjLWunoC8kjU+N/JHU52NrUeX3qEy8EKV9LeCDJcB
...@@ -37,10 +40,11 @@ EPjGlXIT+aW2XiPmK3ZlCDcWIenE+lmtbOpI159Wpk8BGXs/s/xBAkEAlAY3ymgx ...@@ -37,10 +40,11 @@ EPjGlXIT+aW2XiPmK3ZlCDcWIenE+lmtbOpI159Wpk8BGXs/s/xBAkEAlAY3ymgx
63BDJEwvOb2IaP8lDDxNsXx9XJNVvQbv5n15vNsLHbjslHfAhAbxnLQ1fLhUPqSi 63BDJEwvOb2IaP8lDDxNsXx9XJNVvQbv5n15vNsLHbjslHfAhAbxnLQ1fLhUPqSi
nNp/xedE1YxutQ== nNp/xedE1YxutQ==
-----END PRIVATE KEY-----' -----END PRIVATE KEY-----'
end
trait :disabled do trait :disabled do
verified_at nil verified_at { nil }
enabled_until nil enabled_until { nil }
end end
trait :scheduled_for_removal do trait :scheduled_for_removal do
...@@ -52,7 +56,7 @@ nNp/xedE1YxutQ== ...@@ -52,7 +56,7 @@ nNp/xedE1YxutQ==
end end
trait :unverified do trait :unverified do
verified_at nil verified_at { nil }
end end
trait :reverify do trait :reverify do
...@@ -64,17 +68,18 @@ nNp/xedE1YxutQ== ...@@ -64,17 +68,18 @@ nNp/xedE1YxutQ==
end end
trait :without_certificate do trait :without_certificate do
certificate nil certificate { nil }
end end
trait :without_key do trait :without_key do
key nil key { nil }
end end
trait :with_missing_chain do trait :with_missing_chain do
# This certificate is signed with different key # This certificate is signed with different key
# And misses the CA to build trust chain # And misses the CA to build trust chain
certificate '-----BEGIN CERTIFICATE----- certificate do
'-----BEGIN CERTIFICATE-----
MIIDGTCCAgGgAwIBAgIBAjANBgkqhkiG9w0BAQUFADASMRAwDgYDVQQDEwdUZXN0 MIIDGTCCAgGgAwIBAgIBAjANBgkqhkiG9w0BAQUFADASMRAwDgYDVQQDEwdUZXN0
IENBMB4XDTE2MDIxMjE0MjMwMFoXDTE3MDIxMTE0MjMwMFowHTEbMBkGA1UEAxMS IENBMB4XDTE2MDIxMjE0MjMwMFoXDTE3MDIxMTE0MjMwMFowHTEbMBkGA1UEAxMS
dGVzdC1jZXJ0aWZpY2F0ZS0yMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC dGVzdC1jZXJ0aWZpY2F0ZS0yMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
...@@ -93,13 +98,15 @@ WlU8raZoPIqf6H/8JA97pM/nk/3CqCoHsouSQv+jGY4pSL22RqsO0ylIM0LDBbmF ...@@ -93,13 +98,15 @@ WlU8raZoPIqf6H/8JA97pM/nk/3CqCoHsouSQv+jGY4pSL22RqsO0ylIM0LDBbmF
m4AEaojTljX1tMJAF9Rbiw/omam5bDPq2JWtosrz/zB69y5FaQjc6FnCk0M4oN/+ m4AEaojTljX1tMJAF9Rbiw/omam5bDPq2JWtosrz/zB69y5FaQjc6FnCk0M4oN/+
VM+d42lQAgoq318A84Xu5vRh1KCAJuztkhNbM+w= VM+d42lQAgoq318A84Xu5vRh1KCAJuztkhNbM+w=
-----END CERTIFICATE-----' -----END CERTIFICATE-----'
end
end end
trait :with_trusted_chain do trait :with_trusted_chain do
# This contains # This contains
# [Intermediate #2 (SHA-2)] 'Comodo RSA Domain Validation Secure Server CA' # [Intermediate #2 (SHA-2)] 'Comodo RSA Domain Validation Secure Server CA'
# [Intermediate #1 (SHA-2)] 'COMODO RSA Certification Authority' # [Intermediate #1 (SHA-2)] 'COMODO RSA Certification Authority'
certificate '-----BEGIN CERTIFICATE----- certificate do
'-----BEGIN CERTIFICATE-----
MIIGCDCCA/CgAwIBAgIQKy5u6tl1NmwUim7bo3yMBzANBgkqhkiG9w0BAQwFADCB MIIGCDCCA/CgAwIBAgIQKy5u6tl1NmwUim7bo3yMBzANBgkqhkiG9w0BAQwFADCB
hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G
A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV
...@@ -166,13 +173,15 @@ B5a6SE2Q8pTIqXOi6wZ7I53eovNNVZ96YUWYGGjHXkBrI/V5eu+MtWuLt29G9Hvx ...@@ -166,13 +173,15 @@ B5a6SE2Q8pTIqXOi6wZ7I53eovNNVZ96YUWYGGjHXkBrI/V5eu+MtWuLt29G9Hvx
PUsE2JOAWVrgQSQdso8VYFhH2+9uRv0V9dlfmrPb2LjkQLPNlzmuhbsdjrzch5vR PUsE2JOAWVrgQSQdso8VYFhH2+9uRv0V9dlfmrPb2LjkQLPNlzmuhbsdjrzch5vR
pu/xO28QOG8= pu/xO28QOG8=
-----END CERTIFICATE-----' -----END CERTIFICATE-----'
end
end end
trait :with_trusted_expired_chain do trait :with_trusted_expired_chain do
# This contains # This contains
# Let's Encrypt Authority X3 # Let's Encrypt Authority X3
# DST Root CA X3 # DST Root CA X3
certificate '-----BEGIN CERTIFICATE----- certificate do
'-----BEGIN CERTIFICATE-----
MIIFSjCCBDKgAwIBAgISAw24xGWrFotvTBa6AZI/pzq1MA0GCSqGSIb3DQEBCwUA MIIFSjCCBDKgAwIBAgISAw24xGWrFotvTBa6AZI/pzq1MA0GCSqGSIb3DQEBCwUA
MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD
ExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0xOTAzMDcxNzU5NTZaFw0x ExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0xOTAzMDcxNzU5NTZaFw0x
...@@ -250,10 +259,12 @@ R8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5 ...@@ -250,10 +259,12 @@ R8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5
JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo
Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ
-----END CERTIFICATE-----' -----END CERTIFICATE-----'
end
end end
trait :with_expired_certificate do trait :with_expired_certificate do
certificate '-----BEGIN CERTIFICATE----- certificate do
'-----BEGIN CERTIFICATE-----
MIIBsDCCARmgAwIBAgIBATANBgkqhkiG9w0BAQUFADAeMRwwGgYDVQQDExNleHBp MIIBsDCCARmgAwIBAgIBATANBgkqhkiG9w0BAQUFADAeMRwwGgYDVQQDExNleHBp
cmVkLWNlcnRpZmljYXRlMB4XDTE1MDIxMjE0MzMwMFoXDTE2MDIwMTE0MzMwMFow cmVkLWNlcnRpZmljYXRlMB4XDTE1MDIxMjE0MzMwMFoXDTE2MDIwMTE0MzMwMFow
HjEcMBoGA1UEAxMTZXhwaXJlZC1jZXJ0aWZpY2F0ZTCBnzANBgkqhkiG9w0BAQEF HjEcMBoGA1UEAxMTZXhwaXJlZC1jZXJ0aWZpY2F0ZTCBnzANBgkqhkiG9w0BAQEF
...@@ -265,6 +276,7 @@ Hq9LkWn6WP4EHsesHyslgTQZF8C7kVLTbLn2noLnOE+Mp3vcWlZxl3Yk6aZMhKS+ ...@@ -265,6 +276,7 @@ Hq9LkWn6WP4EHsesHyslgTQZF8C7kVLTbLn2noLnOE+Mp3vcWlZxl3Yk6aZMhKS+
Iy6oRpHaCF/2obZdIdgf9rlyz0fkqyHJc9GkioSoOhJZxEV2SgAkap8yS0sX2tJ9 Iy6oRpHaCF/2obZdIdgf9rlyz0fkqyHJc9GkioSoOhJZxEV2SgAkap8yS0sX2tJ9
ZDXgrA== ZDXgrA==
-----END CERTIFICATE-----' -----END CERTIFICATE-----'
end
end end
trait :letsencrypt do trait :letsencrypt do
...@@ -273,7 +285,8 @@ ZDXgrA== ...@@ -273,7 +285,8 @@ ZDXgrA==
end end
trait :explicit_ecdsa do trait :explicit_ecdsa do
certificate '-----BEGIN CERTIFICATE----- certificate do
'-----BEGIN CERTIFICATE-----
MIID1zCCAzkCCQDatOIwBlktwjAKBggqhkjOPQQDAjBPMQswCQYDVQQGEwJVUzEL MIID1zCCAzkCCQDatOIwBlktwjAKBggqhkjOPQQDAjBPMQswCQYDVQQGEwJVUzEL
MAkGA1UECAwCTlkxCzAJBgNVBAcMAk5ZMQswCQYDVQQLDAJJVDEZMBcGA1UEAwwQ MAkGA1UECAwCTlkxCzAJBgNVBAcMAk5ZMQswCQYDVQQLDAJJVDEZMBcGA1UEAwwQ
dGVzdC1jZXJ0aWZpY2F0ZTAeFw0xOTA4MjkxMTE1NDBaFw0yMTA4MjgxMTE1NDBa dGVzdC1jZXJ0aWZpY2F0ZTAeFw0xOTA4MjkxMTE1NDBaFw0yMTA4MjgxMTE1NDBa
...@@ -296,8 +309,10 @@ OjSJpIDdFWGVYJHyMDI5WgQyhm4hAioXJ0T22Zab8Wmq+hBYRJNcHoaV894blfqR ...@@ -296,8 +309,10 @@ OjSJpIDdFWGVYJHyMDI5WgQyhm4hAioXJ0T22Zab8Wmq+hBYRJNcHoaV894blfqR
V3ZJgam8EQJCAcnPpJQ0IqoT1pAQkaL3+Ka8ZaaCd6/8RnoDtGvWljisuyH65SRu V3ZJgam8EQJCAcnPpJQ0IqoT1pAQkaL3+Ka8ZaaCd6/8RnoDtGvWljisuyH65SRu
kmYv87bZe1KqOZDoaDBdfVsoxcGbik19lBPV kmYv87bZe1KqOZDoaDBdfVsoxcGbik19lBPV
-----END CERTIFICATE-----' -----END CERTIFICATE-----'
end
key '-----BEGIN EC PARAMETERS----- key do
'-----BEGIN EC PARAMETERS-----
MIIBwgIBATBNBgcqhkjOPQEBAkIB//////////////////////////////////// MIIBwgIBATBNBgcqhkjOPQEBAkIB////////////////////////////////////
//////////////////////////////////////////////////8wgZ4EQgH///// //////////////////////////////////////////////////8wgZ4EQgH/////
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
...@@ -326,10 +341,12 @@ ZAkCAQGhgYkDgYYABAFUb/hz+GCXfq2geP54Yvimq/uXsz5kpAni/PRj0TrEjH6C ...@@ -326,10 +341,12 @@ ZAkCAQGhgYkDgYYABAFUb/hz+GCXfq2geP54Yvimq/uXsz5kpAni/PRj0TrEjH6C
+Iu6YSMSWFwExlVeJeFvm3F/XW5cBafmfpCF7Llgo8w2MsuoOpobX158IsJ3bUDR +Iu6YSMSWFwExlVeJeFvm3F/XW5cBafmfpCF7Llgo8w2MsuoOpobX158IsJ3bUDR
Nw== Nw==
-----END EC PRIVATE KEY-----' -----END EC PRIVATE KEY-----'
end
end end
trait :ecdsa do trait :ecdsa do
certificate '-----BEGIN CERTIFICATE----- certificate do
'-----BEGIN CERTIFICATE-----
MIIB8zCCAVUCCQCGKuPQ6SBxUTAKBggqhkjOPQQDAjA+MQswCQYDVQQGEwJVUzEL MIIB8zCCAVUCCQCGKuPQ6SBxUTAKBggqhkjOPQQDAjA+MQswCQYDVQQGEwJVUzEL
MAkGA1UECAwCVVMxCzAJBgNVBAcMAlVTMRUwEwYDVQQDDAxzaHVzaGxpbi5kZXYw MAkGA1UECAwCVVMxCzAJBgNVBAcMAlVTMRUwEwYDVQQDDAxzaHVzaGxpbi5kZXYw
HhcNMTkwOTAyMDkyMDUxWhcNMjEwOTAxMDkyMDUxWjA+MQswCQYDVQQGEwJVUzEL HhcNMTkwOTAyMDkyMDUxWhcNMjEwOTAxMDkyMDUxWjA+MQswCQYDVQQGEwJVUzEL
...@@ -342,8 +359,10 @@ R9WYUg5+PQMg7kS+4K/5+5gonWCvaMcP+2P7hltUcvq41l3uMKKCZRU/x60/FMHc ...@@ -342,8 +359,10 @@ R9WYUg5+PQMg7kS+4K/5+5gonWCvaMcP+2P7hltUcvq41l3uMKKCZRU/x60/FMHc
1ZXdAkIBuVtm9RJXziNOKS4TcpH9os/FuREW8YQlpec58LDZdlivcHnikHZ4LCri 1ZXdAkIBuVtm9RJXziNOKS4TcpH9os/FuREW8YQlpec58LDZdlivcHnikHZ4LCri
T7zu3VY6Rq+V/IKpsQwQjmoTJ0IpCM8= T7zu3VY6Rq+V/IKpsQwQjmoTJ0IpCM8=
-----END CERTIFICATE-----' -----END CERTIFICATE-----'
end
key '-----BEGIN EC PARAMETERS----- key do
'-----BEGIN EC PARAMETERS-----
BgUrgQQAIw== BgUrgQQAIw==
-----END EC PARAMETERS----- -----END EC PARAMETERS-----
-----BEGIN EC PRIVATE KEY----- -----BEGIN EC PRIVATE KEY-----
...@@ -353,6 +372,7 @@ dNqyCW1lFsgyt6KHJw6H8bhNemSny1O0Sy4P6yHxq7cnLCyLz1FJnq+BWgJjv/8N ...@@ -353,6 +372,7 @@ dNqyCW1lFsgyt6KHJw6H8bhNemSny1O0Sy4P6yHxq7cnLCyLz1FJnq+BWgJjv/8N
Da9qZifIFmpsv5xNAGxDvANQRpLI/RHc/hvo7HfjuljNfBJ1I6tr0KbhMxB76mtU Da9qZifIFmpsv5xNAGxDvANQRpLI/RHc/hvo7HfjuljNfBJ1I6tr0KbhMxB76mtU
x6zG6WoibsbsJMj70nwseUnPTBQNDP+j61RJjC/r x6zG6WoibsbsJMj70nwseUnPTBQNDP+j61RJjC/r
-----END EC PRIVATE KEY-----' -----END EC PRIVATE KEY-----'
end
end end
end end
end end
...@@ -4,19 +4,19 @@ FactoryBot.define do ...@@ -4,19 +4,19 @@ FactoryBot.define do
factory :personal_access_token do factory :personal_access_token do
user user
sequence(:name) { |n| "PAT #{n}" } sequence(:name) { |n| "PAT #{n}" }
revoked false revoked { false }
expires_at { 5.days.from_now } expires_at { 5.days.from_now }
scopes ['api'] scopes { ['api'] }
impersonation false impersonation { false }
after(:build) { |personal_access_token| personal_access_token.ensure_token } after(:build) { |personal_access_token| personal_access_token.ensure_token }
trait :impersonation do trait :impersonation do
impersonation true impersonation { true }
end end
trait :revoked do trait :revoked do
revoked true revoked { true }
end end
trait :expired do trait :expired do
...@@ -24,7 +24,7 @@ FactoryBot.define do ...@@ -24,7 +24,7 @@ FactoryBot.define do
end end
trait :invalid do trait :invalid do
token_digest nil token_digest { nil }
end end
end end
end end
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
FactoryBot.define do FactoryBot.define do
factory :pool_repository do factory :pool_repository do
shard { Shard.by_name("default") } shard { Shard.by_name("default") }
state :none state { :none }
before(:create) do |pool| before(:create) do |pool|
pool.source_project = create(:project, :repository) pool.source_project = create(:project, :repository)
...@@ -11,19 +11,19 @@ FactoryBot.define do ...@@ -11,19 +11,19 @@ FactoryBot.define do
end end
trait :scheduled do trait :scheduled do
state :scheduled state { :scheduled }
end end
trait :failed do trait :failed do
state :failed state { :failed }
end end
trait :obsolete do trait :obsolete do
state :obsolete state { :obsolete }
end end
trait :ready do trait :ready do
state :ready state { :ready }
after(:create) do |pool| after(:create) do |pool|
pool.create_object_pool pool.create_object_pool
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
FactoryBot.define do FactoryBot.define do
factory :programming_language do factory :programming_language do
name 'Ruby' name { 'Ruby' }
color '#123456' color { '#123456' }
end end
end end
...@@ -3,23 +3,23 @@ ...@@ -3,23 +3,23 @@
FactoryBot.define do FactoryBot.define do
factory :project_auto_devops do factory :project_auto_devops do
project project
enabled true enabled { true }
deploy_strategy :continuous deploy_strategy { :continuous }
trait :continuous_deployment do trait :continuous_deployment do
deploy_strategy ProjectAutoDevops.deploy_strategies[:continuous] # rubocop:disable FactoryBot/DynamicAttributeDefinedStatically deploy_strategy { ProjectAutoDevops.deploy_strategies[:continuous] }
end end
trait :manual_deployment do trait :manual_deployment do
deploy_strategy ProjectAutoDevops.deploy_strategies[:manual] # rubocop:disable FactoryBot/DynamicAttributeDefinedStatically deploy_strategy { ProjectAutoDevops.deploy_strategies[:manual] }
end end
trait :timed_incremental_deployment do trait :timed_incremental_deployment do
deploy_strategy ProjectAutoDevops.deploy_strategies[:timed_incremental] # rubocop:disable FactoryBot/DynamicAttributeDefinedStatically deploy_strategy { ProjectAutoDevops.deploy_strategies[:timed_incremental] }
end end
trait :disabled do trait :disabled do
enabled false enabled { false }
end end
end end
end end
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
FactoryBot.define do FactoryBot.define do
factory :project_daily_statistic do factory :project_daily_statistic do
project project
fetch_count 1 fetch_count { 1 }
end end
end end
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
FactoryBot.define do FactoryBot.define do
factory :project_error_tracking_setting, class: ErrorTracking::ProjectErrorTrackingSetting do factory :project_error_tracking_setting, class: ErrorTracking::ProjectErrorTrackingSetting do
project project
api_url 'https://gitlab.com/api/0/projects/sentry-org/sentry-project' api_url { 'https://gitlab.com/api/0/projects/sentry-org/sentry-project' }
enabled true enabled { true }
token 'access_token_123' token { 'access_token_123' }
project_name 'Sentry Project' project_name { 'Sentry Project' }
organization_name 'Sentry Org' organization_name { 'Sentry Org' }
end end
end end
...@@ -4,6 +4,6 @@ FactoryBot.define do ...@@ -4,6 +4,6 @@ FactoryBot.define do
factory :project_group_link do factory :project_group_link do
project project
group group
expires_at nil expires_at { nil }
end end
end end
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
FactoryBot.define do FactoryBot.define do
factory :project_hook do factory :project_hook do
url { generate(:url) } url { generate(:url) }
enable_ssl_verification false enable_ssl_verification { false }
project project
trait :token do trait :token do
...@@ -11,16 +11,16 @@ FactoryBot.define do ...@@ -11,16 +11,16 @@ FactoryBot.define do
end end
trait :all_events_enabled do trait :all_events_enabled do
push_events true push_events { true }
merge_requests_events true merge_requests_events { true }
tag_push_events true tag_push_events { true }
issues_events true issues_events { true }
confidential_issues_events true confidential_issues_events { true }
note_events true note_events { true }
confidential_note_events true confidential_note_events { true }
job_events true job_events { true }
pipeline_events true pipeline_events { true }
wiki_page_events true wiki_page_events { true }
end end
end end
end end
...@@ -6,16 +6,16 @@ FactoryBot.define do ...@@ -6,16 +6,16 @@ FactoryBot.define do
project project
maintainer maintainer
trait(:guest) { access_level ProjectMember::GUEST } trait(:guest) { access_level { ProjectMember::GUEST } }
trait(:reporter) { access_level ProjectMember::REPORTER } trait(:reporter) { access_level { ProjectMember::REPORTER } }
trait(:developer) { access_level ProjectMember::DEVELOPER } trait(:developer) { access_level { ProjectMember::DEVELOPER } }
trait(:maintainer) { access_level ProjectMember::MAINTAINER } trait(:maintainer) { access_level { ProjectMember::MAINTAINER } }
trait(:access_request) { requested_at { Time.now } } trait(:access_request) { requested_at { Time.now } }
trait(:invited) do trait(:invited) do
user_id nil user_id { nil }
invite_token 'xxx' invite_token { 'xxx' }
invite_email 'email@email.com' invite_email { 'email@email.com' }
end end
trait :blocked do trait :blocked do
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
FactoryBot.define do FactoryBot.define do
factory :project_metrics_setting, class: ProjectMetricsSetting do factory :project_metrics_setting, class: ProjectMetricsSetting do
project project
external_dashboard_url 'https://grafana.com' external_dashboard_url { 'https://grafana.com' }
end end
end end
...@@ -13,7 +13,7 @@ FactoryBot.define do ...@@ -13,7 +13,7 @@ FactoryBot.define do
sequence(:name) { |n| "project#{n}" } sequence(:name) { |n| "project#{n}" }
path { name.downcase.gsub(/\s/, '_') } path { name.downcase.gsub(/\s/, '_') }
# Behaves differently to nil due to cache_has_external_issue_tracker # Behaves differently to nil due to cache_has_external_issue_tracker
has_external_issue_tracker false has_external_issue_tracker { false }
# Associations # Associations
namespace namespace
...@@ -21,21 +21,21 @@ FactoryBot.define do ...@@ -21,21 +21,21 @@ FactoryBot.define do
transient do transient do
# Nest Project Feature attributes # Nest Project Feature attributes
wiki_access_level ProjectFeature::ENABLED wiki_access_level { ProjectFeature::ENABLED }
builds_access_level ProjectFeature::ENABLED builds_access_level { ProjectFeature::ENABLED }
snippets_access_level ProjectFeature::ENABLED snippets_access_level { ProjectFeature::ENABLED }
issues_access_level ProjectFeature::ENABLED issues_access_level { ProjectFeature::ENABLED }
merge_requests_access_level ProjectFeature::ENABLED merge_requests_access_level { ProjectFeature::ENABLED }
repository_access_level ProjectFeature::ENABLED repository_access_level { ProjectFeature::ENABLED }
pages_access_level do pages_access_level do
visibility_level == Gitlab::VisibilityLevel::PUBLIC ? ProjectFeature::ENABLED : ProjectFeature::PRIVATE visibility_level == Gitlab::VisibilityLevel::PUBLIC ? ProjectFeature::ENABLED : ProjectFeature::PRIVATE
end end
# we can't assign the delegated `#ci_cd_settings` attributes directly, as the # we can't assign the delegated `#ci_cd_settings` attributes directly, as the
# `#ci_cd_settings` relation needs to be created first # `#ci_cd_settings` relation needs to be created first
group_runners_enabled nil group_runners_enabled { nil }
import_status nil import_status { nil }
import_jid nil import_jid { nil }
end end
after(:create) do |project, evaluator| after(:create) do |project, evaluator|
...@@ -80,45 +80,45 @@ FactoryBot.define do ...@@ -80,45 +80,45 @@ FactoryBot.define do
end end
trait :public do trait :public do
visibility_level Gitlab::VisibilityLevel::PUBLIC visibility_level { Gitlab::VisibilityLevel::PUBLIC }
end end
trait :internal do trait :internal do
visibility_level Gitlab::VisibilityLevel::INTERNAL visibility_level { Gitlab::VisibilityLevel::INTERNAL }
end end
trait :private do trait :private do
visibility_level Gitlab::VisibilityLevel::PRIVATE visibility_level { Gitlab::VisibilityLevel::PRIVATE }
end end
trait :import_scheduled do trait :import_scheduled do
import_status :scheduled import_status { :scheduled }
end end
trait :import_started do trait :import_started do
import_status :started import_status { :started }
end end
trait :import_finished do trait :import_finished do
import_status :finished import_status { :finished }
end end
trait :import_failed do trait :import_failed do
import_status :failed import_status { :failed }
end end
trait :archived do trait :archived do
archived true archived { true }
end end
storage_version Project::LATEST_STORAGE_VERSION storage_version { Project::LATEST_STORAGE_VERSION }
trait :legacy_storage do trait :legacy_storage do
storage_version nil storage_version { nil }
end end
trait :access_requestable do trait :access_requestable do
request_access_enabled true request_access_enabled { true }
end end
trait :with_avatar do trait :with_avatar do
...@@ -146,7 +146,7 @@ FactoryBot.define do ...@@ -146,7 +146,7 @@ FactoryBot.define do
# will create a repository containing two files, and two commits, in master # will create a repository containing two files, and two commits, in master
trait :custom_repo do trait :custom_repo do
transient do transient do
files {} files { {} }
end end
after :create do |project, evaluator| after :create do |project, evaluator|
...@@ -169,7 +169,7 @@ FactoryBot.define do ...@@ -169,7 +169,7 @@ FactoryBot.define do
test_repo test_repo
transient do transient do
create_templates nil create_templates { nil }
end end
after :create do |project, evaluator| after :create do |project, evaluator|
...@@ -206,9 +206,9 @@ FactoryBot.define do ...@@ -206,9 +206,9 @@ FactoryBot.define do
trait :remote_mirror do trait :remote_mirror do
transient do transient do
remote_name "remote_mirror_#{SecureRandom.hex}" remote_name { "remote_mirror_#{SecureRandom.hex}" }
url "http://foo.com" url { "http://foo.com" }
enabled true enabled { true }
end end
after(:create) do |project, evaluator| after(:create) do |project, evaluator|
project.remote_mirrors.create!(url: evaluator.url, enabled: evaluator.enabled) project.remote_mirrors.create!(url: evaluator.url, enabled: evaluator.enabled)
...@@ -229,7 +229,7 @@ FactoryBot.define do ...@@ -229,7 +229,7 @@ FactoryBot.define do
end end
trait :read_only do trait :read_only do
repository_read_only true repository_read_only { true }
end end
trait :broken_repo do trait :broken_repo do
...@@ -249,29 +249,29 @@ FactoryBot.define do ...@@ -249,29 +249,29 @@ FactoryBot.define do
end end
end end
trait(:wiki_enabled) { wiki_access_level ProjectFeature::ENABLED } trait(:wiki_enabled) { wiki_access_level { ProjectFeature::ENABLED } }
trait(:wiki_disabled) { wiki_access_level ProjectFeature::DISABLED } trait(:wiki_disabled) { wiki_access_level { ProjectFeature::DISABLED } }
trait(:wiki_private) { wiki_access_level ProjectFeature::PRIVATE } trait(:wiki_private) { wiki_access_level { ProjectFeature::PRIVATE } }
trait(:builds_enabled) { builds_access_level ProjectFeature::ENABLED } trait(:builds_enabled) { builds_access_level { ProjectFeature::ENABLED } }
trait(:builds_disabled) { builds_access_level ProjectFeature::DISABLED } trait(:builds_disabled) { builds_access_level { ProjectFeature::DISABLED } }
trait(:builds_private) { builds_access_level ProjectFeature::PRIVATE } trait(:builds_private) { builds_access_level { ProjectFeature::PRIVATE } }
trait(:snippets_enabled) { snippets_access_level ProjectFeature::ENABLED } trait(:snippets_enabled) { snippets_access_level { ProjectFeature::ENABLED } }
trait(:snippets_disabled) { snippets_access_level ProjectFeature::DISABLED } trait(:snippets_disabled) { snippets_access_level { ProjectFeature::DISABLED } }
trait(:snippets_private) { snippets_access_level ProjectFeature::PRIVATE } trait(:snippets_private) { snippets_access_level { ProjectFeature::PRIVATE } }
trait(:issues_disabled) { issues_access_level ProjectFeature::DISABLED } trait(:issues_disabled) { issues_access_level { ProjectFeature::DISABLED } }
trait(:issues_enabled) { issues_access_level ProjectFeature::ENABLED } trait(:issues_enabled) { issues_access_level { ProjectFeature::ENABLED } }
trait(:issues_private) { issues_access_level ProjectFeature::PRIVATE } trait(:issues_private) { issues_access_level { ProjectFeature::PRIVATE } }
trait(:merge_requests_enabled) { merge_requests_access_level ProjectFeature::ENABLED } trait(:merge_requests_enabled) { merge_requests_access_level { ProjectFeature::ENABLED } }
trait(:merge_requests_disabled) { merge_requests_access_level ProjectFeature::DISABLED } trait(:merge_requests_disabled) { merge_requests_access_level { ProjectFeature::DISABLED } }
trait(:merge_requests_private) { merge_requests_access_level ProjectFeature::PRIVATE } trait(:merge_requests_private) { merge_requests_access_level { ProjectFeature::PRIVATE } }
trait(:merge_requests_public) { merge_requests_access_level ProjectFeature::PUBLIC } trait(:merge_requests_public) { merge_requests_access_level { ProjectFeature::PUBLIC } }
trait(:repository_enabled) { repository_access_level ProjectFeature::ENABLED } trait(:repository_enabled) { repository_access_level { ProjectFeature::ENABLED } }
trait(:repository_disabled) { repository_access_level ProjectFeature::DISABLED } trait(:repository_disabled) { repository_access_level { ProjectFeature::DISABLED } }
trait(:repository_private) { repository_access_level ProjectFeature::PRIVATE } trait(:repository_private) { repository_access_level { ProjectFeature::PRIVATE } }
trait(:pages_public) { pages_access_level ProjectFeature::PUBLIC } trait(:pages_public) { pages_access_level { ProjectFeature::PUBLIC } }
trait(:pages_enabled) { pages_access_level ProjectFeature::ENABLED } trait(:pages_enabled) { pages_access_level { ProjectFeature::ENABLED } }
trait(:pages_disabled) { pages_access_level ProjectFeature::DISABLED } trait(:pages_disabled) { pages_access_level { ProjectFeature::DISABLED } }
trait(:pages_private) { pages_access_level ProjectFeature::PRIVATE } trait(:pages_private) { pages_access_level { ProjectFeature::PRIVATE } }
trait :auto_devops do trait :auto_devops do
association :auto_devops, factory: :project_auto_devops association :auto_devops, factory: :project_auto_devops
...@@ -308,19 +308,19 @@ FactoryBot.define do ...@@ -308,19 +308,19 @@ FactoryBot.define do
end end
factory :redmine_project, parent: :project do factory :redmine_project, parent: :project do
has_external_issue_tracker true has_external_issue_tracker { true }
redmine_service redmine_service
end end
factory :youtrack_project, parent: :project do factory :youtrack_project, parent: :project do
has_external_issue_tracker true has_external_issue_tracker { true }
youtrack_service youtrack_service
end end
factory :jira_project, parent: :project do factory :jira_project, parent: :project do
has_external_issue_tracker true has_external_issue_tracker { true }
jira_service jira_service
end end
......
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
FactoryBot.define do FactoryBot.define do
factory :prometheus_metric, class: PrometheusMetric do factory :prometheus_metric, class: PrometheusMetric do
title 'title' title { 'title' }
query 'avg(metric)' query { 'avg(metric)' }
y_label 'y_label' y_label { 'y_label' }
unit 'm/s' unit { 'm/s' }
group :business group { :business }
project project
legend 'legend' legend { 'legend' }
trait :common do trait :common do
common true common { true }
project nil project { nil }
end end
end end
end end
...@@ -6,14 +6,14 @@ FactoryBot.define do ...@@ -6,14 +6,14 @@ FactoryBot.define do
project project
transient do transient do
default_push_level true default_push_level { true }
default_merge_level true default_merge_level { true }
default_access_level true default_access_level { true }
end end
trait :developers_can_push do trait :developers_can_push do
transient do transient do
default_push_level false default_push_level { false }
end end
after(:build) do |protected_branch| after(:build) do |protected_branch|
...@@ -23,7 +23,7 @@ FactoryBot.define do ...@@ -23,7 +23,7 @@ FactoryBot.define do
trait :developers_can_merge do trait :developers_can_merge do
transient do transient do
default_merge_level false default_merge_level { false }
end end
after(:build) do |protected_branch| after(:build) do |protected_branch|
...@@ -33,7 +33,7 @@ FactoryBot.define do ...@@ -33,7 +33,7 @@ FactoryBot.define do
trait :no_one_can_push do trait :no_one_can_push do
transient do transient do
default_push_level false default_push_level { false }
end end
after(:build) do |protected_branch| after(:build) do |protected_branch|
...@@ -43,7 +43,7 @@ FactoryBot.define do ...@@ -43,7 +43,7 @@ FactoryBot.define do
trait :maintainers_can_push do trait :maintainers_can_push do
transient do transient do
default_push_level false default_push_level { false }
end end
after(:build) do |protected_branch| after(:build) do |protected_branch|
......
...@@ -6,12 +6,12 @@ FactoryBot.define do ...@@ -6,12 +6,12 @@ FactoryBot.define do
project project
transient do transient do
default_access_level true default_access_level { true }
end end
trait :developers_can_create do trait :developers_can_create do
transient do transient do
default_access_level false default_access_level { false }
end end
after(:build) do |protected_tag| after(:build) do |protected_tag|
...@@ -21,7 +21,7 @@ FactoryBot.define do ...@@ -21,7 +21,7 @@ FactoryBot.define do
trait :no_one_can_create do trait :no_one_can_create do
transient do transient do
default_access_level false default_access_level { false }
end end
after(:build) do |protected_tag| after(:build) do |protected_tag|
...@@ -31,7 +31,7 @@ FactoryBot.define do ...@@ -31,7 +31,7 @@ FactoryBot.define do
trait :maintainers_can_create do trait :maintainers_can_create do
transient do transient do
default_access_level false default_access_level { false }
end end
after(:build) do |protected_tag| after(:build) do |protected_tag|
......
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
FactoryBot.define do FactoryBot.define do
factory :release do factory :release do
tag "v1.1.0" tag { "v1.1.0" }
sha 'b83d6e391c22777fca1ed3012fce84f633d7fed0' sha { 'b83d6e391c22777fca1ed3012fce84f633d7fed0' }
name { tag } name { tag }
description "Awesome release" description { "Awesome release" }
project project
author author
released_at { Time.zone.parse('2018-10-20T18:00:00Z') } released_at { Time.zone.parse('2018-10-20T18:00:00Z') }
trait :legacy do trait :legacy do
sha nil sha { nil }
author nil author { nil }
end end
end end
end end
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
FactoryBot.define do FactoryBot.define do
factory :remote_mirror, class: 'RemoteMirror' do factory :remote_mirror, class: 'RemoteMirror' do
association :project, :repository association :project, :repository
url "http://foo:bar@test.com" url { "http://foo:bar@test.com" }
end end
end end
...@@ -4,6 +4,6 @@ FactoryBot.define do ...@@ -4,6 +4,6 @@ FactoryBot.define do
factory :repository_language do factory :repository_language do
project project
programming_language programming_language
share 98.5 share { 98.5 }
end end
end end
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
FactoryBot.define do FactoryBot.define do
factory :resource_label_event do factory :resource_label_event do
action :add action { :add }
label label
user { issuable&.author || create(:user) } user { issuable&.author || create(:user) }
......
...@@ -3,54 +3,58 @@ ...@@ -3,54 +3,58 @@
FactoryBot.define do FactoryBot.define do
factory :service do factory :service do
project project
type 'Service' type { 'Service' }
end end
factory :custom_issue_tracker_service, class: CustomIssueTrackerService do factory :custom_issue_tracker_service, class: CustomIssueTrackerService do
project project
active true active { true }
issue_tracker issue_tracker
end end
factory :emails_on_push_service do factory :emails_on_push_service do
project project
type 'EmailsOnPushService' type { 'EmailsOnPushService' }
active true active { true }
push_events true push_events { true }
tag_push_events true tag_push_events { true }
properties( properties do
recipients: 'test@example.com', {
disable_diffs: true, recipients: 'test@example.com',
send_from_committer_email: true disable_diffs: true,
) send_from_committer_email: true
}
end
end end
factory :mock_deployment_service do factory :mock_deployment_service do
project project
type 'MockDeploymentService' type { 'MockDeploymentService' }
active true active { true }
end end
factory :prometheus_service do factory :prometheus_service do
project project
active true active { true }
properties({ properties do
api_url: 'https://prometheus.example.com/', {
manual_configuration: true api_url: 'https://prometheus.example.com/',
}) manual_configuration: true
}
end
end end
factory :jira_service do factory :jira_service do
project project
active true active { true }
transient do transient do
create_data true create_data { true }
url 'https://jira.example.com' url { 'https://jira.example.com' }
api_url nil api_url { nil }
username 'jira_username' username { 'jira_username' }
password 'jira_password' password { 'jira_password' }
jira_issue_transition_id '56-1' jira_issue_transition_id { '56-1' }
end end
after(:build) do |service, evaluator| after(:build) do |service, evaluator|
...@@ -65,34 +69,34 @@ FactoryBot.define do ...@@ -65,34 +69,34 @@ FactoryBot.define do
factory :bugzilla_service do factory :bugzilla_service do
project project
active true active { true }
issue_tracker issue_tracker
end end
factory :redmine_service do factory :redmine_service do
project project
active true active { true }
issue_tracker issue_tracker
end end
factory :youtrack_service do factory :youtrack_service do
project project
active true active { true }
issue_tracker issue_tracker
end end
factory :gitlab_issue_tracker_service do factory :gitlab_issue_tracker_service do
project project
active true active { true }
issue_tracker issue_tracker
end end
trait :issue_tracker do trait :issue_tracker do
transient do transient do
create_data true create_data { true }
project_url 'http://issuetracker.example.com' project_url { 'http://issuetracker.example.com' }
issues_url 'http://issues.example.com/issues/:id' issues_url { 'http://issues.example.com/issues/:id' }
new_issue_url 'http://new-issue.example.com' new_issue_url { 'http://new-issue.example.com' }
end end
after(:build) do |service, evaluator| after(:build) do |service, evaluator|
...@@ -105,29 +109,29 @@ FactoryBot.define do ...@@ -105,29 +109,29 @@ FactoryBot.define do
end end
trait :jira_cloud_service do trait :jira_cloud_service do
url 'https://mysite.atlassian.net' url { 'https://mysite.atlassian.net' }
username 'jira_user' username { 'jira_user' }
password 'my-secret-password' password { 'my-secret-password' }
end end
factory :hipchat_service do factory :hipchat_service do
project project
type 'HipchatService' type { 'HipchatService' }
token 'test_token' token { 'test_token' }
end end
# this is for testing storing values inside properties, which is deprecated and will be removed in # this is for testing storing values inside properties, which is deprecated and will be removed in
# https://gitlab.com/gitlab-org/gitlab/issues/29404 # https://gitlab.com/gitlab-org/gitlab/issues/29404
trait :without_properties_callback do trait :without_properties_callback do
jira_tracker_data nil jira_tracker_data { nil }
issue_tracker_data nil issue_tracker_data { nil }
create_data false create_data { false }
after(:build) do |service| after(:build) do |service|
IssueTrackerService.skip_callback(:validation, :before, :handle_properties) IssueTrackerService.skip_callback(:validation, :before, :handle_properties)
end end
to_create { |instance| instance.save(validate: false)} to_create { |instance| instance.save(validate: false) }
after(:create) do after(:create) do
IssueTrackerService.set_callback(:validation, :before, :handle_properties) IssueTrackerService.set_callback(:validation, :before, :handle_properties)
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
FactoryBot.define do FactoryBot.define do
factory :shard do factory :shard do
name "default" name { "default" }
end end
end end
...@@ -9,15 +9,15 @@ FactoryBot.define do ...@@ -9,15 +9,15 @@ FactoryBot.define do
file_name { generate(:filename) } file_name { generate(:filename) }
trait :public do trait :public do
visibility_level Snippet::PUBLIC visibility_level { Snippet::PUBLIC }
end end
trait :internal do trait :internal do
visibility_level Snippet::INTERNAL visibility_level { Snippet::INTERNAL }
end end
trait :private do trait :private do
visibility_level Snippet::PRIVATE visibility_level { Snippet::PRIVATE }
end end
end end
......
...@@ -4,7 +4,7 @@ FactoryBot.define do ...@@ -4,7 +4,7 @@ FactoryBot.define do
factory :spam_log do factory :spam_log do
user user
sequence(:source_ip) { |n| "42.42.42.#{n % 255}" } sequence(:source_ip) { |n| "42.42.42.#{n % 255}" }
noteable_type 'Issue' noteable_type { 'Issue' }
sequence(:title) { |n| "Spam title #{n}" } sequence(:title) { |n| "Spam title #{n}" }
description { "Spam description\nwith\nmultiple\nlines" } description { "Spam description\nwith\nmultiple\nlines" }
end end
......
...@@ -2,18 +2,18 @@ ...@@ -2,18 +2,18 @@
FactoryBot.define do FactoryBot.define do
factory :suggestion do factory :suggestion do
relative_order 0 relative_order { 0 }
association :note, factory: :diff_note_on_merge_request association :note, factory: :diff_note_on_merge_request
from_content " vars = {\n" from_content { " vars = {\n" }
to_content " vars = [\n" to_content { " vars = [\n" }
trait :unappliable do trait :unappliable do
from_content "foo" from_content { "foo" }
to_content "foo" to_content { "foo" }
end end
trait :applied do trait :applied do
applied true applied { true }
commit_id { RepoHelpers.sample_commit.id } commit_id { RepoHelpers.sample_commit.id }
end end
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
FactoryBot.define do FactoryBot.define do
factory :system_note_metadata do factory :system_note_metadata do
note note
action 'merge' action { 'merge' }
end end
end end
...@@ -7,10 +7,10 @@ FactoryBot.define do ...@@ -7,10 +7,10 @@ FactoryBot.define do
end end
trait :declined do trait :declined do
accepted false accepted { false }
end end
trait :accepted do trait :accepted do
accepted true accepted { true }
end end
end end
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
FactoryBot.define do FactoryBot.define do
factory :term, class: ApplicationSetting::Term do factory :term, class: ApplicationSetting::Term do
terms "Lorem ipsum dolor sit amet, consectetur adipiscing elit." terms { "Lorem ipsum dolor sit amet, consectetur adipiscing elit." }
end end
end end
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
FactoryBot.define do FactoryBot.define do
factory :timelog do factory :timelog do
time_spent 3600 time_spent { 3600 }
issue issue
user { issue.project.creator } user { issue.project.creator }
end end
......
...@@ -38,11 +38,11 @@ FactoryBot.define do ...@@ -38,11 +38,11 @@ FactoryBot.define do
end end
trait :pending do trait :pending do
state :pending state { :pending }
end end
trait :done do trait :done do
state :done state { :done }
end end
end end
...@@ -52,6 +52,6 @@ FactoryBot.define do ...@@ -52,6 +52,6 @@ FactoryBot.define do
user user
action { Todo::ASSIGNED } action { Todo::ASSIGNED }
commit_id { RepoHelpers.sample_commit.id } commit_id { RepoHelpers.sample_commit.id }
target_type "Commit" target_type { "Commit" }
end end
end end
...@@ -5,6 +5,6 @@ FactoryBot.define do ...@@ -5,6 +5,6 @@ FactoryBot.define do
certificate { FFaker::BaconIpsum.characters(728) } certificate { FFaker::BaconIpsum.characters(728) }
key_handle { FFaker::BaconIpsum.characters(86) } key_handle { FFaker::BaconIpsum.characters(86) }
public_key { FFaker::BaconIpsum.characters(88) } public_key { FFaker::BaconIpsum.characters(88) }
counter 0 counter { 0 }
end end
end end
...@@ -4,28 +4,28 @@ FactoryBot.define do ...@@ -4,28 +4,28 @@ FactoryBot.define do
factory :upload do factory :upload do
model { build(:project) } model { build(:project) }
size { 100.kilobytes } size { 100.kilobytes }
uploader "AvatarUploader" uploader { "AvatarUploader" }
mount_point :avatar mount_point { :avatar }
secret nil secret { nil }
store ObjectStorage::Store::LOCAL store { ObjectStorage::Store::LOCAL }
# we should build a mount agnostic upload by default # we should build a mount agnostic upload by default
transient do transient do
filename 'myfile.jpg' filename { 'myfile.jpg' }
end end
# this needs to comply with RecordsUpload::Concern#upload_path # this needs to comply with RecordsUpload::Concern#upload_path
path { File.join("uploads/-/system", model.class.underscore, mount_point.to_s, 'avatar.jpg') } path { File.join("uploads/-/system", model.class.underscore, mount_point.to_s, 'avatar.jpg') }
trait :personal_snippet_upload do trait :personal_snippet_upload do
uploader "PersonalFileUploader" uploader { "PersonalFileUploader" }
path { File.join(secret, filename) } path { File.join(secret, filename) }
model { build(:personal_snippet) } model { build(:personal_snippet) }
secret { SecureRandom.hex } secret { SecureRandom.hex }
end end
trait :issuable_upload do trait :issuable_upload do
uploader "FileUploader" uploader { "FileUploader" }
path { File.join(secret, filename) } path { File.join(secret, filename) }
secret { SecureRandom.hex } secret { SecureRandom.hex }
end end
...@@ -38,27 +38,27 @@ FactoryBot.define do ...@@ -38,27 +38,27 @@ FactoryBot.define do
end end
trait :object_storage do trait :object_storage do
store ObjectStorage::Store::REMOTE store { ObjectStorage::Store::REMOTE }
end end
trait :namespace_upload do trait :namespace_upload do
model { build(:group) } model { build(:group) }
path { File.join(secret, filename) } path { File.join(secret, filename) }
uploader "NamespaceFileUploader" uploader { "NamespaceFileUploader" }
secret { SecureRandom.hex } secret { SecureRandom.hex }
end end
trait :favicon_upload do trait :favicon_upload do
model { build(:appearance) } model { build(:appearance) }
path { File.join(secret, filename) } path { File.join(secret, filename) }
uploader "FaviconUploader" uploader { "FaviconUploader" }
secret { SecureRandom.hex } secret { SecureRandom.hex }
end end
trait :attachment_upload do trait :attachment_upload do
mount_point :attachment mount_point { :attachment }
model { build(:note) } model { build(:note) }
uploader "AttachmentUploader" uploader { "AttachmentUploader" }
end end
end end
end end
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
FactoryBot.define do FactoryBot.define do
factory :user_agent_detail do factory :user_agent_detail do
ip_address '127.0.0.1' ip_address { '127.0.0.1' }
user_agent 'AppleWebKit/537.36' user_agent { 'AppleWebKit/537.36' }
association :subject, factory: :issue association :subject, factory: :issue
end end
end end
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
FactoryBot.define do FactoryBot.define do
factory :user_callout do factory :user_callout do
feature_name :gke_cluster_integration feature_name { :gke_cluster_integration }
user user
end end
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
FactoryBot.define do FactoryBot.define do
factory :user_status do factory :user_status do
user user
emoji 'coffee' emoji { 'coffee' }
message 'I crave coffee' message { 'I crave coffee' }
end end
end end
...@@ -5,17 +5,17 @@ FactoryBot.define do ...@@ -5,17 +5,17 @@ FactoryBot.define do
email { generate(:email) } email { generate(:email) }
name { generate(:name) } name { generate(:name) }
username { generate(:username) } username { generate(:username) }
password "12345678" password { "12345678" }
confirmed_at { Time.now } confirmed_at { Time.now }
confirmation_token { nil } confirmation_token { nil }
can_create_group true can_create_group { true }
after(:stub) do |user| after(:stub) do |user|
user.notification_email = user.email user.notification_email = user.email
end end
trait :admin do trait :admin do
admin true admin { true }
end end
trait :blocked do trait :blocked do
...@@ -23,7 +23,7 @@ FactoryBot.define do ...@@ -23,7 +23,7 @@ FactoryBot.define do
end end
trait :external do trait :external do
external true external { true }
end end
trait :two_factor do trait :two_factor do
...@@ -31,7 +31,7 @@ FactoryBot.define do ...@@ -31,7 +31,7 @@ FactoryBot.define do
end end
trait :ghost do trait :ghost do
ghost true ghost { true }
after(:build) { |user, _| user.block! } after(:build) { |user, _| user.block! }
end end
...@@ -40,11 +40,11 @@ FactoryBot.define do ...@@ -40,11 +40,11 @@ FactoryBot.define do
end end
trait :with_sign_ins do trait :with_sign_ins do
sign_in_count 3 sign_in_count { 3 }
current_sign_in_at { Time.now } current_sign_in_at { Time.now }
last_sign_in_at { FFaker::Time.between(10.days.ago, 1.day.ago) } last_sign_in_at { FFaker::Time.between(10.days.ago, 1.day.ago) }
current_sign_in_ip '127.0.0.1' current_sign_in_ip { '127.0.0.1' }
last_sign_in_ip '127.0.0.1' last_sign_in_ip { '127.0.0.1' }
end end
trait :two_factor_via_otp do trait :two_factor_via_otp do
...@@ -57,7 +57,7 @@ FactoryBot.define do ...@@ -57,7 +57,7 @@ FactoryBot.define do
end end
trait :two_factor_via_u2f do trait :two_factor_via_u2f do
transient { registrations_count 5 } transient { registrations_count { 5 } }
after(:create) do |user, evaluator| after(:create) do |user, evaluator|
create_list(:u2f_registration, evaluator.registrations_count, user: user) create_list(:u2f_registration, evaluator.registrations_count, user: user)
...@@ -65,7 +65,7 @@ FactoryBot.define do ...@@ -65,7 +65,7 @@ FactoryBot.define do
end end
trait :readme do trait :readme do
project_view :readme project_view { :readme }
end end
trait :commit_email do trait :commit_email do
...@@ -77,7 +77,7 @@ FactoryBot.define do ...@@ -77,7 +77,7 @@ FactoryBot.define do
end end
transient do transient do
developer_projects [] developer_projects { [] }
end end
after(:create) do |user, evaluator| after(:create) do |user, evaluator|
...@@ -88,8 +88,8 @@ FactoryBot.define do ...@@ -88,8 +88,8 @@ FactoryBot.define do
factory :omniauth_user do factory :omniauth_user do
transient do transient do
extern_uid '123456' extern_uid { '123456' }
provider 'ldapmain' provider { 'ldapmain' }
end end
after(:create) do |user, evaluator| after(:create) do |user, evaluator|
......
...@@ -3,14 +3,20 @@ ...@@ -3,14 +3,20 @@
FactoryBot.define do FactoryBot.define do
factory :web_hook_log do factory :web_hook_log do
web_hook factory: :project_hook web_hook factory: :project_hook
trigger 'push_hooks' trigger { 'push_hooks' }
url { generate(:url) } url { generate(:url) }
request_headers {} request_headers do
request_data {} {}
response_headers {} end
response_body '' request_data do
response_status '200' {}
execution_duration 2.0 end
internal_error_message nil response_headers do
{}
end
response_body { '' }
response_status { '200' }
execution_duration { 2.0 }
internal_error_message { nil }
end end
end end
...@@ -4,7 +4,7 @@ FactoryBot.define do ...@@ -4,7 +4,7 @@ FactoryBot.define do
factory :wiki_directory do factory :wiki_directory do
skip_create skip_create
slug '/path_up_to/dir' slug { '/path_up_to/dir' }
initialize_with { new(slug) } initialize_with { new(slug) }
end end
end end
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