Skip to content

Support for callback before(:build) #1633

Closed

Description

@23tux

Problem this feature will solve

I want to disable our Bullet gem when FactoryBot is building instances and creating records, because I don't care about n+1 problems inside my test setup.

The problem is, that there seems to be no callback called before(:build). I had a look into the source code but didn't find the right place to patch it.

Any help is appreciated where to start, so I maybe I can try for a PR.

Desired solution

I want to be able to use something like this

FactoryBot.define do
  before(:build) do |record|
    Bullet.enable = false
  end

  after(:create) do |record|
    Bullet.enable = true
  end
end

Activity

  1. ofabianomartins commented on Apr 5, 2024

    @ofabianomartins

    I'm interested too!

  2. mohammednasser-32 commented on Apr 28, 2024

    @mohammednasser-32
    Contributor

    Created a PR for the change
    #1639

  3. 23tux commented on Jan 9, 2025

    @23tux
    Author

    Is there a chance this gets merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions