Skip to content

Commit

Permalink
Fix #913 for Serialize Matcher error undefined method `cast_type' in …
Browse files Browse the repository at this point in the history
…Rails 5

This patch is based on the discussed held in issue #913, and a solution
that I've proposed and others have confirmed as good to go 👏.

Ref: #913 (comment)
  • Loading branch information
bsodmike authored and mcmire committed Sep 17, 2017
1 parent 76e63b2 commit df04f87
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/shoulda/matchers/rails_shim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ def self.serialized_attributes_for(model)
if defined?(::ActiveRecord::Type::Serialized)
# Rails 5+
model.columns.select do |column|
column.cast_type.is_a?(::ActiveRecord::Type::Serialized)
model.type_for_attribute(column.name).is_a?(
::ActiveRecord::Type::Serialized,
)
end.inject({}) do |hash, column|
hash[column.name.to_s] = column.cast_type.coder
hash[column.name.to_s] = model.type_for_attribute(column.name).coder
hash
end
else
Expand Down

0 comments on commit df04f87

Please sign in to comment.