From a5a2656b6e71f6b4b85d803a8f82998b5f71c3dd Mon Sep 17 00:00:00 2001 From: Dominik Sander Date: Tue, 3 May 2011 01:21:28 +0000 Subject: [PATCH] Supports rails 3.1 beta --- lib/paper_trail/has_paper_trail.rb | 2 +- test/unit/model_test.rb | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/paper_trail/has_paper_trail.rb b/lib/paper_trail/has_paper_trail.rb index cfd30842..d6396c86 100644 --- a/lib/paper_trail/has_paper_trail.rb +++ b/lib/paper_trail/has_paper_trail.rb @@ -143,7 +143,7 @@ module PaperTrail end def item_before_change - self.clone.tap do |previous| + self.dup.tap do |previous| previous.id = id changed_attributes.each { |attr, before| previous[attr] = before } end diff --git a/test/unit/model_test.rb b/test/unit/model_test.rb index accd0947..072ce51c 100644 --- a/test/unit/model_test.rb +++ b/test/unit/model_test.rb @@ -212,11 +212,11 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase end should 'handle datetimes' do - assert_equal @date_time.to_time.utc, @previous.a_datetime.to_time.utc + assert_equal @date_time.to_time.utc.to_i, @previous.a_datetime.to_time.utc.to_i end should 'handle times' do - assert_equal @time, @previous.a_time + assert_equal @time.utc.to_i, @previous.a_time.utc.to_i end should 'handle dates' do @@ -241,14 +241,14 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase end should 'restore all forward-compatible attributes' do - assert_equal 'Warble', @last.reify.name - assert_equal 'The quick brown fox', @last.reify.a_text - assert_equal 42, @last.reify.an_integer - assert_in_delta 153.01, @last.reify.a_float, 0.001 - assert_in_delta 2.71828, @last.reify.a_decimal, 0.00001 - assert_equal @date_time.to_time.utc, @last.reify.a_datetime.to_time.utc - assert_equal @time, @last.reify.a_time - assert_equal @date, @last.reify.a_date + assert_equal 'Warble', @last.reify.name + assert_equal 'The quick brown fox', @last.reify.a_text + assert_equal 42, @last.reify.an_integer + assert_in_delta 153.01, @last.reify.a_float, 0.001 + assert_in_delta 2.71828, @last.reify.a_decimal, 0.00001 + assert_equal @date_time.to_time.utc.to_i, @last.reify.a_datetime.to_time.utc.to_i + assert_equal @time.utc.to_i, @last.reify.a_time.utc.to_i + assert_equal @date, @last.reify.a_date assert @last.reify.a_boolean end end