mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 09:43:36 +02:00
Fixed double versioning on domains
This commit is contained in:
parent
6b783fd45e
commit
7c3740acba
5 changed files with 20 additions and 10 deletions
|
@ -66,8 +66,8 @@ class Contact < ActiveRecord::Base
|
|||
def domains_snapshot
|
||||
(domains + domains_owned).uniq.each do |domain|
|
||||
next unless domain.is_a?(Domain)
|
||||
next if domain.versions.last == domain.create_snapshot
|
||||
domain.touch_with_version # Method from paper_trail
|
||||
#next if domain.versions.last == domain.create_snapshot
|
||||
domain.create_version # Method from paper_trail
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -61,10 +61,25 @@ class Domain < ActiveRecord::Base
|
|||
attr_accessor :owner_contact_typeahead, :update_me
|
||||
|
||||
# archiving
|
||||
has_paper_trail class_name: 'DomainVersion', meta: { snapshot: :create_snapshot }
|
||||
has_paper_trail class_name: 'DomainVersion', meta: { snapshot: :create_snapshot }, if: Proc.new{ |t| t.new_version }
|
||||
|
||||
def new_version
|
||||
#versions.try(:last).try(:snapshot) != create_snapshot
|
||||
return false if versions.try(:last).try(:snapshot) == create_snapshot
|
||||
true
|
||||
end
|
||||
|
||||
def create_version
|
||||
return true unless PaperTrail.enabled?
|
||||
# We don't create a version unless domain is valid, is that a good idea?
|
||||
return true unless valid?
|
||||
#return true if versions.try(:last).try(:snapshot) == create_snapshot
|
||||
touch_with_version
|
||||
end
|
||||
|
||||
def track_nameserver_add(nameserver)
|
||||
# if we are not adding nameservers on create ( we don't care about ms so to_i )
|
||||
#return true if versions.try(:last).try(:snapshot) == create_snapshot
|
||||
touch_with_version if nameserver.created_at.to_i != created_at.to_i && valid?
|
||||
end
|
||||
|
||||
|
|
|
@ -39,12 +39,8 @@ class DomainContact < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def domain_snapshot
|
||||
# We don't create a version unless domain is valid, is that a good idea?
|
||||
return true unless PaperTrail.enabled?
|
||||
return true if domain.nil?
|
||||
return true if contact.nil?
|
||||
return true if domain.versions.last.try(:snapshot) == domain.try(:create_snapshot)
|
||||
domain.touch_with_version if domain.valid?
|
||||
domain.create_version
|
||||
true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -47,7 +47,7 @@ class Nameserver < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def domain_version
|
||||
domain.touch_with_version if domain.valid?
|
||||
domain.create_version
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
|
|
@ -2,7 +2,6 @@ require 'rails_helper'
|
|||
|
||||
describe DomainVersion do
|
||||
with_versioning do
|
||||
# before(:each) { Fabricate(:domain_validation_setting_group); Fabricate(:dnskeys_setting_group) }
|
||||
before(:each) do
|
||||
Setting.ns_min_count = 1
|
||||
Fabricate(:domain, name: 'version.ee', dnskeys: []) do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue