thoughtbot / shoulda-matchers

Simple one-liner tests for common Rails functionality
https://matchers.shoulda.io
MIT License
3.5k stars 911 forks source link

fix: Polymorphic + STI uniqueness check #1624

Closed matsales28 closed 4 months ago

matsales28 commented 5 months ago

Instead of just initializing a new class that inherits from the parent class, we are initializing a new class but also overriding some method definitions. That is necessary because the Rails guides recommend that whenever you have a polymorphic association and STI you should override the ..._type column to use the type name of the base STI class.

https://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#module-ActiveRecord::Associations::ClassMethods-label-Polymorphic+Associations

This should fix #1622

matsales28 commented 4 months ago

@VSPPedro, this is now ready for you to take a look!