Merge remote-tracking branch 'pamediakopes /fix-originator'

Moved the unit test for this change to into the model_test.rb.  [ fix #166 ]
This commit is contained in:
Ben Atkins 2012-10-16 16:03:32 -04:00
commit 1668bb26ae
3 changed files with 9 additions and 1 deletions

2
.gitignore vendored
View File

@ -11,3 +11,5 @@ pkg/*
.rbenv-version
Gemfile.lock
vendor/*
.idea
.rvmrc

View File

@ -97,7 +97,7 @@ module PaperTrail
# Returns who put the object into its current state.
def originator
version_class.with_item_keys(self.class.name, id).last.try :whodunnit
version_class.with_item_keys(self.class.base_class.name, id).last.try :whodunnit
end
# Returns the object (not a Version) as it was at the given timestamp.

View File

@ -517,6 +517,12 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
assert_nil Version.last.next
end
should 'should return the correct originator' do
PaperTrail.whodunnit = 'Ben'
@foo.update_attribute(:name, 'Geoffrey')
assert_equal PaperTrail.whodunnit, @foo.originator
end
context 'when destroyed' do
setup { @foo.destroy }