forked from ManageIQ/manageiq-schema
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround Rails 7 raising type mismatch errors
- Loading branch information
Showing
4 changed files
with
69 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module TypeMismatchExpectedInMigrationSpec | ||
# Rails 7 now calls this from the klass method, forcing association classes to be a type of the freshly loaded class | ||
# For migration specs, we purposely cache the stub models so these models don't match the associations where we specify | ||
# an explicit class_name after constantize. | ||
def raise_on_type_mismatch!(record) | ||
return | ||
end | ||
end | ||
ActiveRecord::Associations::Association.prepend(TypeMismatchExpectedInMigrationSpec) if ActiveRecord::VERSION::STRING >= "7.0" |