diff options
Diffstat (limited to 'spec/factories')
-rw-r--r-- | spec/factories/snippet_repositories.rb | 12 | ||||
-rw-r--r-- | spec/factories/snippets.rb | 15 |
2 files changed, 27 insertions, 0 deletions
diff --git a/spec/factories/snippet_repositories.rb b/spec/factories/snippet_repositories.rb new file mode 100644 index 00000000000..1f9e68514bb --- /dev/null +++ b/spec/factories/snippet_repositories.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :snippet_repository do + snippet + + after(:build) do |snippet_repository, _| + snippet_repository.shard_name = snippet_repository.snippet.repository_storage + snippet_repository.disk_path = snippet_repository.snippet.disk_path + end + end +end diff --git a/spec/factories/snippets.rb b/spec/factories/snippets.rb index 5990ed7ffb0..6fcb0319748 100644 --- a/spec/factories/snippets.rb +++ b/spec/factories/snippets.rb @@ -20,6 +20,21 @@ FactoryBot.define do trait :private do visibility_level { Snippet::PRIVATE } end + + # Test repository - https://gitlab.com/gitlab-org/gitlab-test + trait :repository do + after :create do |snippet| + TestEnv.copy_repo(snippet, + bare_repo: TestEnv.factory_repo_path_bare, + refs: TestEnv::BRANCH_SHA) + end + end + + trait :empty_repo do + after(:create) do |snippet| + raise "Failed to create repository!" unless snippet.repository.create_if_not_exists + end + end end factory :project_snippet, parent: :snippet, class: :ProjectSnippet do |