Skip to content

Commit

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

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

Ref: thoughtbot#913 (comment)
  • Loading branch information
bsodmike committed Oct 18, 2016
1 parent 6c2fb57 commit e2c4633
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/shoulda/matchers/rails_shim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ 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 e2c4633

Please sign in to comment.