Merge pull request #458 from rhec/store_metadata_on_create
store attribute metadata as it exists at creation
This commit is contained in:
commit
692dff1155
|
@ -403,8 +403,9 @@ module PaperTrail
|
|||
if v.respond_to?(:call)
|
||||
v.call(self)
|
||||
elsif v.is_a?(Symbol) && respond_to?(v)
|
||||
# if it is an attribute that is changing, be sure to grab the current version
|
||||
if has_attribute?(v) && send("#{v}_changed?".to_sym)
|
||||
# if it is an attribute that is changing in an existing object,
|
||||
# be sure to grab the current version
|
||||
if has_attribute?(v) && send("#{v}_changed?".to_sym) && data[:event] != 'create'
|
||||
send("#{v}_was".to_sym)
|
||||
else
|
||||
send(v)
|
||||
|
|
|
@ -800,8 +800,8 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
assert_equal @article.action_data_provider_method, @article.versions.last.action
|
||||
end
|
||||
|
||||
should 'store dynamic meta data based on an attribute of the item prior to creation' do
|
||||
assert_equal nil, @article.versions.last.title
|
||||
should 'store dynamic meta data based on an attribute of the item at creation' do
|
||||
assert_equal @initial_title, @article.versions.last.title
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue