From 1c34da50c9913dfb5789bb8037310b635cc82771 Mon Sep 17 00:00:00 2001 From: Ben Zittlau Date: Thu, 24 Mar 2011 13:44:10 -0600 Subject: [PATCH] Adding some basic testing of the new custom class functionality --- test/unit/model_test.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/unit/model_test.rb b/test/unit/model_test.rb index 1f997ebf..c73823e0 100644 --- a/test/unit/model_test.rb +++ b/test/unit/model_test.rb @@ -710,6 +710,30 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase end end + context 'A new model instance which uses a custom Version class' do + setup { @post = Post.new } + + context 'which is then saved' do + setup { @post.save } + should_change('the number of post versions') { PostVersion.count } + should_not_change('the number of versions') { Version.count } + end + end + + context 'An existing model instance which uses a custom Version class' do + setup { @post = Post.create } + + should 'should have versions of the custom class' do + assert_equal "PostVersion", @post.versions.first.class.name + end + + context 'which is modified' do + setup { @post.update_attributes({ :content => "Some new content" }) } + should_change('the number of post versions') { PostVersion.count } + should_not_change('the number of versions') { Version.count } + end + end + context 'An overwritten default accessor' do setup do