diff options
Diffstat (limited to 'spec/factories/projects.rb')
-rw-r--r-- | spec/factories/projects.rb | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index f113ca2425f..299dd165807 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -222,7 +222,7 @@ FactoryBot.define do # 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' }) + # 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 @@ -245,6 +245,19 @@ FactoryBot.define do end end + # A basic repository with a single file 'test.txt'. It also has the HEAD as the default branch. + trait :small_repo do + custom_repo + + files { { 'test.txt' => 'test' } } + + after(:create) do |project| + Sidekiq::Worker.skipping_transaction_check do + raise "Failed to assign the repository head!" unless project.change_head(project.default_branch_or_main) + end + end + end + # Test repository - https://gitlab.com/gitlab-org/gitlab-test trait :repository do test_repo @@ -354,6 +367,18 @@ FactoryBot.define do end end + trait :stubbed_commit_count do + after(:build) do |project| + stub_method(project.repository, :commit_count) { 2 } + end + end + + trait :stubbed_branch_count do + after(:build) do |project| + stub_method(project.repository, :branch_count) { 2 } + end + end + trait :wiki_repo do after(:create) do |project| stub_feature_flags(main_branch_over_master: false) |