You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Execute FactoryBot.lint! in database transactions (#1726)
Prior to this change `FactoryBot.lint!` execution can trigger sequential
`FactoryBot.create` calls made within the same test (either Minitest
`test` or RSpec `it` blocks).
This can result in linting violations for records that have
database-level uniqueness constraints.
This commit introduces the private `Linter#in_transaction` method to
wrap the executing block within an [ActiveRecord::Base.transaction][]
block that concludes with raising an [ActiveRecord::Rollback][] error.
After this change, executions no longer contest with database-level
uniqueness constraints.
[ActiveRecord::Base.transaction]: https://edgeapi.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html#method-i-transaction
[ActiveRecord::Rollback]: https://edgeapi.rubyonrails.org/classes/ActiveRecord/Rollback.html
0 commit comments