Permalink
Browse files

Added a very basic unit test for audit_trail

  • Loading branch information...
1 parent 0867a3f commit 0b83e0d605019b260f115f17046e6fb4e4fbc700 Jeremy Weiskotten committed Feb 14, 2010
Showing with 15 additions and 0 deletions.
  1. +15 −0 test/paper_trail_model_test.rb
View
15 test/paper_trail_model_test.rb
@@ -173,6 +173,21 @@ class HasPaperTrailModelTest < Test::Unit::TestCase
@reified_widget.save
assert_equal 1, @reified_widget.fluxors.length
end
+
+ should 'build an audit trail' do
+ audit_trail = @widget.audit_trail
+ assert_equal 3, audit_trail.size
+
+ # the audit trails hould list the most recent event first
+ assert_equal 'destroy', audit_trail[0][:event]
+ assert_equal 'update', audit_trail[1][:event]
+ assert_equal 'create', audit_trail[2][:event]
+
+ audit_trail.each do |change|
+ assert_kind_of Time, change[:changed_at]
+ assert_kind_of Array, change[:changes]
+ end
+ end
end
end
end

0 comments on commit 0b83e0d

Please sign in to comment.