Invoke HashWithIndifferentAccess#to_hash to cast to a hash since #to_h is not defined on Ruby19 and lower

This commit is contained in:
Ben Atkins 2014-10-21 15:30:29 -04:00
parent 08d89bdd5a
commit abdf53ab39
2 changed files with 3 additions and 3 deletions

View File

@ -294,7 +294,7 @@ module PaperTrail
def changes_for_paper_trail
self.changes.delete_if do |key, value|
!notably_changed.include?(key)
end.tap { |changes| self.class.serialize_attribute_changes(changes) }.to_h
end.tap { |changes| self.class.serialize_attribute_changes(changes) }.to_hash
end
# Invoked via`after_update` callback for when a previous version is reified and then saved

View File

@ -21,7 +21,7 @@ describe PaperTrail::Version, :type => :model do
specify { expect(PaperTrail.serializer).to be PaperTrail::Serializers::YAML }
it "should store out as a plain hash" do
expect(value =~ /ActiveSupport::HashWithIndifferentAccess/).to be_nil
expect(value =~ /HashWithIndifferentAccess/).to be_nil
end
end
@ -29,7 +29,7 @@ describe PaperTrail::Version, :type => :model do
before(:all) { PaperTrail.serializer = PaperTrail::Serializers::JSON }
it "should store out as a plain hash" do
expect(value =~ /ActiveSupport::HashWithIndifferentAccess/).to be_nil
expect(value =~ /HashWithIndifferentAccess/).to be_nil
end
after(:all) { PaperTrail.serializer = PaperTrail::Serializers::YAML }