Allow repositories to be programmatically built in the specs
This commit is contained in:
parent
f7c1a5e1ed
commit
db28db414c
|
@ -130,6 +130,33 @@ FactoryBot.define do
|
|||
end
|
||||
end
|
||||
|
||||
# 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
|
||||
files {}
|
||||
end
|
||||
|
||||
after :create do |project, evaluator|
|
||||
raise "Failed to create repository!" unless project.create_repository
|
||||
|
||||
evaluator.files.each do |filename, content|
|
||||
project.repository.create_file(
|
||||
project.creator,
|
||||
filename,
|
||||
content,
|
||||
message: "Automatically created file #{filename}",
|
||||
branch_name: 'master'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Test repository - https://gitlab.com/gitlab-org/gitlab-test
|
||||
trait :repository do
|
||||
test_repo
|
||||
|
|
Loading…
Reference in New Issue