Closed ngouy closed 3 years ago
Hello, @ngouy we have tried reproducing this scenario with the reproduction script and substituted the create!
call with the process that factory_bot
is using internally:
# under the hood create does something similar to this
new_class = ParentClass.new
new_class.type = "UnknownSubClass"
new_class.save!
The behavior is the same as you correctly described. But since this is reproducible without any factory_bot
code we are going to close it.
Thank you for bringing it up!
Description
When creating STI ish objects, factory bot isn't checking for the type. It doesn't raise any error if the given type doesn't exists in STI subclasses
Reproduction Steps
I have an STI pattern
Thus I only have one table in db with the
type
colomnHere is my factory
Now lets test some things :
So far so good. But here is the bug :
There is an inconsistency between the real activerecord interface and what factorybot is returning us
Expected behavior
We should get an error
Actual behavior
Everything goes smoothly 😱
System configuration
factory_bot version: 5.1.1 (updated to 6.1.0, same issue) rails version: 6.1.1 ruby version: 2.7.2