From 071282f30367ed6a4c2a41b235db920ec26af775 Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Wed, 30 Jul 2014 16:17:02 -0400 Subject: [PATCH] close #354; fixes #374; close #131; Update CHANGELOG for PR for #375 --- CHANGELOG.md | 4 ++++ spec/models/widget_spec.rb | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f856d523..8cab3fc9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ new model instance. - [#398](https://github.com/airblade/paper_trail/pull/398) - Only require the `RSpec` helper if `RSpec::Core` is required. - [#394](https://github.com/airblade/paper_trail/pull/394) - Add RSpec matcher `have_a_version_with` for easier testing. + - [#375](https://github.com/airblade/paper_trail/pull/375) / [#374](https://github.com/airblade/paper_trail/issues/374) / + [#354](https://github.com/airblade/paper_trail/issues/354) / [#131](https://github.com/airblade/paper_trail/issues/131) - + Versions should be built with `after_` callbacks so the timestamp field for a version can be forced to match the + corresponding timestamp in the database for the state persistence of a change to the base (versioned) model. ## 3.0.3 diff --git a/spec/models/widget_spec.rb b/spec/models/widget_spec.rb index bc7ee1415..1d07671e2 100644 --- a/spec/models/widget_spec.rb +++ b/spec/models/widget_spec.rb @@ -48,6 +48,14 @@ end end + describe :after_create do + let(:widget) { Widget.create!(:name => 'Foobar', :created_at => Time.now - 1.week) } + + it "corresponding version should use the widget's `created_at`" do + widget.versions.last.created_at.to_i.should == widget.created_at.to_i + end + end + describe :after_update do before { widget.update_attributes!(:name => 'Foobar', :updated_at => Time.now + 1.week) } @@ -60,7 +68,7 @@ subject.should be_live end - it "should use the widget updated_at" do + it "corresponding version should use the widget updated_at" do widget.versions.last.created_at.to_i.should == widget.updated_at.to_i end end