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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
2953798e
Commit
2953798e
authored
Oct 19, 2018
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document the :repository and :custom_repo traits
parent
c094bdb8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
doc/development/testing_guide/best_practices.md
doc/development/testing_guide/best_practices.md
+31
-0
No files found.
doc/development/testing_guide/best_practices.md
View file @
2953798e
...
@@ -348,6 +348,37 @@ GitLab uses [factory_bot] as a test fixture replacement.
...
@@ -348,6 +348,37 @@ GitLab uses [factory_bot] as a test fixture replacement.
All fixtures should be be placed under
`spec/fixtures/`
.
All fixtures should be be placed under
`spec/fixtures/`
.
### Repositories
Testing some functionality, e.g., merging a merge request, requires a git
repository with a certain state to be present in the test environment. GitLab
maintains the
[
gitlab-test
](
https://gitlab.com/gitlab-org/gitlab-test
)
repository for certain common cases - you can ensure a copy of the repository is
used with the
`:repository`
trait for project factories:
```
ruby
let
(
:project
)
{
create
(
:project
,
:repository
)
}
```
Where you can, consider using the
`:custom_repo`
trait instead of
`:repository`
.
This allows you to specify exactly what files will appear in the
`master`
branch
of the project's repository. For example:
```
ruby
let
(
:project
)
do
create
(
:project
,
:custom_repo
,
files:
{
'README.md'
=>
'Content here'
,
'foo/bar/baz.txt'
=>
'More content here'
}
)
end
```
This will create a repository containing two files, with default permissions and
the specified content.
### Config
### Config
RSpec config files are files that change the RSpec config (i.e.
RSpec config files are files that change the RSpec config (i.e.
...
...
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