Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for callback before(:build) #1633

Open
23tux opened this issue Apr 4, 2024 · 2 comments · May be fixed by #1639
Open

Support for callback before(:build) #1633

23tux opened this issue Apr 4, 2024 · 2 comments · May be fixed by #1639
Labels

Comments

@23tux
Copy link

23tux commented Apr 4, 2024

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
@23tux 23tux added the feature label Apr 4, 2024
@ofabianomartins
Copy link

I'm interested too!

@mohammednasser-32 mohammednasser-32 linked a pull request Apr 28, 2024 that will close this issue
@mohammednasser-32
Copy link

Created a PR for the change
#1639

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants