Skip to content

Commit

Permalink
Ensure that ActiveRecord is not addressed unless it is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
stonefield authored and matsales28 committed Nov 10, 2023
1 parent 0dc6c6d commit 1b2bdc7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/shoulda/matchers/rails_shim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ def generate_validation_message(
end

def serialized_attributes_for(model)
type_serialized_defined = Object.const_defined?('ActiveRecord::Type::Serialized')
attribute_types_for(model).
inject({}) do |hash, (attribute_name, attribute_type)|
if attribute_type.is_a?(::ActiveRecord::Type::Serialized)
if type_serialized_defined && attribute_type.is_a?(::ActiveRecord::Type::Serialized)
hash.merge(attribute_name => attribute_type.coder)
else
hash
Expand Down

0 comments on commit 1b2bdc7

Please sign in to comment.