Skip to content

Replace some instances of `init` with `build`

Dan Davison requested to merge dj-1992-factorybot-build-resources into master

What does this MR do and why?

After the merging of Add FactoryBot DSL for end-to-end Resources (!128162 - merged), the ability to build resources was also added in.

Replace some init references with FactoryBot build.

project = create(:project, name: 'test')
issue = build(:issue, title: 'My Issue', project: project)

# instead of

project = Resource::Project.fabricate_via_api! do |project|
  project.name = 'test'
end

issue = Resource::Issue.init do |issue|
  issue.title = 'My Issue'
  issue.project = project
end

Closes gitlab-org/quality/quality-engineering/team-tasks#1994 (closed)

Allow building of Factories

Replace Project,Group,Sandbox init refs

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Dan Davison

Merge request reports