2014-07-31 13:13:27 -04:00
|
|
|
FactoryGirl.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
|
2014-07-31 13:13:27 -04:00
|
|
|
factory :empty_project, class: 'Project' do
|
|
|
|
sequence(:name) { |n| "project#{n}" }
|
|
|
|
path { name.downcase.gsub(/\s/, '_') }
|
|
|
|
namespace
|
|
|
|
creator
|
|
|
|
|
2016-10-06 17:17:11 -04:00
|
|
|
# Behaves differently to nil due to cache_has_external_issue_tracker
|
|
|
|
has_external_issue_tracker false
|
|
|
|
|
2014-07-31 13:13:27 -04:00
|
|
|
trait :public do
|
|
|
|
visibility_level Gitlab::VisibilityLevel::PUBLIC
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :internal do
|
|
|
|
visibility_level Gitlab::VisibilityLevel::INTERNAL
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :private do
|
|
|
|
visibility_level Gitlab::VisibilityLevel::PRIVATE
|
|
|
|
end
|
2016-05-04 17:05:16 -04:00
|
|
|
|
|
|
|
trait :empty_repo do
|
|
|
|
after(:create) do |project|
|
|
|
|
project.create_repository
|
|
|
|
end
|
|
|
|
end
|
2016-08-01 18:31:21 -04:00
|
|
|
|
2016-09-23 03:42:07 -04:00
|
|
|
trait :broken_repo do
|
|
|
|
after(:create) do |project|
|
|
|
|
project.create_repository
|
|
|
|
|
|
|
|
FileUtils.rm_r(File.join(project.repository_storage_path, "#{project.path_with_namespace}.git", 'refs'))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-01 18:31:21 -04:00
|
|
|
# Nest Project Feature attributes
|
|
|
|
transient do
|
|
|
|
wiki_access_level ProjectFeature::ENABLED
|
|
|
|
builds_access_level ProjectFeature::ENABLED
|
|
|
|
snippets_access_level ProjectFeature::ENABLED
|
|
|
|
issues_access_level ProjectFeature::ENABLED
|
|
|
|
merge_requests_access_level ProjectFeature::ENABLED
|
2016-09-16 15:15:39 -04:00
|
|
|
repository_access_level ProjectFeature::ENABLED
|
2016-08-01 18:31:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
after(:create) do |project, evaluator|
|
|
|
|
project.project_feature.
|
|
|
|
update_attributes(
|
|
|
|
wiki_access_level: evaluator.wiki_access_level,
|
|
|
|
builds_access_level: evaluator.builds_access_level,
|
|
|
|
snippets_access_level: evaluator.snippets_access_level,
|
|
|
|
issues_access_level: evaluator.issues_access_level,
|
|
|
|
merge_requests_access_level: evaluator.merge_requests_access_level,
|
2016-09-16 15:15:39 -04:00
|
|
|
repository_access_level: evaluator.repository_access_level
|
2016-08-01 18:31:21 -04:00
|
|
|
)
|
|
|
|
end
|
2014-07-31 13:13:27 -04:00
|
|
|
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
|
|
|
|
factory :project_empty_repo, parent: :empty_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
|
|
|
|
factory :project_broken_repo, parent: :empty_project do
|
|
|
|
broken_repo
|
|
|
|
end
|
|
|
|
|
2014-11-30 03:50:15 -05:00
|
|
|
# Project with test repository
|
|
|
|
#
|
|
|
|
# Test repository source can be found at
|
|
|
|
# https://gitlab.com/gitlab-org/gitlab-test
|
2014-07-31 13:13:27 -04:00
|
|
|
factory :project, parent: :empty_project do
|
|
|
|
path { 'gitlabhq' }
|
|
|
|
|
|
|
|
after :create do |project|
|
|
|
|
TestEnv.copy_repo(project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-04-13 01:27:45 -04:00
|
|
|
factory :forked_project_with_submodules, parent: :empty_project do
|
|
|
|
path { 'forked-gitlabhq' }
|
|
|
|
|
|
|
|
after :create do |project|
|
|
|
|
TestEnv.copy_forked_repo_with_submodules(project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-07-31 13:13:27 -04:00
|
|
|
factory :redmine_project, parent: :project do
|
2016-10-06 17:17:11 -04:00
|
|
|
has_external_issue_tracker true
|
|
|
|
|
2015-01-26 18:59:40 -05:00
|
|
|
after :create do |project|
|
|
|
|
project.create_redmine_service(
|
|
|
|
active: true,
|
|
|
|
properties: {
|
2015-01-27 01:08:27 -05:00
|
|
|
'project_url' => 'http://redmine/projects/project_name_in_redmine',
|
|
|
|
'issues_url' => "http://redmine/#{project.id}/project_name_in_redmine/:id",
|
|
|
|
'new_issue_url' => 'http://redmine/projects/project_name_in_redmine/issues/new'
|
2015-01-26 18:59:40 -05:00
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
2014-07-31 13:13:27 -04:00
|
|
|
end
|
2015-04-29 14:28:24 -04:00
|
|
|
|
|
|
|
factory :jira_project, parent: :project do
|
2016-10-06 17:17:11 -04:00
|
|
|
has_external_issue_tracker true
|
|
|
|
|
2015-04-29 14:28:24 -04:00
|
|
|
after :create do |project|
|
|
|
|
project.create_jira_service(
|
|
|
|
active: true,
|
|
|
|
properties: {
|
2016-09-29 17:11:32 -04:00
|
|
|
title: 'JIRA tracker',
|
|
|
|
url: 'http://jira.example.net',
|
|
|
|
project_key: 'JIRA'
|
2015-04-29 14:28:24 -04:00
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2014-07-31 13:13:27 -04:00
|
|
|
end
|