Support conditional paper trail on destroy
This commit is contained in:
parent
e870e0d561
commit
a517bc333c
|
@ -72,7 +72,7 @@ module PaperTrail
|
|||
|
||||
after_create :record_create, :if => :save_version? if !options[:on] || options[:on].include?(:create)
|
||||
before_update :record_update, :if => :save_version? if !options[:on] || options[:on].include?(:update)
|
||||
after_destroy :record_destroy if !options[:on] || options[:on].include?(:destroy)
|
||||
after_destroy :record_destroy, :if => :save_version? if !options[:on] || options[:on].include?(:destroy)
|
||||
end
|
||||
|
||||
# Switches PaperTrail off for this class.
|
||||
|
|
|
@ -79,6 +79,15 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
setup { @translation.update_attributes :content => 'Content' }
|
||||
should_not_change('the number of versions') { Version.count }
|
||||
end
|
||||
|
||||
context 'after destroy' do
|
||||
setup do
|
||||
@translation.save!
|
||||
@translation.destroy
|
||||
end
|
||||
|
||||
should_not_change('the number of versions') { Version.count }
|
||||
end
|
||||
end
|
||||
|
||||
context 'for US translations' do
|
||||
|
@ -107,6 +116,15 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
setup { @translation.update_attributes :content => 'Content' }
|
||||
should_change('the number of versions', :by => 1) { Version.count }
|
||||
end
|
||||
|
||||
context 'after destroy' do
|
||||
setup do
|
||||
@translation.save!
|
||||
@translation.destroy
|
||||
end
|
||||
|
||||
should_change('the number of versions', :by => 1) { Version.count }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue