test/unit/model_test.rb in paper_trail-2.2.6 vs test/unit/model_test.rb in paper_trail-2.2.7
- old
+ new
@@ -58,10 +58,13 @@
should 'be live' do
assert @widget.live?
end
+ should 'should not have changes' do
+ assert_nil @widget.versions.last.changeset
+ end
context 'and then updated without any changes' do
setup { @widget.save }
should 'not have a new version' do
@@ -95,10 +98,21 @@
should 'have versions that are not live' do
assert @widget.versions.map(&:reify).compact.all? { |w| !w.live? }
end
+ should 'have stored changes' do
+ assert_equal ({'name' => ['Henry', 'Harry']}), YAML::load(@widget.versions.last.object_changes)
+ assert_equal ({'name' => ['Henry', 'Harry']}), @widget.versions.last.changeset
+ end
+
+ should 'not have stored changes if object_changes column doesn\'t exist' do
+ remove_object_changes_column
+ Version.reset_column_information
+ assert_nil @widget.versions.last.changeset
+ end
+
if defined?(ActiveRecord::IdentityMap) && ActiveRecord::IdentityMap.respond_to?(:without)
should 'not clobber the IdentityMap when reifying' do
module ActiveRecord::IdentityMap
class << self
alias :__without :without
@@ -116,10 +130,10 @@
context 'and has one associated object' do
setup do
@wotsit = @widget.create_wotsit :name => 'John'
end
-
+
should 'not copy the has_one association by default when reifying' do
reified_widget = @widget.versions.last.reify
assert_equal @wotsit, reified_widget.wotsit # association hasn't been affected by reifying
assert_equal @wotsit, @widget.wotsit # confirm that the association is correct
end