From abdf53ab39144210ecf8c69d5358c63d540bc0f0 Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Tue, 21 Oct 2014 15:30:29 -0400 Subject: [PATCH] Invoke HashWithIndifferentAccess#to_hash to cast to a hash since #to_h is not defined on Ruby19 and lower --- lib/paper_trail/has_paper_trail.rb | 2 +- spec/models/version_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/paper_trail/has_paper_trail.rb b/lib/paper_trail/has_paper_trail.rb index c964bdc9..7e93a910 100644 --- a/lib/paper_trail/has_paper_trail.rb +++ b/lib/paper_trail/has_paper_trail.rb @@ -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 diff --git a/spec/models/version_spec.rb b/spec/models/version_spec.rb index 411c5163..1cd48321 100644 --- a/spec/models/version_spec.rb +++ b/spec/models/version_spec.rb @@ -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 }