GitLab Fabrication Guide
GitLab Fabrication Guide
This guide will help you understand how to fabricate GitLab Data Models.
Create a Model
You can create a model using create()
method. The create()
method accepts a Factory and a hash of attributes.
For example, this would create a group label with the title ‘bug’ and color ‘#FF0000’ under the top-level namespace:
Create a List of Models
You can create a list of models using create_list()
method. The create_list()
method accepts a Factory, the number of models to create, and a hash of attributes.
For example, this would create 5 group labels with the title ‘bug’ and color ‘#FF0000’ under the top-level namespace:
Build a model and save it later
You can build a model using build()
method. The build()
method accepts a Factory and a hash of attributes.
In this example, we build the first label without saving, label 1
will be created, then label 2
is saved later, resulting in label 2
being created after label 1
.
Build a model and bypass validation
You can build a model and bypass GitLab’s built-in validations by building a model and calling save(validate: false)
.
In this example, we are assuming that the color
is validated by GitLab’s built-in record validations. We can bypass this validation by calling save(validate: false)
.