Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
db28db41
Commit
db28db41
authored
Sep 03, 2018
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow repositories to be programmatically built in the specs
parent
f7c1a5e1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
spec/factories/projects.rb
spec/factories/projects.rb
+27
-0
No files found.
spec/factories/projects.rb
View file @
db28db41
...
@@ -130,6 +130,33 @@ FactoryBot.define do
...
@@ -130,6 +130,33 @@ FactoryBot.define do
end
end
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
# Test repository - https://gitlab.com/gitlab-org/gitlab-test
trait
:repository
do
trait
:repository
do
test_repo
test_repo
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment