2019-07-25 01:11:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-29 05:47:54 -04:00
|
|
|
require_relative '../support/helpers/test_env'
|
2017-05-31 09:43:19 -04:00
|
|
|
|
2017-12-13 19:13:44 -05:00
|
|
|
FactoryBot.define do
|
2014-11-30 03:50:15 -05:00
|
|
|
# Project without repository
|
|
|
|
#
|
|
|
|
# Project does not have bare repository.
|
2016-07-05 18:24:35 -04:00
|
|
|
# Use this factory if you don't need repository in tests
|
2017-08-02 15:43:24 -04:00
|
|
|
factory :project, class: 'Project' do
|
2014-07-31 13:13:27 -04:00
|
|
|
sequence(:name) { |n| "project#{n}" }
|
|
|
|
path { name.downcase.gsub(/\s/, '_') }
|
2020-10-22 20:08:30 -04:00
|
|
|
|
|
|
|
# Behaves differently to nil due to cache_has_external_* methods.
|
2019-10-01 20:06:26 -04:00
|
|
|
has_external_issue_tracker { false }
|
2020-10-22 20:08:30 -04:00
|
|
|
has_external_wiki { false }
|
2016-10-06 17:17:11 -04:00
|
|
|
|
2017-08-09 05:31:25 -04:00
|
|
|
# Associations
|
|
|
|
namespace
|
2020-10-06 08:08:38 -04:00
|
|
|
creator { group ? association(:user) : namespace&.owner }
|
2017-08-09 05:31:25 -04:00
|
|
|
|
|
|
|
transient do
|
2017-11-08 07:08:13 -05:00
|
|
|
# Nest Project Feature attributes
|
2019-10-01 20:06:26 -04:00
|
|
|
wiki_access_level { ProjectFeature::ENABLED }
|
|
|
|
builds_access_level { ProjectFeature::ENABLED }
|
|
|
|
snippets_access_level { ProjectFeature::ENABLED }
|
|
|
|
issues_access_level { ProjectFeature::ENABLED }
|
2020-01-17 13:08:41 -05:00
|
|
|
forking_access_level { ProjectFeature::ENABLED }
|
2019-10-01 20:06:26 -04:00
|
|
|
merge_requests_access_level { ProjectFeature::ENABLED }
|
|
|
|
repository_access_level { ProjectFeature::ENABLED }
|
2021-02-11 10:09:11 -05:00
|
|
|
analytics_access_level { ProjectFeature::ENABLED }
|
2019-07-17 15:52:03 -04:00
|
|
|
pages_access_level do
|
|
|
|
visibility_level == Gitlab::VisibilityLevel::PUBLIC ? ProjectFeature::ENABLED : ProjectFeature::PRIVATE
|
|
|
|
end
|
2020-10-01 14:10:20 -04:00
|
|
|
metrics_dashboard_access_level { ProjectFeature::PRIVATE }
|
2020-11-27 07:09:14 -05:00
|
|
|
operations_access_level { ProjectFeature::ENABLED }
|
2021-07-26 08:10:08 -04:00
|
|
|
container_registry_access_level { ProjectFeature::ENABLED }
|
2022-02-25 10:16:30 -05:00
|
|
|
security_and_compliance_access_level { ProjectFeature::PRIVATE }
|
2018-05-03 09:38:55 -04:00
|
|
|
|
|
|
|
# we can't assign the delegated `#ci_cd_settings` attributes directly, as the
|
|
|
|
# `#ci_cd_settings` relation needs to be created first
|
2019-10-01 20:06:26 -04:00
|
|
|
group_runners_enabled { nil }
|
2020-12-15 13:10:06 -05:00
|
|
|
merge_pipelines_enabled { nil }
|
|
|
|
merge_trains_enabled { nil }
|
2021-02-09 04:09:19 -05:00
|
|
|
keep_latest_artifact { nil }
|
2019-10-01 20:06:26 -04:00
|
|
|
import_status { nil }
|
|
|
|
import_jid { nil }
|
2020-04-21 11:21:10 -04:00
|
|
|
import_correlation_id { nil }
|
|
|
|
import_last_error { nil }
|
2020-02-17 04:08:52 -05:00
|
|
|
forward_deployment_enabled { nil }
|
2021-01-14 07:10:54 -05:00
|
|
|
restrict_user_defined_variables { nil }
|
2021-06-14 08:10:13 -04:00
|
|
|
ci_job_token_scope_enabled { nil }
|
2022-01-19 07:17:41 -05:00
|
|
|
runner_token_expiration_interval { nil }
|
|
|
|
runner_token_expiration_interval_human_readable { nil }
|
2017-08-09 05:31:25 -04:00
|
|
|
end
|
|
|
|
|
2021-08-04 17:09:04 -04:00
|
|
|
after(:build) do |project, evaluator|
|
2017-08-09 05:31:25 -04:00
|
|
|
# Builds and MRs can't have higher visibility level than repository access level.
|
|
|
|
builds_access_level = [evaluator.builds_access_level, evaluator.repository_access_level].min
|
|
|
|
merge_requests_access_level = [evaluator.merge_requests_access_level, evaluator.repository_access_level].min
|
|
|
|
|
2018-10-05 09:41:11 -04:00
|
|
|
hash = {
|
2017-08-09 05:31:25 -04:00
|
|
|
wiki_access_level: evaluator.wiki_access_level,
|
|
|
|
builds_access_level: builds_access_level,
|
|
|
|
snippets_access_level: evaluator.snippets_access_level,
|
|
|
|
issues_access_level: evaluator.issues_access_level,
|
2020-01-17 13:08:41 -05:00
|
|
|
forking_access_level: evaluator.forking_access_level,
|
2017-08-09 05:31:25 -04:00
|
|
|
merge_requests_access_level: merge_requests_access_level,
|
2020-08-21 11:10:03 -04:00
|
|
|
repository_access_level: evaluator.repository_access_level,
|
2020-10-01 14:10:20 -04:00
|
|
|
pages_access_level: evaluator.pages_access_level,
|
2020-11-27 07:09:14 -05:00
|
|
|
metrics_dashboard_access_level: evaluator.metrics_dashboard_access_level,
|
2021-02-11 10:09:11 -05:00
|
|
|
operations_access_level: evaluator.operations_access_level,
|
2021-08-04 17:09:04 -04:00
|
|
|
analytics_access_level: evaluator.analytics_access_level,
|
2022-02-25 10:16:30 -05:00
|
|
|
container_registry_access_level: evaluator.container_registry_access_level,
|
|
|
|
security_and_compliance_access_level: evaluator.security_and_compliance_access_level
|
2018-10-05 09:41:11 -04:00
|
|
|
}
|
|
|
|
|
2020-09-03 14:08:29 -04:00
|
|
|
project.build_project_feature(hash)
|
|
|
|
end
|
2017-08-09 05:31:25 -04:00
|
|
|
|
2020-09-03 14:08:29 -04:00
|
|
|
after(:create) do |project, evaluator|
|
2017-08-09 05:31:25 -04:00
|
|
|
# Normally the class Projects::CreateService is used for creating
|
|
|
|
# projects, and this class takes care of making sure the owner and current
|
|
|
|
# user have access to the project. Our specs don't use said service class,
|
|
|
|
# thus we must manually refresh things here.
|
|
|
|
unless project.group || project.pending_delete
|
2022-01-21 16:16:35 -05:00
|
|
|
project.add_maintainer(project.first_owner)
|
2017-08-09 05:31:25 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
project.group&.refresh_members_authorized_projects
|
2018-05-03 09:38:55 -04:00
|
|
|
|
|
|
|
# assign the delegated `#ci_cd_settings` attributes after create
|
2020-12-15 13:10:06 -05:00
|
|
|
project.group_runners_enabled = evaluator.group_runners_enabled unless evaluator.group_runners_enabled.nil?
|
|
|
|
project.merge_pipelines_enabled = evaluator.merge_pipelines_enabled unless evaluator.merge_pipelines_enabled.nil?
|
|
|
|
project.merge_trains_enabled = evaluator.merge_trains_enabled unless evaluator.merge_trains_enabled.nil?
|
2021-02-09 04:09:19 -05:00
|
|
|
project.keep_latest_artifact = evaluator.keep_latest_artifact unless evaluator.keep_latest_artifact.nil?
|
2021-01-14 07:10:54 -05:00
|
|
|
project.restrict_user_defined_variables = evaluator.restrict_user_defined_variables unless evaluator.restrict_user_defined_variables.nil?
|
2021-06-14 08:10:13 -04:00
|
|
|
project.ci_job_token_scope_enabled = evaluator.ci_job_token_scope_enabled unless evaluator.ci_job_token_scope_enabled.nil?
|
2022-01-19 07:17:41 -05:00
|
|
|
project.runner_token_expiration_interval = evaluator.runner_token_expiration_interval unless evaluator.runner_token_expiration_interval.nil?
|
|
|
|
project.runner_token_expiration_interval_human_readable = evaluator.runner_token_expiration_interval_human_readable unless evaluator.runner_token_expiration_interval_human_readable.nil?
|
2018-11-27 04:41:27 -05:00
|
|
|
|
|
|
|
if evaluator.import_status
|
|
|
|
import_state = project.import_state || project.build_import_state
|
|
|
|
import_state.status = evaluator.import_status
|
|
|
|
import_state.jid = evaluator.import_jid
|
2020-04-21 11:21:10 -04:00
|
|
|
import_state.correlation_id_value = evaluator.import_correlation_id
|
|
|
|
import_state.last_error = evaluator.import_last_error
|
2020-07-21 08:09:30 -04:00
|
|
|
import_state.save!
|
2018-11-27 04:41:27 -05:00
|
|
|
end
|
2021-12-31 13:16:55 -05:00
|
|
|
|
|
|
|
# simulating ::Projects::ProcessSyncEventsWorker because most tests don't run Sidekiq inline
|
|
|
|
project.create_ci_project_mirror!(namespace_id: project.namespace_id) unless project.ci_project_mirror
|
2017-08-09 05:31:25 -04:00
|
|
|
end
|
|
|
|
|
2014-07-31 13:13:27 -04:00
|
|
|
trait :public do
|
2019-10-01 20:06:26 -04:00
|
|
|
visibility_level { Gitlab::VisibilityLevel::PUBLIC }
|
2014-07-31 13:13:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :internal do
|
2019-10-01 20:06:26 -04:00
|
|
|
visibility_level { Gitlab::VisibilityLevel::INTERNAL }
|
2014-07-31 13:13:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :private do
|
2019-10-01 20:06:26 -04:00
|
|
|
visibility_level { Gitlab::VisibilityLevel::PRIVATE }
|
2014-07-31 13:13:27 -04:00
|
|
|
end
|
2016-05-04 17:05:16 -04:00
|
|
|
|
2017-06-01 10:27:35 -04:00
|
|
|
trait :import_scheduled do
|
2019-10-01 20:06:26 -04:00
|
|
|
import_status { :scheduled }
|
2017-06-01 10:27:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :import_started do
|
2019-10-01 20:06:26 -04:00
|
|
|
import_status { :started }
|
2017-06-01 10:27:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :import_finished do
|
2019-10-01 20:06:26 -04:00
|
|
|
import_status { :finished }
|
2017-06-01 10:27:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :import_failed do
|
2019-10-01 20:06:26 -04:00
|
|
|
import_status { :failed }
|
2017-06-01 10:27:35 -04:00
|
|
|
end
|
|
|
|
|
2020-09-01 08:11:01 -04:00
|
|
|
trait :jira_dvcs_cloud do
|
|
|
|
before(:create) do |project|
|
|
|
|
create(:project_feature_usage, :dvcs_cloud, project: project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :jira_dvcs_server do
|
|
|
|
before(:create) do |project|
|
|
|
|
create(:project_feature_usage, :dvcs_server, project: project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-04 03:30:11 -05:00
|
|
|
trait :archived do
|
2019-10-01 20:06:26 -04:00
|
|
|
archived { true }
|
2017-01-04 03:30:11 -05:00
|
|
|
end
|
|
|
|
|
2022-02-23 04:12:16 -05:00
|
|
|
trait :hidden do
|
|
|
|
hidden { true }
|
|
|
|
end
|
|
|
|
|
2020-03-27 14:07:48 -04:00
|
|
|
trait :last_repository_check_failed do
|
|
|
|
last_repository_check_failed { true }
|
|
|
|
end
|
|
|
|
|
2019-10-01 20:06:26 -04:00
|
|
|
storage_version { Project::LATEST_STORAGE_VERSION }
|
2017-12-01 08:58:49 -05:00
|
|
|
|
|
|
|
trait :legacy_storage do
|
2019-10-01 20:06:26 -04:00
|
|
|
storage_version { nil }
|
2017-08-04 01:30:42 -04:00
|
|
|
end
|
|
|
|
|
2019-10-16 08:06:32 -04:00
|
|
|
trait :request_access_disabled do
|
|
|
|
request_access_enabled { false }
|
2016-11-11 07:51:50 -05:00
|
|
|
end
|
|
|
|
|
2017-05-01 16:15:16 -04:00
|
|
|
trait :with_avatar do
|
2018-02-01 14:24:59 -05:00
|
|
|
avatar { fixture_file_upload('spec/fixtures/dk.png') }
|
2017-05-01 16:15:16 -04:00
|
|
|
end
|
|
|
|
|
2018-01-23 14:03:02 -05:00
|
|
|
trait :with_export do
|
2018-06-25 09:10:26 -04:00
|
|
|
after(:create) do |project, _evaluator|
|
|
|
|
ProjectExportWorker.new.perform(project.creator.id, project.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-17 12:17:15 -04:00
|
|
|
trait :broken_storage do
|
|
|
|
after(:create) do |project|
|
|
|
|
project.update_column(:repository_storage, 'broken')
|
|
|
|
end
|
|
|
|
end
|
2020-01-11 10:07:49 -05:00
|
|
|
|
2018-09-03 10:21:15 -04:00
|
|
|
# Build a custom repository by specifying a hash of `filename => content` in
|
|
|
|
# the transient `files` attribute. Each file will be created in its own
|
|
|
|
# commit, operating against the master branch. So, the following call:
|
|
|
|
#
|
|
|
|
# create(:project, :custom_repo, files: { 'foo/a.txt' => 'foo', 'b.txt' => bar' })
|
|
|
|
#
|
|
|
|
# will create a repository containing two files, and two commits, in master
|
|
|
|
trait :custom_repo do
|
|
|
|
transient do
|
2019-10-01 20:06:26 -04:00
|
|
|
files { {} }
|
2018-09-03 10:21:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
after :create do |project, evaluator|
|
2021-11-25 10:09:54 -05:00
|
|
|
raise "Failed to create repository!" unless project.repository.exists? || project.create_repository
|
2018-09-03 10:21:15 -04:00
|
|
|
|
|
|
|
evaluator.files.each do |filename, content|
|
|
|
|
project.repository.create_file(
|
|
|
|
project.creator,
|
|
|
|
filename,
|
|
|
|
content,
|
|
|
|
message: "Automatically created file #{filename}",
|
2021-05-04 08:10:04 -04:00
|
|
|
branch_name: project.default_branch || 'master'
|
2018-09-03 10:21:15 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-02 15:55:11 -04:00
|
|
|
# Test repository - https://gitlab.com/gitlab-org/gitlab-test
|
2017-01-16 23:06:18 -05:00
|
|
|
trait :repository do
|
2017-08-02 15:43:24 -04:00
|
|
|
test_repo
|
|
|
|
|
|
|
|
transient do
|
2019-10-01 20:06:26 -04:00
|
|
|
create_templates { nil }
|
2020-06-30 08:08:57 -04:00
|
|
|
create_branch { nil }
|
2017-08-02 15:43:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
after :create do |project, evaluator|
|
2017-08-09 05:31:25 -04:00
|
|
|
if evaluator.create_templates
|
|
|
|
templates_path = "#{evaluator.create_templates}_templates"
|
2017-08-02 15:43:24 -04:00
|
|
|
|
|
|
|
project.repository.create_file(
|
2017-08-09 05:31:25 -04:00
|
|
|
project.creator,
|
|
|
|
".gitlab/#{templates_path}/bug.md",
|
2017-08-02 15:43:24 -04:00
|
|
|
'something valid',
|
|
|
|
message: 'test 3',
|
|
|
|
branch_name: 'master')
|
|
|
|
project.repository.create_file(
|
2017-08-09 05:31:25 -04:00
|
|
|
project.creator,
|
|
|
|
".gitlab/#{templates_path}/template_test.md",
|
2017-08-02 15:43:24 -04:00
|
|
|
'template_test',
|
|
|
|
message: 'test 1',
|
|
|
|
branch_name: 'master')
|
|
|
|
project.repository.create_file(
|
2017-08-09 05:31:25 -04:00
|
|
|
project.creator,
|
|
|
|
".gitlab/#{templates_path}/feature_proposal.md",
|
2017-08-02 15:43:24 -04:00
|
|
|
'feature_proposal',
|
|
|
|
message: 'test 2',
|
|
|
|
branch_name: 'master')
|
|
|
|
end
|
2020-06-30 08:08:57 -04:00
|
|
|
|
|
|
|
if evaluator.create_branch
|
|
|
|
project.repository.create_file(
|
|
|
|
project.creator,
|
|
|
|
'README.md',
|
|
|
|
"README on branch #{evaluator.create_branch}",
|
|
|
|
message: 'Add README.md',
|
|
|
|
branch_name: evaluator.create_branch)
|
|
|
|
|
|
|
|
end
|
2021-05-19 05:10:19 -04:00
|
|
|
|
|
|
|
project.track_project_repository
|
2017-08-02 15:43:24 -04:00
|
|
|
end
|
2017-01-16 23:06:18 -05:00
|
|
|
end
|
|
|
|
|
2016-05-04 17:05:16 -04:00
|
|
|
trait :empty_repo do
|
|
|
|
after(:create) do |project|
|
2017-03-08 12:04:44 -05:00
|
|
|
raise "Failed to create repository!" unless project.create_repository
|
2016-05-04 17:05:16 -04:00
|
|
|
end
|
|
|
|
end
|
2016-08-01 18:31:21 -04:00
|
|
|
|
2020-05-04 02:10:10 -04:00
|
|
|
trait :design_repo do
|
|
|
|
after(:create) do |project|
|
|
|
|
raise 'Failed to create design repository!' unless project.design_repository.create_if_not_exists
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-03 08:55:14 -04:00
|
|
|
trait :remote_mirror do
|
|
|
|
transient do
|
2019-10-01 20:06:26 -04:00
|
|
|
url { "http://foo.com" }
|
|
|
|
enabled { true }
|
2018-05-03 08:55:14 -04:00
|
|
|
end
|
|
|
|
after(:create) do |project, evaluator|
|
|
|
|
project.remote_mirrors.create!(url: evaluator.url, enabled: evaluator.enabled)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-18 09:52:55 -04:00
|
|
|
trait :stubbed_repository do
|
|
|
|
after(:build) do |project|
|
|
|
|
allow(project).to receive(:empty_repo?).and_return(false)
|
|
|
|
allow(project.repository).to receive(:empty?).and_return(false)
|
2016-05-04 17:05:16 -04:00
|
|
|
end
|
|
|
|
end
|
2016-08-01 18:31:21 -04:00
|
|
|
|
2017-09-06 01:16:26 -04:00
|
|
|
trait :wiki_repo do
|
|
|
|
after(:create) do |project|
|
|
|
|
raise 'Failed to create wiki repository!' unless project.create_wiki
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-19 03:44:58 -04:00
|
|
|
trait :read_only do
|
2019-10-01 20:06:26 -04:00
|
|
|
repository_read_only { true }
|
2017-09-05 22:24:31 -04:00
|
|
|
end
|
|
|
|
|
2016-09-23 03:42:07 -04:00
|
|
|
trait :broken_repo do
|
|
|
|
after(:create) do |project|
|
2019-10-23 05:06:03 -04:00
|
|
|
TestEnv.rm_storage_dir(project.repository_storage, "#{project.disk_path}.git/refs")
|
2016-09-23 03:42:07 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-12-14 19:59:04 -05:00
|
|
|
trait :test_repo do
|
|
|
|
after :create do |project|
|
2017-05-10 11:31:50 -04:00
|
|
|
TestEnv.copy_repo(project,
|
|
|
|
bare_repo: TestEnv.factory_repo_path_bare,
|
|
|
|
refs: TestEnv::BRANCH_SHA)
|
2016-12-14 19:59:04 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-09-30 08:09:53 -04:00
|
|
|
trait :with_import_url do
|
|
|
|
import_finished
|
|
|
|
|
|
|
|
import_url { generate(:url) }
|
|
|
|
end
|
|
|
|
|
2019-10-01 20:06:26 -04:00
|
|
|
trait(:wiki_enabled) { wiki_access_level { ProjectFeature::ENABLED } }
|
|
|
|
trait(:wiki_disabled) { wiki_access_level { ProjectFeature::DISABLED } }
|
|
|
|
trait(:wiki_private) { wiki_access_level { ProjectFeature::PRIVATE } }
|
|
|
|
trait(:builds_enabled) { builds_access_level { ProjectFeature::ENABLED } }
|
|
|
|
trait(:builds_disabled) { builds_access_level { ProjectFeature::DISABLED } }
|
|
|
|
trait(:builds_private) { builds_access_level { ProjectFeature::PRIVATE } }
|
|
|
|
trait(:snippets_enabled) { snippets_access_level { ProjectFeature::ENABLED } }
|
|
|
|
trait(:snippets_disabled) { snippets_access_level { ProjectFeature::DISABLED } }
|
|
|
|
trait(:snippets_private) { snippets_access_level { ProjectFeature::PRIVATE } }
|
|
|
|
trait(:issues_disabled) { issues_access_level { ProjectFeature::DISABLED } }
|
|
|
|
trait(:issues_enabled) { issues_access_level { ProjectFeature::ENABLED } }
|
|
|
|
trait(:issues_private) { issues_access_level { ProjectFeature::PRIVATE } }
|
2020-01-17 13:08:41 -05:00
|
|
|
trait(:forking_disabled) { forking_access_level { ProjectFeature::DISABLED } }
|
|
|
|
trait(:forking_enabled) { forking_access_level { ProjectFeature::ENABLED } }
|
|
|
|
trait(:forking_private) { forking_access_level { ProjectFeature::PRIVATE } }
|
2019-10-01 20:06:26 -04:00
|
|
|
trait(:merge_requests_enabled) { merge_requests_access_level { ProjectFeature::ENABLED } }
|
|
|
|
trait(:merge_requests_disabled) { merge_requests_access_level { ProjectFeature::DISABLED } }
|
|
|
|
trait(:merge_requests_private) { merge_requests_access_level { ProjectFeature::PRIVATE } }
|
|
|
|
trait(:merge_requests_public) { merge_requests_access_level { ProjectFeature::PUBLIC } }
|
|
|
|
trait(:repository_enabled) { repository_access_level { ProjectFeature::ENABLED } }
|
|
|
|
trait(:repository_disabled) { repository_access_level { ProjectFeature::DISABLED } }
|
|
|
|
trait(:repository_private) { repository_access_level { ProjectFeature::PRIVATE } }
|
|
|
|
trait(:pages_public) { pages_access_level { ProjectFeature::PUBLIC } }
|
|
|
|
trait(:pages_enabled) { pages_access_level { ProjectFeature::ENABLED } }
|
|
|
|
trait(:pages_disabled) { pages_access_level { ProjectFeature::DISABLED } }
|
|
|
|
trait(:pages_private) { pages_access_level { ProjectFeature::PRIVATE } }
|
2020-10-01 14:10:20 -04:00
|
|
|
trait(:metrics_dashboard_enabled) { metrics_dashboard_access_level { ProjectFeature::ENABLED } }
|
|
|
|
trait(:metrics_dashboard_disabled) { metrics_dashboard_access_level { ProjectFeature::DISABLED } }
|
|
|
|
trait(:metrics_dashboard_private) { metrics_dashboard_access_level { ProjectFeature::PRIVATE } }
|
2020-11-27 07:09:14 -05:00
|
|
|
trait(:operations_enabled) { operations_access_level { ProjectFeature::ENABLED } }
|
|
|
|
trait(:operations_disabled) { operations_access_level { ProjectFeature::DISABLED } }
|
|
|
|
trait(:operations_private) { operations_access_level { ProjectFeature::PRIVATE } }
|
2021-02-11 10:09:11 -05:00
|
|
|
trait(:analytics_enabled) { analytics_access_level { ProjectFeature::ENABLED } }
|
|
|
|
trait(:analytics_disabled) { analytics_access_level { ProjectFeature::DISABLED } }
|
|
|
|
trait(:analytics_private) { analytics_access_level { ProjectFeature::PRIVATE } }
|
2021-07-26 08:10:08 -04:00
|
|
|
trait(:container_registry_enabled) { container_registry_access_level { ProjectFeature::ENABLED } }
|
|
|
|
trait(:container_registry_disabled) { container_registry_access_level { ProjectFeature::DISABLED } }
|
|
|
|
trait(:container_registry_private) { container_registry_access_level { ProjectFeature::PRIVATE } }
|
2022-02-25 10:16:30 -05:00
|
|
|
trait(:security_and_compliance_enabled) { security_and_compliance_access_level { ProjectFeature::ENABLED } }
|
|
|
|
trait(:security_and_compliance_disabled) { security_and_compliance_access_level { ProjectFeature::DISABLED } }
|
|
|
|
trait(:security_and_compliance_private) { security_and_compliance_access_level { ProjectFeature::PRIVATE } }
|
2018-09-06 15:20:42 -04:00
|
|
|
|
|
|
|
trait :auto_devops do
|
|
|
|
association :auto_devops, factory: :project_auto_devops
|
|
|
|
end
|
2019-03-12 06:15:33 -04:00
|
|
|
|
|
|
|
trait :auto_devops_disabled do
|
|
|
|
association :auto_devops, factory: [:project_auto_devops, :disabled]
|
|
|
|
end
|
2020-06-03 17:08:23 -04:00
|
|
|
|
|
|
|
trait :without_container_expiration_policy do
|
|
|
|
after :create do |project|
|
|
|
|
project.container_expiration_policy.destroy!
|
|
|
|
end
|
|
|
|
end
|
2014-07-31 13:13:27 -04:00
|
|
|
end
|
|
|
|
|
2020-07-09 05:09:27 -04:00
|
|
|
trait :service_desk_disabled do
|
|
|
|
service_desk_enabled { nil }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait(:service_desk_enabled) do
|
|
|
|
service_desk_enabled { true }
|
|
|
|
end
|
|
|
|
|
2022-03-14 02:07:47 -04:00
|
|
|
trait :with_error_tracking_setting do
|
|
|
|
error_tracking_setting { association :project_error_tracking_setting }
|
|
|
|
end
|
|
|
|
|
2014-11-30 03:50:15 -05:00
|
|
|
# Project with empty repository
|
|
|
|
#
|
|
|
|
# This is a case when you just created a project
|
|
|
|
# but not pushed any code there yet
|
2017-08-02 15:43:24 -04:00
|
|
|
factory :project_empty_repo, parent: :project do
|
2016-05-04 17:05:16 -04:00
|
|
|
empty_repo
|
2014-11-30 03:50:15 -05:00
|
|
|
end
|
|
|
|
|
2016-09-23 03:42:07 -04:00
|
|
|
# Project with broken repository
|
|
|
|
#
|
|
|
|
# Project with an invalid repository state
|
2017-08-02 15:43:24 -04:00
|
|
|
factory :project_broken_repo, parent: :project do
|
2016-09-23 03:42:07 -04:00
|
|
|
broken_repo
|
|
|
|
end
|
|
|
|
|
2017-08-02 15:43:24 -04:00
|
|
|
factory :forked_project_with_submodules, parent: :project do
|
2015-04-13 01:27:45 -04:00
|
|
|
path { 'forked-gitlabhq' }
|
|
|
|
|
|
|
|
after :create do |project|
|
2017-05-10 11:31:50 -04:00
|
|
|
TestEnv.copy_repo(project,
|
|
|
|
bare_repo: TestEnv.forked_repo_path_bare,
|
|
|
|
refs: TestEnv::FORKED_BRANCH_SHA)
|
2015-04-13 01:27:45 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-07-31 13:13:27 -04:00
|
|
|
factory :redmine_project, parent: :project do
|
2019-10-01 20:06:26 -04:00
|
|
|
has_external_issue_tracker { true }
|
2016-10-06 17:17:11 -04:00
|
|
|
|
2021-06-18 11:10:16 -04:00
|
|
|
redmine_integration
|
2014-07-31 13:13:27 -04:00
|
|
|
end
|
2015-04-29 14:28:24 -04:00
|
|
|
|
2019-02-18 12:08:36 -05:00
|
|
|
factory :youtrack_project, parent: :project do
|
2019-10-01 20:06:26 -04:00
|
|
|
has_external_issue_tracker { true }
|
2019-02-18 12:08:36 -05:00
|
|
|
|
2021-06-21 08:07:45 -04:00
|
|
|
youtrack_integration
|
2019-02-18 12:08:36 -05:00
|
|
|
end
|
|
|
|
|
2015-04-29 14:28:24 -04:00
|
|
|
factory :jira_project, parent: :project do
|
2019-10-01 20:06:26 -04:00
|
|
|
has_external_issue_tracker { true }
|
2019-07-11 05:53:08 -04:00
|
|
|
|
2021-06-18 11:10:16 -04:00
|
|
|
jira_integration
|
2015-04-29 14:28:24 -04:00
|
|
|
end
|
2016-12-08 11:36:26 -05:00
|
|
|
|
2017-08-02 15:43:24 -04:00
|
|
|
factory :prometheus_project, parent: :project do
|
2017-03-07 11:57:42 -05:00
|
|
|
after :create do |project|
|
2021-06-18 17:10:06 -04:00
|
|
|
project.create_prometheus_integration(
|
2017-03-07 11:57:42 -05:00
|
|
|
active: true,
|
|
|
|
properties: {
|
2018-02-06 19:53:18 -05:00
|
|
|
api_url: 'https://prometheus.example.com/',
|
2018-01-30 05:32:47 -05:00
|
|
|
manual_configuration: true
|
2017-03-07 11:57:42 -05:00
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2020-07-15 05:09:34 -04:00
|
|
|
|
2020-09-14 08:09:34 -04:00
|
|
|
factory :ewm_project, parent: :project do
|
|
|
|
has_external_issue_tracker { true }
|
|
|
|
|
2021-06-16 14:10:35 -04:00
|
|
|
ewm_integration
|
2020-09-14 08:09:34 -04:00
|
|
|
end
|
|
|
|
|
2020-07-15 05:09:34 -04:00
|
|
|
factory :project_with_design, parent: :project do
|
|
|
|
after(:create) do |project|
|
|
|
|
issue = create(:issue, project: project)
|
|
|
|
create(:design, project: project, issue: issue)
|
|
|
|
end
|
|
|
|
end
|
2020-07-23 17:09:19 -04:00
|
|
|
|
|
|
|
trait :in_subgroup do
|
|
|
|
namespace factory: [:group, :nested]
|
|
|
|
end
|
2014-07-31 13:13:27 -04:00
|
|
|
end
|