DomainContact versioning and tests for versioning

This commit is contained in:
Andres Keskküla 2014-10-16 11:38:29 +03:00
parent 79bf0e54c3
commit cb37ddf96d
3 changed files with 63 additions and 1 deletions

View file

@ -3,6 +3,10 @@ class DomainContact < ActiveRecord::Base
belongs_to :contact
belongs_to :domain
after_create :domain_snapshot
after_destroy :domain_snapshot
# after_save :domain_snapshot
attr_accessor :value_typeahead
def epp_code_map
@ -33,4 +37,11 @@ class DomainContact < ActiveRecord::Base
def value_typeahead
@value_typeahead || contact.try(:name) || nil
end
def domain_snapshot
# We don't create a version unless domain is valid, is that a good idea?
return true unless PaperTrail.enabled?
domain.touch_with_version if domain.valid?
true
end
end

View file

@ -55,5 +55,9 @@
= ns[:hostname] + ","
= ns[:ipv4] || ns[:ipv6]
%td= l(version.created_at, format: :short)
%td
%p{ :style => 'font-size:x-small;' }
= l(version.created_at, format: :short)
= version.whodunnit
= version.event