diff options
author | Jose <jivanvl@hotmail.com> | 2018-04-30 17:00:16 -0500 |
---|---|---|
committer | Jose <jivanvl@hotmail.com> | 2018-04-30 17:00:16 -0500 |
commit | d3327e0dfacd27d547ffdb3b7f4a1a76c76ae281 (patch) | |
tree | 82019118f22877ec9135d45620c9dcf8acd0579e /spec/factories | |
parent | f48f40bf267fd0f35ba09fd3b8f30e17c0789327 (diff) | |
parent | 2f7b71df7619768220657ed47c7737f4c3e19e90 (diff) | |
download | gitlab-ce-d3327e0dfacd27d547ffdb3b7f4a1a76c76ae281.tar.gz |
Merge branch 'master' into 44059-specify-variables-when-executing-a-manual-pipeline-from-the-ui
Diffstat (limited to 'spec/factories')
-rw-r--r-- | spec/factories/ci/builds.rb | 6 | ||||
-rw-r--r-- | spec/factories/commits.rb | 2 | ||||
-rw-r--r-- | spec/factories/deploy_tokens.rb | 8 | ||||
-rw-r--r-- | spec/factories/gpg_key_subkeys.rb | 2 | ||||
-rw-r--r-- | spec/factories/gpg_keys.rb | 2 | ||||
-rw-r--r-- | spec/factories/gpg_signature.rb | 2 | ||||
-rw-r--r-- | spec/factories/groups.rb | 8 | ||||
-rw-r--r-- | spec/factories/namespaces.rb | 18 | ||||
-rw-r--r-- | spec/factories/notes.rb | 2 | ||||
-rw-r--r-- | spec/factories/projects.rb | 15 |
10 files changed, 54 insertions, 11 deletions
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index e1fafa71d5c..4acc008ed38 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -62,6 +62,7 @@ FactoryBot.define do end trait :pending do + queued_at 'Di 29. Okt 09:50:59 CET 2013' status 'pending' end @@ -242,5 +243,10 @@ FactoryBot.define do failed failure_reason 1 end + + trait :api_failure do + failed + failure_reason 2 + end end end diff --git a/spec/factories/commits.rb b/spec/factories/commits.rb index d5d819d862a..818f7b046f6 100644 --- a/spec/factories/commits.rb +++ b/spec/factories/commits.rb @@ -1,4 +1,4 @@ -require_relative '../support/repo_helpers' +require_relative '../support/helpers/repo_helpers' FactoryBot.define do factory :commit do diff --git a/spec/factories/deploy_tokens.rb b/spec/factories/deploy_tokens.rb index 5fea4a9d5a6..017e866e69c 100644 --- a/spec/factories/deploy_tokens.rb +++ b/spec/factories/deploy_tokens.rb @@ -10,5 +10,13 @@ FactoryBot.define do trait :revoked do revoked true end + + trait :gitlab_deploy_token do + name DeployToken::GITLAB_DEPLOY_TOKEN_NAME + end + + trait :expired do + expires_at { Date.today - 1.month } + end end end diff --git a/spec/factories/gpg_key_subkeys.rb b/spec/factories/gpg_key_subkeys.rb index 57eaaee345f..6c7db5379a9 100644 --- a/spec/factories/gpg_key_subkeys.rb +++ b/spec/factories/gpg_key_subkeys.rb @@ -1,5 +1,3 @@ -require_relative '../support/gpg_helpers' - FactoryBot.define do factory :gpg_key_subkey do gpg_key diff --git a/spec/factories/gpg_keys.rb b/spec/factories/gpg_keys.rb index b8aabf74221..51b8ddc9934 100644 --- a/spec/factories/gpg_keys.rb +++ b/spec/factories/gpg_keys.rb @@ -1,4 +1,4 @@ -require_relative '../support/gpg_helpers' +require_relative '../support/helpers/gpg_helpers' FactoryBot.define do factory :gpg_key do diff --git a/spec/factories/gpg_signature.rb b/spec/factories/gpg_signature.rb index 4620caff823..b89e6ffc4b3 100644 --- a/spec/factories/gpg_signature.rb +++ b/spec/factories/gpg_signature.rb @@ -1,5 +1,3 @@ -require_relative '../support/gpg_helpers' - FactoryBot.define do factory :gpg_signature do commit_sha { Digest::SHA1.hexdigest(SecureRandom.hex) } diff --git a/spec/factories/groups.rb b/spec/factories/groups.rb index 8c531cf5909..3b354c0d96b 100644 --- a/spec/factories/groups.rb +++ b/spec/factories/groups.rb @@ -5,6 +5,14 @@ FactoryBot.define do type 'Group' owner nil + after(:create) do |group| + if group.owner + # We could remove this after we have proper constraint: + # https://gitlab.com/gitlab-org/gitlab-ce/issues/43292 + raise "Don't set owner for groups, use `group.add_owner(user)` instead" + end + end + trait :public do visibility_level Gitlab::VisibilityLevel::PUBLIC end diff --git a/spec/factories/namespaces.rb b/spec/factories/namespaces.rb index f94b09cff15..6feafa5ece9 100644 --- a/spec/factories/namespaces.rb +++ b/spec/factories/namespaces.rb @@ -2,6 +2,22 @@ FactoryBot.define do factory :namespace do sequence(:name) { |n| "namespace#{n}" } path { name.downcase.gsub(/\s/, '_') } - owner + + # This is a workaround to avoid the user creating another namespace via + # User#ensure_namespace_correct. We should try to remove it and then + # we could remove this workaround + association :owner, factory: :user, strategy: :build + before(:create) do |namespace| + owner = namespace.owner + + if owner + # We're changing the username here because we want to keep our path, + # and User#ensure_namespace_correct would change the path based on + # username, so we're forced to do this otherwise we'll need to change + # a lot of existing tests. + owner.username = namespace.path + owner.namespace = namespace + end + end end end diff --git a/spec/factories/notes.rb b/spec/factories/notes.rb index 857333f222d..40f3fa7d69b 100644 --- a/spec/factories/notes.rb +++ b/spec/factories/notes.rb @@ -1,4 +1,4 @@ -require_relative '../support/repo_helpers' +require_relative '../support/helpers/repo_helpers' include ActionDispatch::TestProcess diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 1761b6e2a3b..1904615778c 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -1,4 +1,4 @@ -require_relative '../support/test_env' +require_relative '../support/helpers/test_env' FactoryBot.define do # Project without repository @@ -147,7 +147,15 @@ FactoryBot.define do # We delete hooks so that gitlab-shell will not try to authenticate with # an API that isn't running - FileUtils.rm_r(File.join(project.repository_storage_path, "#{project.disk_path}.git", 'hooks')) + project.gitlab_shell.rm_directory(project.repository_storage, + File.join("#{project.disk_path}.git", 'hooks')) + end + end + + 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) end end @@ -165,7 +173,8 @@ FactoryBot.define do after(:create) do |project| raise "Failed to create repository!" unless project.create_repository - FileUtils.rm_r(File.join(project.repository_storage_path, "#{project.disk_path}.git", 'refs')) + project.gitlab_shell.rm_directory(project.repository_storage, + File.join("#{project.disk_path}.git", 'refs')) end end |