Skip to content

Commit

Permalink
Fix STI bug affecting destroyed models.
Browse files Browse the repository at this point in the history
  • Loading branch information
airblade committed Jul 11, 2011
1 parent 6511eea commit f51eb08
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/paper_trail/has_paper_trail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def record_update
def record_destroy
if switched_on? and not new_record?
version_class.create merge_metadata(:item_id => self.id,
:item_type => self.class.name,
:item_type => self.class.base_class.name,
:event => 'destroy',
:object => object_to_string(item_before_change),
:whodunnit => PaperTrail.whodunnit)
Expand Down
9 changes: 6 additions & 3 deletions test/unit/model_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -387,17 +387,20 @@ def without(&block)
end

should 'reify with the correct type' do
thing = @foo.versions.last.reify
thing = Version.last.reify
assert_kind_of FooWidget, thing
assert_equal @foo.versions.first, Version.last.previous
assert_nil Version.last.next
end


context 'when destroyed' do
setup { @foo.destroy }

should 'reify with the correct type' do
thing = @foo.versions.last.reify
thing = Version.last.reify
assert_kind_of FooWidget, thing
assert_equal @foo.versions[1], Version.last.previous
assert_nil Version.last.next
end
end
end
Expand Down

0 comments on commit f51eb08

Please sign in to comment.