Merge branch 'master' of github.com:domify/registry into country-refactor

Conflicts:
	app/models/address.rb
	app/models/country_deprecated.rb
	app/models/registrar.rb
	db/schema.rb
This commit is contained in:
Martin Lensment 2015-02-02 11:42:21 +02:00
commit 7537bb3712
91 changed files with 1614 additions and 698 deletions

View file

@ -17,3 +17,6 @@
color: #777
padding-top: 15px
font-size: 10px
.nowrap
white-space: nowrap

View file

@ -3,7 +3,7 @@ class Admin::ApiUsersController < AdminController
before_action :set_api_user, only: [:show, :edit, :update, :destroy]
def index
@q = ApiUser.search(params[:q])
@q = ApiUser.includes(:registrar).search(params[:q])
@api_users = @q.result.page(params[:page])
end

View file

@ -2,12 +2,16 @@ class Admin::DomainVersionsController < AdminController
load_and_authorize_resource
def index
@q = DomainVersion.deleted.search(params[:q])
@domains = @q.result.page(params[:page])
@domain = Domain.find(params[:domain_id])
@versions = @domain.versions
end
def show
@versions = DomainVersion.where(item_id: params[:id])
@name = @versions.last.name
end
# def index
# # @q = DomainVersion.deleted.search(params[:q])
# # @domains = @q.result.page(params[:page])
# end
# def show
# @versions = DomainVersion.where(item_id: params[:id])
# end
end

View file

@ -13,6 +13,26 @@ class ApplicationController < ActionController::Base
return session[:user_return_to].to_s if session[:user_return_to] && session[:user_return_to] != login_path
admin_dashboard_path
end
def user_for_paper_trail
if defined?(current_api_user) && current_api_user.present?
# Most of the time it's not loaded in correct time because PaperTrail before filter kicks in
# before current_api_user is defined. PaperTrail is triggered also at current_api_user
api_user_log_str(current_api_user)
elsif current_user.present?
"#{current_user.id}-#{current_user.username}"
else
'public'
end
end
def api_user_log_str(user)
if user.present?
"#{user.id}-api-#{user.username}"
else
'api-public'
end
end
end
class ApplicationController < ActionController::Base

View file

@ -1,15 +1,15 @@
module Shared::UserStamper
extend ActiveSupport::Concern
def stamp(obj)
return false if obj.nil? || !obj.has_attribute?(:created_by_id && :updated_by_id)
# def stamp(obj)
# return false if obj.nil? || !obj.has_attribute?(:created_by_id && :updated_by_id)
if obj.new_record?
obj.created_by_id = current_api_user.id
else
obj.updated_by_id = current_api_user.id
end
# if obj.new_record?
# obj.created_by_id = current_api_user.id
# else
# obj.updated_by_id = current_api_user.id
# end
true
end
# true
# end
end

View file

@ -1,15 +1,10 @@
class Epp::ContactsController < EppController
include Shared::UserStamper ## Refactor this?
helper WhodunnitHelper ## Refactor this?
def user_for_paper_trail ## Refactor this?
current_api_user ? "#{current_api_user.id}-ApiUser" : nil
end
def create
@contact = Contact.new(contact_and_address_attributes)
@contact.registrar = current_api_user.registrar
render_epp_response '/epp/contacts/create' and return if stamp(@contact) && @contact.save
render_epp_response '/epp/contacts/create' and return if @contact.save
handle_errors(@contact)
end
@ -18,8 +13,8 @@ class Epp::ContactsController < EppController
code = params_hash['epp']['command']['update']['update'][:id]
@contact = Contact.where(code: code).first
# if update_rights? && stamp(@contact) && @contact.update_attributes(contact_and_address_attributes(:update))
if owner? && stamp(@contact) && @contact.update_attributes(contact_and_address_attributes(:update))
# if update_rights? && @contact.update_attributes(contact_and_address_attributes(:update))
if owner? && @contact.update_attributes(contact_and_address_attributes(:update))
render_epp_response 'epp/contacts/update'
else
contact_exists?(code)

View file

@ -22,7 +22,14 @@ class EppController < ApplicationController
end
def current_api_user
@current_api_user ||= ApiUser.find(epp_session[:api_user_id]) if epp_session[:api_user_id]
return @current_api_user if @current_api_user
@current_api_user ||= ApiUser.find_by_id(epp_session[:api_user_id])
# by default PaperTrail uses before filter and at that
# time current_api_user is not yet present
::PaperTrail.whodunnit = api_user_log_str(@current_api_user)
::PaperSession.session = epp_session.session_id if epp_session.session_id.present?
@current_api_user
end
# ERROR + RESPONSE HANDLING
@ -198,7 +205,7 @@ class EppController < ApplicationController
request_successful: epp_errors.empty?,
request_object: params[:epp_object_type],
response: @response,
api_user_name: @api_user.try(:to_s) || current_api_user.try(:to_s),
api_user_name: PaperTrail.whodunnit,
api_user_registrar: @api_user.try(:registrar).try(:to_s) || current_api_user.try(:registrar).try(:to_s),
ip: request.ip
})

View file

@ -1,4 +1,6 @@
class Address < ActiveRecord::Base
include Versions # version/address_version.rb
LOCAL_TYPE_SHORT = 'loc'
INTERNATIONAL_TYPE_SHORT = 'int'
LOCAL_TYPE = 'LocalAddress'
@ -9,8 +11,6 @@ class Address < ActiveRecord::Base
belongs_to :contact
has_paper_trail class_name: 'AddressVersion'
def country
Country.new(country_code)
end

View file

@ -1,4 +0,0 @@
class AddressVersion < PaperTrail::Version
self.table_name = :address_versions
self.sequence_name = :address_version_id_seq
end

View file

@ -1,5 +1,6 @@
# rubocop: disable Metrics/ClassLength
class ApiUser < ActiveRecord::Base
include Versions # version/api_user_version.rb
# TODO: should have max request limit per day
belongs_to :registrar
has_many :contacts

View file

@ -1,35 +1,36 @@
module DomainVersionObserver
extend ActiveSupport::Concern
included do
after_save :delayed_whois_update
end
# TODO: remove old
# included do
# after_save :delayed_whois_update
# end
private
# private
def delayed_whois_update
name = domain_name
return unless name
body = snapshot
delay.update_private_whois(name, body)
delay.update_public_whois(name, body)
end
# def delayed_whois_update
# name = domain_name
# return unless name
# body = snapshot
# delay.update_private_whois(name, body)
# delay.update_public_whois(name, body)
# end
def update_private_whois(domain_name, body)
wd = Whois::PublicDomain.find_or_initialize_by(name: domain_name)
wd.body = body
wd.save!
end
# def update_private_whois(domain_name, body)
# wd = Whois::PublicDomain.find_or_initialize_by(name: domain_name)
# wd.body = body
# wd.save!
# end
def update_public_whois(domain_name, body)
wd = Whois::PrivateDomain.find_or_initialize_by(name: domain_name)
wd.body = body
wd.save!
end
# def update_public_whois(domain_name, body)
# wd = Whois::PrivateDomain.find_or_initialize_by(name: domain_name)
# wd.body = body
# wd.save!
# end
def domain_name
name = reify.try(:name)
name = load_snapshot[:domain][:name] if event == 'create'
return name if name
end
# def domain_name
# name = reify.try(:name)
# name = load_snapshot[:domain][:name] if event == 'create'
# return name if name
# end
end

View file

@ -1,22 +1,23 @@
module UserEvents
extend ActiveSupport::Concern
module ClassMethods
def registrar_events(id)
registrar = Registrar.find(id)
return [] unless registrar
@events = []
registrar.users.each { |user| @events << user_events(user.id) }
registrar.api_users.each { |user| @events << epp_user_events(user.id) }
@events
end
# TODO: remove old
# module ClassMethods
# def registrar_events(id)
# registrar = Registrar.find(id)
# return [] unless registrar
# @events = []
# registrar.users.each { |user| @events << user_events(user.id) }
# registrar.epp_users.each { |user| @events << epp_user_events(user.id) }
# @events
# end
def user_events(id)
where(whodunnit: id.to_s)
end
# def user_events(id)
# where(whodunnit: id.to_s)
# end
def epp_user_events(id)
where(whodunnit: "#{id}-ApiUser")
end
end
# def epp_user_events(id)
# where(whodunnit: "#{id}-EppUser")
# end
# end
end

View file

@ -0,0 +1,12 @@
module VersionSession
extend ActiveSupport::Concern
included do
before_save :add_session
def add_session
self.session = PaperSession.session
true
end
end
end

View file

@ -0,0 +1,32 @@
# Papertrail concerns is mainly tested at country spec
module Versions
extend ActiveSupport::Concern
included do
has_paper_trail class_name: "#{model_name}Version"
# add creator and updator
before_create :add_creator
before_create :add_updator
before_update :add_updator
def add_creator
self.creator_str = ::PaperTrail.whodunnit
true
end
def add_updator
self.updator_str = ::PaperTrail.whodunnit
true
end
# callbacks
def touch_domain_version
domain.try(:touch_with_version)
end
def touch_domains_version
domains.each(&:touch_with_version)
end
end
end

View file

@ -1,6 +1,5 @@
class Contact < ActiveRecord::Base
# TODO: Foreign contact will get email with activation link/username/temp password
include Versions # version/contact_version.rb
include EppErrors
has_one :address, dependent: :destroy
@ -10,9 +9,6 @@ class Contact < ActiveRecord::Base
has_many :domains, through: :domain_contacts
has_many :statuses, class_name: 'ContactStatus'
# TODO: remove the x_by
belongs_to :created_by, class_name: 'ApiUser', foreign_key: :created_by_id
belongs_to :updated_by, class_name: 'ApiUser', foreign_key: :updated_by_id
belongs_to :registrar
accepts_nested_attributes_for :address, :disclosure
@ -34,17 +30,16 @@ class Contact < ActiveRecord::Base
delegate :zip, to: :address # , prefix: true
# callbacks
# TODO: remove old
# after_commit :domains_snapshot
after_update :domains_snapshot
after_destroy :domains_snapshot
# after_update :domains_snapshot
# after_destroy :domains_snapshot
before_create :generate_code
before_create :generate_auth_info
after_create :ensure_disclosure
# scopes
scope :current_registrars, ->(id) { where(registrar_id: id) }
# archiving
has_paper_trail class_name: 'ContactVersion'
IDENT_TYPE_ICO = 'ico'
IDENT_TYPES = [
@ -72,13 +67,14 @@ class Contact < ActiveRecord::Base
create_disclosure! unless disclosure
end
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.create_version # Method from paper_trail
end
end
# TODO: remove old
# 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.create_version # Method from paper_trail
# end
# end
def juridical?
ident_type == IDENT_TYPE_ICO
@ -89,11 +85,11 @@ class Contact < ActiveRecord::Base
end
def cr_id
created_by ? created_by.username : nil
# created_by ? created_by.username : nil
end
def up_id
updated_by ? updated_by.username : nil
# updated_by ? updated_by.username : nil
end
def auth_info_matches(pw)
@ -148,16 +144,17 @@ class Contact < ActiveRecord::Base
name
end
# TODO: remove old
# for archiving
def snapshot
{
name: name,
phone: phone,
code: code,
ident: ident,
email: email
}
end
# def snapshot
# {
# name: name,
# phone: phone,
# code: code,
# ident: ident,
# email: email
# }
# end
class << self
# non-EPP

View file

@ -1,4 +1,5 @@
class ContactDisclosure < ActiveRecord::Base
include Versions # version/contact_disclosure_version.rb
belongs_to :contact
def attributes_with_flag

View file

@ -1,4 +1,5 @@
class ContactStatus < ActiveRecord::Base
include Versions # version/contact_status_version.rb
include EppErrors
belongs_to :contact

View file

@ -1,8 +0,0 @@
class ContactVersion < PaperTrail::Version
include UserEvents
scope :deleted, -> { where(event: 'destroy') }
self.table_name = :contact_versions
self.sequence_name = :contact_version_id_seq
end

View file

@ -1,4 +1,5 @@
class Dnskey < ActiveRecord::Base
include Versions # version/dnskey_version.rb
include EppErrors
belongs_to :domain

View file

@ -1,4 +1,7 @@
class Domain < ActiveRecord::Base
include Versions # version/domain_version.rb
has_paper_trail class_name: "DomainVersion", meta: { children: :children_log }
# TODO: whois requests ip whitelist for full info for own domains and partial info for other domains
# TODO: most inputs should be trimmed before validatation, probably some global logic?
paginates_per 10 # just for showoff
@ -17,7 +20,9 @@ class Domain < ActiveRecord::Base
-> { where(domain_contacts: { contact_type: DomainContact::ADMIN }) },
through: :domain_contacts, source: :contact
has_many :nameservers, dependent: :delete_all, after_add: :track_nameserver_add
# TODO: remove old
# has_many :nameservers, dependent: :delete_all, after_add: :track_nameserver_add
has_many :nameservers, dependent: :delete_all
accepts_nested_attributes_for :nameservers, allow_destroy: true,
reject_if: proc { |attrs| attrs[:hostname].blank? }
@ -47,6 +52,10 @@ class Domain < ActiveRecord::Base
before_create :set_validity_dates
before_create :attach_default_contacts
after_save :manage_automatic_statuses
before_save :touch_always_version
def touch_always_version
self.updated_at = Time.now
end
validates :name_dirty, domain_name: true, uniqueness: true
validates :period, numericality: { only_integer: true }
@ -102,9 +111,10 @@ class Domain < ActiveRecord::Base
attr_accessor :owner_contact_typeahead, :update_me
# TODO: remove old
# archiving
# if proc works only on changes on domain sadly
has_paper_trail class_name: 'DomainVersion', meta: { snapshot: :create_snapshot }, if: proc(&:new_version)
# has_paper_trail class_name: 'DomainVersion', meta: { snapshot: :create_snapshot }, if: proc(&:new_version)
def tech_domain_contacts
domain_contacts.select { |x| x.contact_type == DomainContact::TECH }
@ -114,46 +124,51 @@ class Domain < ActiveRecord::Base
domain_contacts.select { |x| x.contact_type == DomainContact::ADMIN }
end
def new_version
return false if versions.try(:last).try(:snapshot) == create_snapshot
true
end
# TODO: remove old
# def new_version
# return false if versions.try(:last).try(:snapshot) == create_snapshot
# true
# end
def create_version
return true unless PaperTrail.enabled?
return true unless valid?
touch_with_version if new_version
end
# TODO: remove old
# def create_version
# return true unless PaperTrail.enabled?
# return true unless valid?
# touch_with_version if new_version
# end
def track_nameserver_add(_nameserver)
return true if versions.count == 0
return true unless valid? && new_version
# TODO: remove old
# def track_nameserver_add(_nameserver)
# return true if versions.count == 0
# return true unless valid? && new_version
touch_with_version
end
# touch_with_version
# end
def create_snapshot
oc = owner_contact.snapshot if owner_contact.is_a?(Contact)
{
owner_contact: oc,
tech_contacts: tech_contacts.map(&:snapshot),
admin_contacts: admin_contacts.map(&:snapshot),
nameservers: nameservers.map(&:snapshot),
domain: make_snapshot
}.to_yaml
end
# TODO: remove old
# def create_snapshot
# oc = owner_contact.snapshot if owner_contact.is_a?(Contact)
# {
# owner_contact: oc,
# tech_contacts: tech_contacts.map(&:snapshot),
# admin_contacts: admin_contacts.map(&:snapshot),
# nameservers: nameservers.map(&:snapshot),
# domain: make_snapshot
# }.to_yaml
# end
def make_snapshot
{
name: name,
status: status,
period: period,
period_unit: period_unit,
registrar_id: registrar.try(:id),
valid_to: valid_to,
valid_from: valid_from
}
end
# TODO: remove old
# def make_snapshot
# {
# name: name,
# status: status,
# period: period,
# period_unit: period_unit,
# registrar_id: registrar.try(:id),
# valid_to: valid_to,
# valid_from: valid_from
# }
# end
def name=(value)
value.strip!
@ -271,11 +286,20 @@ class Domain < ActiveRecord::Base
end
end
def children_log
log = HashWithIndifferentAccess.new
log[:admin_contacts] = admin_contacts.map {|ac| ac.attributes}
log[:tech_contacts] = tech_contacts.map {|tc| tc.attributes}
log[:nameservers] = nameservers.map {|ns| ns.attributes}
log[:owner_contact] = [owner_contact.try(:attributes)]
log
end
class << self
def convert_period_to_time(period, unit)
return period.to_i.days if unit == 'd'
return period.to_i.days if unit == 'd'
return period.to_i.months if unit == 'm'
return period.to_i.years if unit == 'y'
return period.to_i.years if unit == 'y'
end
end
end

View file

@ -1,10 +1,12 @@
class DomainContact < ActiveRecord::Base
include Versions # version/domain_contact_version.rb
include EppErrors
belongs_to :contact
belongs_to :domain
after_create :domain_snapshot
after_destroy :domain_snapshot
# TODO: remove old
# after_create :domain_snapshot
# after_destroy :domain_snapshot
# after_save :domain_snapshot
attr_accessor :value_typeahead
@ -38,10 +40,11 @@ class DomainContact < ActiveRecord::Base
@value_typeahead || contact.try(:name) || nil
end
def domain_snapshot
return true if domain.nil?
return true if domain.versions.count == 0 # avoid snapshot on creation
domain.create_version
true
end
# TODO: remove old
# def domain_snapshot
# return true if domain.nil?
# return true if domain.versions.count == 0 # avoid snapshot on creation
# domain.create_version
# true
# end
end

View file

@ -1,4 +1,5 @@
class DomainStatus < ActiveRecord::Base
include Versions # version/domain_status_version.rb
include EppErrors
belongs_to :domain
@ -50,9 +51,6 @@ class DomainStatus < ActiveRecord::Base
SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED
]
# archiving
has_paper_trail class_name: 'DomainStatusVersion'
def epp_code_map
{
'2302' => [ # Object exists

View file

@ -1,4 +0,0 @@
class DomainStatusVersion < PaperTrail::Version
self.table_name = :domain_status_versions
self.sequence_name = :domain_status_version_id_seq
end

View file

@ -1,4 +1,5 @@
class DomainTransfer < ActiveRecord::Base
include Versions # version/domain_transfer_version.rb
belongs_to :domain
belongs_to :transfer_from, class_name: 'Registrar'

View file

@ -1,36 +0,0 @@
class DomainVersion < PaperTrail::Version
include UserEvents
include DomainVersionObserver if Setting.whois_enabled # unless Setting.whois_enabled
scope :deleted, -> { where(event: 'destroy') }
self.table_name = :domain_versions
self.sequence_name = :domain_version_id_seq
def load_snapshot
snapshot ? YAML.load(snapshot) : {}
end
def previous?
return true if previous
false
end
def name
name = reify.try(:name)
name = load_snapshot[:domain].try(:[], :name) unless name
name
end
def changed_elements
return [] unless previous?
@changes = []
@previous_snap = previous.load_snapshot
@snap = load_snapshot
[:owner_contact, :tech_contacts, :admin_contacts, :nameservers, :domain].each do |key|
@changes << key unless @snap[key] == @previous_snap[key]
end
@changes
end
end

View file

@ -162,36 +162,36 @@ class Epp::EppDomain < Domain
end
def detach_contacts(contact_list)
to_delete = []
to_destroy = []
contact_list.each do |k, v|
v.each do |x|
contact = domain_contacts.joins(:contact).where(contacts: { code: x[:contact] }, contact_type: k.to_s)
if contact.blank?
add_epp_error('2303', 'contact', x[:contact], [:domain_contacts, :not_found])
else
to_delete << contact
to_destroy << contact
end
end
end
domain_contacts.delete(to_delete)
domain_contacts.destroy(to_destroy)
end
def detach_nameservers(ns_list)
to_delete = []
to_destroy = []
ns_list.each do |ns_attrs|
nameserver = nameservers.where(ns_attrs)
if nameserver.blank?
add_epp_error('2303', 'hostAttr', ns_attrs[:hostname], [:nameservers, :not_found])
else
to_delete << nameserver
to_destroy << nameserver
end
end
nameservers.delete(to_delete)
nameservers.destroy(to_destroy)
end
def detach_statuses(status_list)
to_delete = []
to_destroy = []
status_list.each do |x|
unless DomainStatus::CLIENT_STATUSES.include?(x[:value])
add_epp_error('2303', 'status', x[:value], [:domain_statuses, :not_found])
@ -202,11 +202,11 @@ class Epp::EppDomain < Domain
if status.blank?
add_epp_error('2303', 'status', x[:value], [:domain_statuses, :not_found])
else
to_delete << status
to_destroy << status
end
end
domain_statuses.delete(to_delete)
domain_statuses.destroy(to_destroy)
end
def attach_dnskeys(dnssec_data)
@ -258,13 +258,13 @@ class Epp::EppDomain < Domain
def detach_dnskeys(dnssec_data)
return false unless validate_dnssec_data(dnssec_data)
to_delete = []
to_destroy = []
dnssec_data[:ds_data].each do |x|
ds = dnskeys.where(ds_key_tag: x[:ds_key_tag])
if ds.blank?
add_epp_error('2303', 'keyTag', x[:key_tag], [:dnskeys, :not_found])
else
to_delete << ds
to_destroy << ds
end
end
@ -273,11 +273,11 @@ class Epp::EppDomain < Domain
if ds.blank?
add_epp_error('2303', 'publicKey', x[:public_key], [:dnskeys, :not_found])
else
to_delete << ds
to_destroy << ds
end
end
dnskeys.delete(to_delete)
dnskeys.destroy(to_destroy)
end
### RENEW ###

View file

@ -1,4 +1,5 @@
class Keyrelay < ActiveRecord::Base
include Versions # version/keyrelay_version.rb
include EppErrors
belongs_to :domain
@ -15,6 +16,8 @@ class Keyrelay < ActiveRecord::Base
validate :validate_expiry_relative_xor_expiry_absolute
after_save :touch_domain_version
def epp_code_map
{
'2005' => [

View file

@ -1,4 +1,5 @@
class LegalDocument < ActiveRecord::Base
include Versions # version/legal_document_version.rb
belongs_to :documentable, polymorphic: true
TYPES = %w(pdf bdoc ddoc zip rar gz tar 7z)

View file

@ -1,4 +1,5 @@
class Message < ActiveRecord::Base
include Versions # version/message_version.rb
belongs_to :registrar
before_create -> { self.queued = true }

View file

@ -1,4 +1,5 @@
class Nameserver < ActiveRecord::Base
include Versions # version/nameserver_version.rb
include EppErrors
belongs_to :registrar
@ -10,9 +11,8 @@ class Nameserver < ActiveRecord::Base
validates :ipv6, format: { with: /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/, allow_blank: true }
# rubocop: enable Metrics/LineLength
# archiving
has_paper_trail class_name: 'NameserverVersion'
after_destroy :domain_version
# TODO: remove old
# after_destroy :domain_version
before_validation :normalize_attributes
@ -34,13 +34,14 @@ class Nameserver < ActiveRecord::Base
}
end
def snapshot
{
hostname: hostname,
ipv4: ipv4,
ipv6: ipv6
}
end
# TODO: remove old
# def snapshot
# {
# hostname: hostname,
# ipv4: ipv4,
# ipv6: ipv6
# }
# end
def normalize_attributes
self.hostname = hostname.try(:strip).try(:downcase)
@ -48,9 +49,10 @@ class Nameserver < ActiveRecord::Base
self.ipv6 = ipv6.try(:strip).try(:upcase)
end
def domain_version
domain.create_version if domain
end
# TODO: remove old
# def domain_version
# domain.create_version if domain
# end
def to_s
hostname

View file

@ -1,4 +0,0 @@
class NameserverVersion < PaperTrail::Version
self.table_name = :nameserver_versions
self.sequence_name = :nameserver_version_id_seq
end

View file

@ -1,4 +1,6 @@
class Registrar < ActiveRecord::Base
include Versions # version/registrar_version.rb
has_many :domains, dependent: :restrict_with_error
has_many :contacts, dependent: :restrict_with_error
has_many :api_users, dependent: :restrict_with_error
@ -6,6 +8,7 @@ class Registrar < ActiveRecord::Base
validates :name, :reg_no, :address, :country, :email, presence: true
validates :name, :reg_no, uniqueness: true
after_save :touch_domains_version
validates :email, :billing_email, format: /@/, allow_blank: true

View file

@ -1,2 +1,3 @@
class ReservedDomain < ActiveRecord::Base
include Versions # version/reserved_domain_version.rb
end

View file

@ -1,2 +1,3 @@
class Setting < RailsSettings::CachedSettings
include Versions # version/setting_version.rb
end

View file

@ -1,4 +1,5 @@
class User < ActiveRecord::Base
include Versions # version/user_version.rb
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :trackable, :timeoutable

View file

@ -0,0 +1,5 @@
class AddressVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_addresses
self.sequence_name = :log_addresses_id_seq
end

View file

@ -0,0 +1,5 @@
class ApiUserVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_api_users
self.sequence_name = :log_api_users_id_seq
end

View file

@ -0,0 +1,5 @@
class ContactDisclosureVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_contact_disclosures
self.sequence_name = :log_contact_disclosures_id_seq
end

View file

@ -0,0 +1,5 @@
class ContactStatusVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_contact_statuses
self.sequence_name = :log_contact_statuses_id_seq
end

View file

@ -0,0 +1,9 @@
class ContactVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_contacts
self.sequence_name = :log_contacts_id_seq
# include UserEvents
# scope :deleted, -> { where(event: 'destroy') }
end

View file

@ -0,0 +1,5 @@
class CountryVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_countries
self.sequence_name = :log_countries_id_seq
end

View file

@ -0,0 +1,5 @@
class DnskeyVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_dnskeys
self.sequence_name = :log_dnskeys_id_seq
end

View file

@ -0,0 +1,5 @@
class DomainContactVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_domain_contacts
self.sequence_name = :log_domain_contacts_id_seq
end

View file

@ -0,0 +1,5 @@
class DomainStatusVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_domain_statuses
self.sequence_name = :log_domain_statuses_id_seq
end

View file

@ -0,0 +1,5 @@
class DomainTransferVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_domain_transfers
self.sequence_name = :log_domain_transfers_id_seq
end

View file

@ -0,0 +1,43 @@
class DomainVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_domains
self.sequence_name = :log_domains_id_seq
include UserEvents
# TODO: remove old
# include DomainVersionObserver if Setting.whois_enabled # unless Setting.whois_enabled
scope :deleted, -> { where(event: 'destroy') }
# TODO: remove old
# def load_snapshot
# snapshot ? YAML.load(snapshot) : {}
# end
# TODO: remove old
# def previous?
# return true if previous
# false
# end
# TODO: remove old
# def name
# name = reify.try(:name)
# name = load_snapshot[:domain].try(:[], :name) unless name
# name
# end
# TODO: remove old
# def changed_elements
# return [] unless previous?
# @changes = []
# @previous_snap = previous.load_snapshot
# @snap = load_snapshot
# [:owner_contact, :tech_contacts, :admin_contacts, :nameservers, :domain].each do |key|
# @changes << key unless @snap[key] == @previous_snap[key]
# end
# @changes
# end
end

View file

@ -0,0 +1,5 @@
class KeyrelayVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_keyrelays
self.sequence_name = :log_keyrelays_id_seq
end

View file

@ -0,0 +1,5 @@
class LegalDocumentVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_legal_documents
self.sequence_name = :log_legal_documents_id_seq
end

View file

@ -0,0 +1,5 @@
class MessageVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_messages
self.sequence_name = :log_messages_id_seq
end

View file

@ -0,0 +1,5 @@
class NameserverVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_nameservers
self.sequence_name = :log_nameservers_id_seq
end

View file

@ -0,0 +1,5 @@
class RegistrarVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_registrars
self.sequence_name = :log_registrars_id_seq
end

View file

@ -0,0 +1,5 @@
class ReservedDomainVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_reserved_domains
self.sequence_name = :log_reserved_domains_id_seq
end

View file

@ -0,0 +1,5 @@
class SettingVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_settings
self.sequence_name = :log_settings_id_seq
end

View file

@ -0,0 +1,5 @@
class UserVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_users
self.sequence_name = :log_users_id_seq
end

View file

@ -0,0 +1,5 @@
class ZonefileSettingVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_zonefile_settings
self.sequence_name = :log_zonefile_settings_id_seq
end

View file

@ -1,4 +1,5 @@
class ZonefileSetting < ActiveRecord::Base
include Versions # version/zonefile_setting_version.rb
validates :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, presence: true
validates :ttl, :refresh, :retry, :expire, :minimum_ttl, numericality: { only_integer: true }

View file

@ -1,63 +1,125 @@
%td{ class: changes.include?(:domain) ? 'edit-highlight' : 'no-highlight' }
- if children[:domain]
%p{:style => "font-size:x-small;"}
= children[:domain][:period]
= children[:domain][:period_unit] if children[:domain][:period]
- if children[:domain][:valid_to] && children[:domain][:valid_from]
= ","
= l(children[:domain][:valid_from], format: :date) + '-' + l(children[:domain][:valid_to], format: :date)
- if children[:domain].try(:[], :registrar_id)
= ","
= Registrar.find(children[:domain][:registrar_id]).try(:name)
- if children[:domain][:status]
= ',' + children[:domain][:status]
%td{ class: changes.include?(:owner_contact) ? 'edit-highlight' : 'no-highlight' }
- if children[:owner_contact]
%p{:style => "font-size:x-small;"}
= children[:owner_contact][:name]
= ","
= children[:owner_contact][:phone]
= ","
= children[:owner_contact][:email]
= ","
= children[:owner_contact][:code]
%td{ class: changes.include?(:admin_contacts) ? 'edit-highlight' : 'no-highlight' }
- if children[:admin_contacts]
- children[:admin_contacts].each do |ac|
%p{:style => "font-size:x-small;"}
= ac[:name]
= ","
= ac[:phone]
= ","
= ac[:email]
= ","
= ac[:code]
%td{ class: changes.include?(:tech_contacts) ? 'edit-highlight' : 'no-highlight' }
- if children[:tech_contacts]
- children[:tech_contacts].each do |tc|
%p{:style => "font-size:x-small;"}
= tc[:name]
= ","
= tc[:phone]
= ","
= tc[:email]
= ","
= tc[:code]
%td{ class: changes.include?(:nameservers) ? 'edit-highlight' : 'no-highlight' }
- if children[:nameservers]
- children[:nameservers].each do |ns|
%p{:style => "font-size:x-small;"}
= ns[:hostname]
= ","
= ns[:ipv4] || ns[:ipv6]
- children = HashWithIndifferentAccess.new(version.children)
- nameservers = children[:nameservers] || []
- tech_contacts = children[:tech_contacts] || []
- admin_contacts = children[:admin_contacts] || []
- owner_contact = children[:owner_contact] || []
%td
%p{ :style => 'font-size:x-small;' }
= l(version.created_at, format: :short)
= whodunnit_with_protocol(version.whodunnit)
%p.nowrap
= l(domain.updated_at, format: :short)
= version.event
%p.text-right
= version.terminator
%td
%p
= "#{domain.period}#{domain.period_unit}"
= "#{l(domain.valid_from, format: :date)} - #{l(domain.valid_to, format: :date)}"
%p
= domain.status
%td
- owner_contact.each do |oc|
%p
= oc[:name]
= oc[:phone]
= oc[:email]
%p
= oc[:code]
%td
- admin_contacts.each do |ac|
%p
= ac[:name]
= ac[:phone]
= ac[:email]
%p
= ac[:code]
%td
- tech_contacts.each do |tc|
%p
= tc[:name]
= tc[:phone]
= tc[:email]
%p
= tc[:code]
%td
- nameservers.each do |ns|
%p
= ns[:hostname]
%br
= ns[:ipv4]
= ns[:ipv6]
%td
%p
= domain.registrar.name
-# %td
-# = version.children.inspect
-# %td{ class: changes.include?(:domain) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:domain]
-# %p{:style => "font-size:x-small;"}
-# = children[:domain][:period]
-# = children[:domain][:period_unit] if children[:domain][:period]
-# - if children[:domain][:valid_to] && children[:domain][:valid_from]
-# = ","
-# = l(children[:domain][:valid_from], format: :date) + '-' + l(children[:domain][:valid_to], format: :date)
-# - if children[:domain].try(:[], :registrar_id)
-# = ","
-# = Registrar.find(children[:domain][:registrar_id]).try(:name)
-# - if children[:domain][:status]
-# = ',' + children[:domain][:status]
-# %td{ class: changes.include?(:owner_contact) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:owner_contact]
-# %p{:style => "font-size:x-small;"}
-# = children[:owner_contact][:name]
-# = ","
-# = children[:owner_contact][:phone]
-# = ","
-# = children[:owner_contact][:email]
-# = ","
-# = children[:owner_contact][:code]
-# %td{ class: changes.include?(:admin_contacts) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:admin_contacts]
-# - children[:admin_contacts].each do |ac|
-# %p{:style => "font-size:x-small;"}
-# = ac[:name]
-# = ","
-# = ac[:phone]
-# = ","
-# = ac[:email]
-# = ","
-# = ac[:code]
-# %td{ class: changes.include?(:tech_contacts) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:tech_contacts]
-# - children[:tech_contacts].each do |tc|
-# %p{:style => "font-size:x-small;"}
-# = tc[:name]
-# = ","
-# = tc[:phone]
-# = ","
-# = tc[:email]
-# = ","
-# = tc[:code]
-# %td{ class: changes.include?(:nameservers) ? 'edit-highlight' : 'no-highlight' }
-# - if children[:nameservers]
-# - children[:nameservers].each do |ns|
-# %p{:style => "font-size:x-small;"}
-# = ns[:hostname]
-# = ","
-# = ns[:ipv4] || ns[:ipv6]
-# %td
-# %p{ :style => 'font-size:x-small;' }
-# = l(version.created_at, format: :short)
-# = whodunnit_with_protocol(version.whodunnit)
-# = version.event

View file

@ -1,28 +1,31 @@
.row
.col-sm-12
%h2.text-center-xs= t('domains')
.col-sm-6
%h2.text-center-xs
= "#{t(:domain_history)}: #{@domain.name}"
.col-sm-6
%h2.text-right.text-center-xs
%hr
.row
.col-md-12
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-1'}
= t('name')
%th{class: 'col-xs-1'}
= sort_link(@q, 'whodunnit')
%th{class: 'col-xs-1'}
= sort_link(@q, 'created_at')
%th{class: 'col-xs-1'}= t(:timestap)
%th{class: 'col-xs-2'}= t(:period)
%th{class: 'col-xs-2'}= t(:owner)
%th{class: 'col-xs-2'}= t(:admin)
%th{class: 'col-xs-2'}= t(:tech)
%th{class: 'col-xs-2'}= t(:nameservers)
%th{class: 'col-xs-2'}= t(:registrar)
%tbody
- @domains.each do |domain|
- obj = domain.reify
%tr
%td= link_to(obj.name, admin_domain_version_path(obj))
%td= whodunnit_with_protocol(domain.whodunnit) unless domain.whodunnit.nil?
%td= l(obj.created_at, format: :short)
%tr.small
= render 'admin/domain_versions/version',
domain: @domain, version: @domain.versions.last
.row
.col-md-12
= paginate @domains
- @domain.versions.not_creates.reverse.each do |version|
%tr.small
= render 'admin/domain_versions/version',
domain: version.reify, version: version.previous

View file

@ -0,0 +1,28 @@
-# .row
-# .col-sm-12
-# %h2.text-center-xs= t('domains')
-# %hr
-# .row
-# .col-md-12
-# .table-responsive
-# %table.table.table-hover.table-bordered.table-condensed
-# %thead
-# %tr
-# %th{class: 'col-xs-1'}
-# = t('name')
-# %th{class: 'col-xs-1'}
-# = sort_link(@q, 'whodunnit')
-# %th{class: 'col-xs-1'}
-# = sort_link(@q, 'created_at')
-# %tbody
-# - @domains.each do |domain|
-# - obj = domain.reify
-# %tr
-# %td= link_to(obj.name, admin_domain_version_path(obj))
-# %td= whodunnit_with_protocol(domain.whodunnit) unless domain.whodunnit.nil?
-# %td= l(obj.created_at, format: :short)
-# .row
-# .col-md-12
-# = paginate @domains

View file

@ -1,29 +0,0 @@
.row
.col-sm-6
%h2.text-center-xs
= "#{t(:domain_history)} for " + @name.to_s
.col-sm-6
%h2.text-right.text-center-xs
%hr
.row
.col-md-12
.table-responsive
%table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-2'}= t(:'domain_info')
%th{class: 'col-xs-2'}= t(:'owner_contact')
%th{class: 'col-xs-2'}= t(:'admin_contacts')
%th{class: 'col-xs-2'}= t(:'tech_contacts')
%th{class: 'col-xs-2'}= t(:'nameservers')
%th{class: 'col-xs-1'}= t(:'changes_info')
%tbody
- @versions.each do |version|
%tr
- children = version.load_snapshot
- next unless children.is_a?(Hash)
- children = HashWithIndifferentAccess.new(children)
- changes = version.changed_elements
= render 'admin/domain_versions/version', children: children, version: version, changes: changes

View file

@ -4,8 +4,8 @@
= "#{t('domain_details')}"
.col-sm-6
%h2.text-right.text-center-xs
= link_to(t('edit_statuses'), edit_admin_domain_path(@domain), class: 'btn btn-primary')
= link_to(t(:'history'), admin_domain_version_path(@domain.id), method: :get, class: 'btn btn-primary')
= link_to(t(:edit_statuses), edit_admin_domain_path(@domain), class: 'btn btn-primary')
= link_to(t(:history), admin_domain_domain_versions_path(@domain.id), method: :get, class: 'btn btn-primary')
%hr
.row

View file

@ -45,6 +45,7 @@
.row
.col-md-12
%hr
= paginate @epp_logs
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%thead

View file

@ -45,7 +45,7 @@
%li.dropdown-header= t('system')
%li= link_to t('settings'), admin_settings_path
%li= link_to t('zonefile'), admin_zonefile_settings_path
%li= link_to t(:domains_history), admin_domain_versions_path
-# %li= link_to t(:domains_history), admin_domain_versions_path
%li= link_to t(:epp_logs), admin_epp_logs_path
%li= link_to t(:repp_logs), admin_repp_logs_path
%li= link_to t(:background_jobs), admin_delayed_jobs_path

View file

@ -30,6 +30,9 @@ module Registry
config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
# Load all model subdirs
config.autoload_paths += Dir[Rails.root.join('app', 'models', '**/')]
# Active Record used to suppresses errors raised within
# `after_rollback`/`after_commit` callbacks and only printed them to the logs.
# In the next version, these errors will no longer be suppressed.

View file

@ -0,0 +1,26 @@
# the following line is required for PaperTrail >= 4.0.0 with Rails
PaperTrail::Rails::Engine.eager_load!
PaperTrail::Version.module_eval do
self.abstract_class = true
end
# Store console and rake changes in versions
if defined?(::Rails::Console) || File.basename($PROGRAM_NAME).split(' ').first == 'spring'
PaperTrail.whodunnit = "console-#{`whoami`.strip}"
elsif File.basename($PROGRAM_NAME) == "rake"
# rake username does not work when spring enabled
PaperTrail.whodunnit = "rake-#{`whoami`.strip} #{ARGV.join ' '}"
end
class PaperSession
class << self
def session
@session ||= Time.now.to_s(:db)
end
def session=(code)
@session = code
end
end
end

View file

@ -1,27 +1,4 @@
class EppConstraint
OBJECT_TYPES = {
domain: { domain: 'urn:ietf:params:xml:ns:domain-1.0' },
contact: { contact: 'urn:ietf:params:xml:ns:contact-1.0' }
}
def initialize(type)
@type = type
end
# creates parsed_frame, detects epp request object
def matches?(request)
parsed_frame = Nokogiri::XML(request.params[:raw_frame])
unless [:keyrelay, :poll].include?(@type)
element = "//#{@type}:#{request.params[:action]}"
return false if parsed_frame.xpath("#{element}", OBJECT_TYPES[@type]).none?
end
request.params[:parsed_frame] = parsed_frame.remove_namespaces!
request.params[:epp_object_type] = @type
true
end
end
require 'epp_constraint'
Rails.application.routes.draw do
namespace(:epp, defaults: { format: :xml }) do
@ -50,7 +27,11 @@ Rails.application.routes.draw do
resources :legal_documents
resources :keyrelays
resources :domains
resources :domains do
resources :domain_versions
end
resources :settings
resources :registrars do
collection do
@ -66,7 +47,6 @@ Rails.application.routes.draw do
resources :users
resources :api_users
resources :domain_versions
resources :delayed_jobs

View file

@ -0,0 +1,28 @@
class AddJsonBasedVersions < ActiveRecord::Migration
def change
%w(address contact_disclosure contact contact_status country dnskey
domain_contact domain domain_status domain_transfer epp_user keyrelay
legal_document message nameserver registrar
reserved_domain setting user zonefile_setting
).each do |name|
table_name = "log_#{name.tableize}"
create_table table_name do |t|
t.string :item_type, null: false
t.integer :item_id, null: false
t.string :event, null: false
t.string :whodunnit
t.json :object
t.json :object_changes
t.datetime :created_at
end
add_index table_name, [:item_type, :item_id]
add_index table_name, :whodunnit
add_column name.tableize, :creator_id_tmp, :integer
add_column name.tableize, :updater_id_tmp, :integer
rename_column name.tableize, :creator_id_tmp, :creator_id
rename_column name.tableize, :updater_id_tmp, :updater_id
end
end
end

View file

@ -0,0 +1,14 @@
class DropAllVersionsDisabledByDefault < ActiveRecord::Migration
def change
# All versions are depricated by log_* tables
# comment to remove unneeded old versions tables
# drop_table "version_associations"
# drop_table "versions"
# drop_table "address_versions"
# drop_table "contact_versions"
# drop_table "domain_status_versions"
# drop_table "domain_versions"
# drop_table "nameserver_versions"
end
end

View file

@ -0,0 +1,11 @@
class AddVersions < ActiveRecord::Migration
def change
if ActiveRecord::Base.connection.table_exists? 'versions'
rename_table :versions, :depricated_versions
end
create_table :versions do |t|
t.text :depricated_table_but_somehow_paper_trail_tests_fails_without_it
end
end
end

View file

@ -0,0 +1,5 @@
class RenameLogEppUserToLogApiUser < ActiveRecord::Migration
def change
rename_table :log_epp_users, :log_api_users
end
end

View file

@ -0,0 +1,15 @@
class AddCreatorAndUpdater < ActiveRecord::Migration
def change
%w(address contact_disclosure contact contact_status country dnskey
domain_contact domain domain_status domain_transfer api_user keyrelay
legal_document message nameserver registrar
reserved_domain setting user zonefile_setting
).each do |name|
table_name = name.tableize
remove_column table_name, :creator_id, :string
remove_column table_name, :updater_id, :string
add_column table_name, :creator_str, :string
add_column table_name, :updator_str, :string
end
end
end

View file

@ -0,0 +1,5 @@
class AddNameServerVersionIds < ActiveRecord::Migration
def change
add_column :log_domains, :nameserver_version_ids, :text, array: true, default: []
end
end

View file

@ -0,0 +1,7 @@
class AddMetaToDomain < ActiveRecord::Migration
def change
rename_column :log_domains, :nameserver_version_ids, :nameserver_ids
add_column :log_domains, :tech_contact_ids, :text, array: true, default: []
add_column :log_domains, :admin_contact_ids, :text, array: true, default: []
end
end

View file

@ -0,0 +1,13 @@
class AddSessionIdToLog < ActiveRecord::Migration
def change
%w(address contact_disclosure contact contact_status country dnskey
domain_contact domain domain_status domain_transfer api_user keyrelay
legal_document message nameserver registrar
reserved_domain setting user zonefile_setting
).each do |name|
table_name = name.tableize
add_column "log_#{table_name}", :session, :string
add_column "log_#{table_name}", :children, :json
end
end
end

View file

@ -11,25 +11,19 @@
#
# It's strongly recommended that you check this file into your version control system.
<<<<<<< HEAD
ActiveRecord::Schema.define(version: 20150202084444) do
=======
ActiveRecord::Schema.define(version: 20150130191056) do
>>>>>>> c010000bfec582db543f6a89f263e92b7611c7ef
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "address_versions", force: :cascade do |t|
t.string "item_type", limit: 255, null: false
t.integer "item_id", null: false
t.string "event", limit: 255, null: false
t.string "whodunnit", limit: 255
t.text "object"
t.datetime "created_at"
end
add_index "address_versions", ["item_type", "item_id"], name: "index_address_versions_on_item_type_and_item_id", using: :btree
create_table "addresses", force: :cascade do |t|
t.integer "contact_id"
t.integer "country_id"
<<<<<<< HEAD
t.string "city", limit: 255
t.string "street", limit: 255
t.string "zip", limit: 255
@ -38,17 +32,30 @@ ActiveRecord::Schema.define(version: 20150202084444) do
t.string "street2", limit: 255
t.string "street3", limit: 255
t.string "country_code"
=======
t.string "city"
t.string "street"
t.string "zip"
t.datetime "created_at"
t.datetime "updated_at"
t.string "street2"
t.string "street3"
t.string "creator_str"
t.string "updator_str"
>>>>>>> c010000bfec582db543f6a89f263e92b7611c7ef
end
create_table "api_users", force: :cascade do |t|
t.integer "registrar_id"
t.string "username", limit: 255
t.string "password", limit: 255
t.boolean "active", default: false
t.string "username"
t.string "password"
t.boolean "active", default: false
t.text "csr"
t.text "crt"
t.datetime "created_at"
t.datetime "updated_at"
t.string "creator_str"
t.string "updator_str"
end
create_table "cached_nameservers", id: false, force: :cascade do |t|
@ -69,63 +76,60 @@ ActiveRecord::Schema.define(version: 20150202084444) do
t.boolean "name"
t.boolean "org_name"
t.boolean "address"
t.string "creator_str"
t.string "updator_str"
end
create_table "contact_statuses", force: :cascade do |t|
t.string "value", limit: 255
t.string "description", limit: 255
t.string "value"
t.string "description"
t.integer "contact_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "creator_str"
t.string "updator_str"
end
create_table "contact_versions", force: :cascade do |t|
t.string "item_type", limit: 255, null: false
t.integer "item_id", null: false
t.string "event", limit: 255, null: false
t.string "whodunnit", limit: 255
t.text "object"
t.datetime "created_at"
end
add_index "contact_versions", ["item_type", "item_id"], name: "index_contact_versions_on_item_type_and_item_id", using: :btree
create_table "contacts", force: :cascade do |t|
t.string "code", limit: 255
t.string "type", limit: 255
t.string "reg_no", limit: 255
t.string "phone", limit: 255
t.string "email", limit: 255
t.string "fax", limit: 255
t.string "code"
t.string "type"
t.string "reg_no"
t.string "phone"
t.string "email"
t.string "fax"
t.datetime "created_at"
t.datetime "updated_at"
t.string "ident", limit: 255
t.string "ident_type", limit: 255
t.string "ident"
t.string "ident_type"
t.integer "created_by_id"
t.integer "updated_by_id"
t.string "auth_info", limit: 255
t.string "name", limit: 255
t.string "org_name", limit: 255
t.string "auth_info"
t.string "name"
t.string "org_name"
t.integer "registrar_id"
t.string "creator_str"
t.string "updator_str"
end
create_table "countries", force: :cascade do |t|
t.string "iso", limit: 255
t.string "name", limit: 255
t.string "iso"
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.string "creator_str"
t.string "updator_str"
end
create_table "delayed_jobs", force: :cascade do |t|
t.integer "priority", default: 0, null: false
t.integer "attempts", default: 0, null: false
t.text "handler", null: false
t.integer "priority", default: 0, null: false
t.integer "attempts", default: 0, null: false
t.text "handler", null: false
t.text "last_error"
t.datetime "run_at"
t.datetime "locked_at"
t.datetime "failed_at"
t.string "locked_by", limit: 255
t.string "queue", limit: 255
t.string "locked_by"
t.string "queue"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -134,10 +138,14 @@ ActiveRecord::Schema.define(version: 20150202084444) do
create_table "delegation_signers", force: :cascade do |t|
t.integer "domain_id"
t.string "key_tag", limit: 255
t.string "key_tag"
t.integer "alg"
t.integer "digest_type"
t.string "digest", limit: 255
t.string "digest"
end
create_table "depricated_versions", force: :cascade do |t|
t.datetime "created_at"
end
create_table "dnskeys", force: :cascade do |t|
@ -147,41 +155,36 @@ ActiveRecord::Schema.define(version: 20150202084444) do
t.integer "alg"
t.text "public_key"
t.integer "delegation_signer_id"
t.string "ds_key_tag", limit: 255
t.string "ds_key_tag"
t.integer "ds_alg"
t.integer "ds_digest_type"
t.string "ds_digest", limit: 255
t.string "ds_digest"
t.string "creator_str"
t.string "updator_str"
end
create_table "domain_contacts", force: :cascade do |t|
t.integer "contact_id"
t.integer "domain_id"
t.string "contact_type", limit: 255
t.string "contact_type"
t.datetime "created_at"
t.datetime "updated_at"
t.string "contact_code_cache", limit: 255
t.string "contact_code_cache"
t.string "creator_str"
t.string "updator_str"
end
create_table "domain_status_versions", force: :cascade do |t|
t.string "item_type", limit: 255, null: false
t.integer "item_id", null: false
t.string "event", limit: 255, null: false
t.string "whodunnit", limit: 255
t.text "object"
t.datetime "created_at"
end
add_index "domain_status_versions", ["item_type", "item_id"], name: "index_domain_status_versions_on_item_type_and_item_id", using: :btree
create_table "domain_statuses", force: :cascade do |t|
t.integer "domain_id"
t.string "description", limit: 255
t.string "value", limit: 255
t.string "description"
t.string "value"
t.string "creator_str"
t.string "updator_str"
end
create_table "domain_transfers", force: :cascade do |t|
t.integer "domain_id"
t.string "status", limit: 255
t.string "status"
t.datetime "transfer_requested_at"
t.datetime "transferred_at"
t.integer "transfer_from_id"
@ -189,39 +192,38 @@ ActiveRecord::Schema.define(version: 20150202084444) do
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "wait_until"
t.string "creator_str"
t.string "updator_str"
end
create_table "domain_versions", force: :cascade do |t|
t.string "item_type", limit: 255, null: false
t.integer "item_id", null: false
t.string "event", limit: 255, null: false
t.string "whodunnit", limit: 255
t.text "object"
t.datetime "created_at"
t.text "snapshot"
end
add_index "domain_versions", ["item_type", "item_id"], name: "index_domain_versions_on_item_type_and_item_id", using: :btree
create_table "domains", force: :cascade do |t|
t.string "name", limit: 255
t.string "name"
t.integer "registrar_id"
t.datetime "registered_at"
<<<<<<< HEAD
=======
t.string "status"
>>>>>>> c010000bfec582db543f6a89f263e92b7611c7ef
t.datetime "valid_from"
t.datetime "valid_to"
t.integer "owner_contact_id"
t.string "auth_info", limit: 255
t.string "auth_info"
t.datetime "created_at"
t.datetime "updated_at"
t.string "name_dirty", limit: 255
t.string "name_puny", limit: 255
t.string "name_dirty"
t.string "name_puny"
t.integer "period"
t.string "period_unit", limit: 1
<<<<<<< HEAD
t.string "status"
=======
t.string "creator_str"
t.string "updator_str"
>>>>>>> c010000bfec582db543f6a89f263e92b7611c7ef
end
create_table "epp_sessions", force: :cascade do |t|
t.string "session_id", limit: 255
t.string "session_id"
t.text "data"
t.datetime "created_at"
t.datetime "updated_at"
@ -233,67 +235,369 @@ ActiveRecord::Schema.define(version: 20150202084444) do
create_table "keyrelays", force: :cascade do |t|
t.integer "domain_id"
t.datetime "pa_date"
t.string "key_data_flags", limit: 255
t.string "key_data_protocol", limit: 255
t.string "key_data_alg", limit: 255
t.string "key_data_flags"
t.string "key_data_protocol"
t.string "key_data_alg"
t.text "key_data_public_key"
t.string "auth_info_pw", limit: 255
t.string "expiry_relative", limit: 255
t.string "auth_info_pw"
t.string "expiry_relative"
t.datetime "expiry_absolute"
t.integer "requester_id"
t.integer "accepter_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "creator_str"
t.string "updator_str"
end
create_table "legal_documents", force: :cascade do |t|
t.string "document_type", limit: 255
t.string "document_type"
t.text "body"
t.integer "documentable_id"
t.string "documentable_type", limit: 255
t.string "documentable_type"
t.datetime "created_at"
t.datetime "updated_at"
t.string "creator_str"
t.string "updator_str"
end
create_table "log_addresses", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_addresses", ["item_type", "item_id"], name: "index_log_addresses_on_item_type_and_item_id", using: :btree
add_index "log_addresses", ["whodunnit"], name: "index_log_addresses_on_whodunnit", using: :btree
create_table "log_api_users", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_api_users", ["item_type", "item_id"], name: "index_log_api_users_on_item_type_and_item_id", using: :btree
add_index "log_api_users", ["whodunnit"], name: "index_log_api_users_on_whodunnit", using: :btree
create_table "log_contact_disclosures", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_contact_disclosures", ["item_type", "item_id"], name: "index_log_contact_disclosures_on_item_type_and_item_id", using: :btree
add_index "log_contact_disclosures", ["whodunnit"], name: "index_log_contact_disclosures_on_whodunnit", using: :btree
create_table "log_contact_statuses", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_contact_statuses", ["item_type", "item_id"], name: "index_log_contact_statuses_on_item_type_and_item_id", using: :btree
add_index "log_contact_statuses", ["whodunnit"], name: "index_log_contact_statuses_on_whodunnit", using: :btree
create_table "log_contacts", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_contacts", ["item_type", "item_id"], name: "index_log_contacts_on_item_type_and_item_id", using: :btree
add_index "log_contacts", ["whodunnit"], name: "index_log_contacts_on_whodunnit", using: :btree
create_table "log_countries", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_countries", ["item_type", "item_id"], name: "index_log_countries_on_item_type_and_item_id", using: :btree
add_index "log_countries", ["whodunnit"], name: "index_log_countries_on_whodunnit", using: :btree
create_table "log_dnskeys", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_dnskeys", ["item_type", "item_id"], name: "index_log_dnskeys_on_item_type_and_item_id", using: :btree
add_index "log_dnskeys", ["whodunnit"], name: "index_log_dnskeys_on_whodunnit", using: :btree
create_table "log_domain_contacts", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_domain_contacts", ["item_type", "item_id"], name: "index_log_domain_contacts_on_item_type_and_item_id", using: :btree
add_index "log_domain_contacts", ["whodunnit"], name: "index_log_domain_contacts_on_whodunnit", using: :btree
create_table "log_domain_statuses", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_domain_statuses", ["item_type", "item_id"], name: "index_log_domain_statuses_on_item_type_and_item_id", using: :btree
add_index "log_domain_statuses", ["whodunnit"], name: "index_log_domain_statuses_on_whodunnit", using: :btree
create_table "log_domain_transfers", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_domain_transfers", ["item_type", "item_id"], name: "index_log_domain_transfers_on_item_type_and_item_id", using: :btree
add_index "log_domain_transfers", ["whodunnit"], name: "index_log_domain_transfers_on_whodunnit", using: :btree
create_table "log_domains", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.text "nameserver_ids", default: [], array: true
t.text "tech_contact_ids", default: [], array: true
t.text "admin_contact_ids", default: [], array: true
t.string "session"
t.json "children"
end
add_index "log_domains", ["item_type", "item_id"], name: "index_log_domains_on_item_type_and_item_id", using: :btree
add_index "log_domains", ["whodunnit"], name: "index_log_domains_on_whodunnit", using: :btree
create_table "log_keyrelays", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_keyrelays", ["item_type", "item_id"], name: "index_log_keyrelays_on_item_type_and_item_id", using: :btree
add_index "log_keyrelays", ["whodunnit"], name: "index_log_keyrelays_on_whodunnit", using: :btree
create_table "log_legal_documents", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_legal_documents", ["item_type", "item_id"], name: "index_log_legal_documents_on_item_type_and_item_id", using: :btree
add_index "log_legal_documents", ["whodunnit"], name: "index_log_legal_documents_on_whodunnit", using: :btree
create_table "log_messages", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_messages", ["item_type", "item_id"], name: "index_log_messages_on_item_type_and_item_id", using: :btree
add_index "log_messages", ["whodunnit"], name: "index_log_messages_on_whodunnit", using: :btree
create_table "log_nameservers", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_nameservers", ["item_type", "item_id"], name: "index_log_nameservers_on_item_type_and_item_id", using: :btree
add_index "log_nameservers", ["whodunnit"], name: "index_log_nameservers_on_whodunnit", using: :btree
create_table "log_registrars", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_registrars", ["item_type", "item_id"], name: "index_log_registrars_on_item_type_and_item_id", using: :btree
add_index "log_registrars", ["whodunnit"], name: "index_log_registrars_on_whodunnit", using: :btree
create_table "log_reserved_domains", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_reserved_domains", ["item_type", "item_id"], name: "index_log_reserved_domains_on_item_type_and_item_id", using: :btree
add_index "log_reserved_domains", ["whodunnit"], name: "index_log_reserved_domains_on_whodunnit", using: :btree
create_table "log_settings", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_settings", ["item_type", "item_id"], name: "index_log_settings_on_item_type_and_item_id", using: :btree
add_index "log_settings", ["whodunnit"], name: "index_log_settings_on_whodunnit", using: :btree
create_table "log_users", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_users", ["item_type", "item_id"], name: "index_log_users_on_item_type_and_item_id", using: :btree
add_index "log_users", ["whodunnit"], name: "index_log_users_on_whodunnit", using: :btree
create_table "log_zonefile_settings", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
end
add_index "log_zonefile_settings", ["item_type", "item_id"], name: "index_log_zonefile_settings_on_item_type_and_item_id", using: :btree
add_index "log_zonefile_settings", ["whodunnit"], name: "index_log_zonefile_settings_on_whodunnit", using: :btree
create_table "messages", force: :cascade do |t|
t.integer "registrar_id"
t.string "body", limit: 255
t.string "attached_obj_type", limit: 255
t.string "attached_obj_id", limit: 255
t.string "body"
t.string "attached_obj_type"
t.string "attached_obj_id"
t.boolean "queued"
t.datetime "created_at"
t.datetime "updated_at"
t.string "creator_str"
t.string "updator_str"
end
create_table "nameserver_versions", force: :cascade do |t|
t.string "item_type", limit: 255, null: false
t.integer "item_id", null: false
t.string "event", limit: 255, null: false
t.string "whodunnit", limit: 255
t.text "object"
t.datetime "created_at"
end
add_index "nameserver_versions", ["item_type", "item_id"], name: "index_nameserver_versions_on_item_type_and_item_id", using: :btree
create_table "nameservers", force: :cascade do |t|
t.string "hostname", limit: 255
t.string "ipv4", limit: 255
t.string "hostname"
t.string "ipv4"
t.datetime "created_at"
t.datetime "updated_at"
t.string "ipv6", limit: 255
t.string "ipv6"
t.integer "domain_id"
t.string "creator_str"
t.string "updator_str"
end
create_table "registrars", force: :cascade do |t|
t.string "name", limit: 255
t.string "reg_no", limit: 255
t.string "vat_no", limit: 255
t.string "address", limit: 255
t.string "name"
t.string "reg_no"
t.string "vat_no"
t.string "address"
t.integer "country_id"
t.string "billing_address", limit: 255
t.string "billing_address"
t.datetime "created_at"
t.datetime "updated_at"
t.string "creator_str"
t.string "updator_str"
t.string "phone"
t.string "email"
t.string "billing_email"
@ -301,35 +605,40 @@ ActiveRecord::Schema.define(version: 20150202084444) do
end
create_table "reserved_domains", force: :cascade do |t|
t.string "name", limit: 255
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.string "creator_str"
t.string "updator_str"
end
create_table "settings", force: :cascade do |t|
t.string "var", limit: 255, null: false
t.string "var", null: false
t.text "value"
t.integer "thing_id"
t.string "thing_type", limit: 30
t.string "thing_type", limit: 30
t.datetime "created_at"
t.datetime "updated_at"
t.string "creator_str"
t.string "updator_str"
end
add_index "settings", ["thing_type", "thing_id", "var"], name: "index_settings_on_thing_type_and_thing_id_and_var", unique: true, using: :btree
create_table "users", force: :cascade do |t|
t.string "username", limit: 255
t.string "password", limit: 255
t.string "username"
t.string "password"
t.datetime "created_at"
t.datetime "updated_at"
t.string "email", limit: 255
t.integer "sign_in_count", default: 0, null: false
t.string "email"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.inet "current_sign_in_ip"
t.inet "last_sign_in_ip"
t.string "identity_code", limit: 255
t.string "identity_code"
t.integer "country_id"
<<<<<<< HEAD
t.string "roles", array: true
t.string "country_code"
end
@ -338,35 +647,30 @@ ActiveRecord::Schema.define(version: 20150202084444) do
t.integer "version_id"
t.string "foreign_key_name", null: false
t.integer "foreign_key_id"
=======
t.string "roles", array: true
t.string "creator_str"
t.string "updator_str"
>>>>>>> c010000bfec582db543f6a89f263e92b7611c7ef
end
add_index "version_associations", ["foreign_key_name", "foreign_key_id"], name: "index_version_associations_on_foreign_key", using: :btree
add_index "version_associations", ["version_id"], name: "index_version_associations_on_version_id", using: :btree
create_table "versions", force: :cascade do |t|
t.string "item_type", limit: 255, null: false
t.integer "item_id", null: false
t.string "event", limit: 255, null: false
t.string "whodunnit", limit: 255
t.text "object"
t.datetime "created_at"
t.integer "transaction_id"
t.text "depricated_table_but_somehow_paper_trail_tests_fails_without_it"
end
add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree
add_index "versions", ["transaction_id"], name: "index_versions_on_transaction_id", using: :btree
create_table "zonefile_settings", force: :cascade do |t|
t.string "origin", limit: 255
t.string "origin"
t.integer "ttl"
t.integer "refresh"
t.integer "retry"
t.integer "expire"
t.integer "minimum_ttl"
t.string "email", limit: 255
t.string "master_nameserver", limit: 255
t.string "email"
t.string "master_nameserver"
t.datetime "created_at"
t.datetime "updated_at"
t.string "creator_str"
t.string "updator_str"
end
end

View file

@ -1,11 +1,5 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
Country.where(name: 'Estonia', iso: 'EE').first_or_create!
Country.where(name: 'Latvia', iso: 'LV').first_or_create!
@ -13,29 +7,31 @@ registrar1 = Registrar.where(
name: 'Registrar First AS',
reg_no: '10300220',
address: 'Pärnu mnt 2, Tallinna linn, Harju maakond, 11415',
email: 'registrar1@example.com',
country: Country.first
).first_or_create
).first_or_create!
ApiUser.where(
username: 'registrar1',
password: 'test1',
active: true,
registrar: registrar1
).first_or_create
).first_or_create!
registrar2 = Registrar.where(
name: 'Registrar Second AS',
reg_no: '10529229',
address: 'Vabaduse pst 32, 11316 Tallinn',
email: 'registrar2@example.com',
country: Country.first
).first_or_create
).first_or_create!
ApiUser.where(
username: 'registrar2',
password: 'test2',
active: true,
registrar: registrar2
).first_or_create
).first_or_create!
User.where(
username: 'user1',
@ -43,7 +39,7 @@ User.where(
email: 'user1@example.ee',
identity_code: '37810013855',
country: Country.where(name: 'Estonia').first
).first_or_create
).first_or_create!
User.where(
username: 'user2',
@ -51,7 +47,7 @@ User.where(
email: 'user2@example.ee',
identity_code: '37810010085',
country: Country.where(name: 'Estonia').first
).first_or_create
).first_or_create!
User.where(
username: 'user3',
@ -59,7 +55,6 @@ User.where(
email: 'user3@example.ee',
identity_code: '37810010727',
country: Country.where(name: 'Estonia').first
).first_or_create
).first_or_create!
User.update_all(roles: ['admin'])
# Setting.whois_enabled = true only uncomment this if you wish whois

24
lib/epp_constraint.rb Normal file
View file

@ -0,0 +1,24 @@
class EppConstraint
OBJECT_TYPES = {
domain: { domain: 'urn:ietf:params:xml:ns:domain-1.0' },
contact: { contact: 'urn:ietf:params:xml:ns:contact-1.0' }
}
def initialize(type)
@type = type
end
# creates parsed_frame, detects epp request object
def matches?(request)
parsed_frame = Nokogiri::XML(request.params[:raw_frame])
unless [:keyrelay, :poll].include?(@type)
element = "//#{@type}:#{request.params[:action]}"
return false if parsed_frame.xpath("#{element}", OBJECT_TYPES[@type]).none?
end
request.params[:parsed_frame] = parsed_frame.remove_namespaces!
request.params[:epp_object_type] = @type
true
end
end

View file

@ -0,0 +1 @@
Will generate custom PaperTrail version model

View file

@ -0,0 +1,4 @@
class <%= class_name %>Version < PaperTrail::Version
self.table_name = :log_<%= file_name.tableize %>
self.sequence_name = :log_<%= file_name.tableize %>_id_seq
end

View file

@ -0,0 +1,11 @@
class VersionGenerator < Rails::Generators::NamedBase
source_root File.expand_path("../templates", __FILE__)
def create_version_file
template "version.rb.erb", "app/models/version/#{file_name}_version.rb"
end
def class_name
file_name.camelize
end
end

View file

@ -68,8 +68,8 @@ describe 'EPP Contact', epp: true do
@contact = Contact.last
@contact.registrar.should == registrar1
registrar1.api_users.should include(@contact.created_by)
@contact.updated_by_id.should == nil
# registrar1.api_users.should include(@contact.created_by)
# @contact.updated_by_id.should == nil
@contact.ident.should == '37605030299'
@contact.address.street.should == '123 Example'
@ -77,7 +77,7 @@ describe 'EPP Contact', epp: true do
log.request_command.should == 'create'
log.request_object.should == 'contact'
log.request_successful.should == true
log.api_user_name.should == 'gitlab'
log.api_user_name.should == '1-api-gitlab'
log.api_user_registrar.should == 'Registrar OÜ'
end
@ -156,7 +156,7 @@ describe 'EPP Contact', epp: true do
@contact =
Fabricate(
:contact,
created_by_id: 1,
# created_by_id: 1,
registrar: registrar1,
email: 'not_updated@test.test',
code: 'sh8013',
@ -216,7 +216,7 @@ describe 'EPP Contact', epp: true do
code: 'sh8013disclosure',
auth_info: '2fooBAR',
registrar: registrar1,
created_by_id: ApiUser.first.id,
# created_by_id: ApiUser.first.id,
disclosure: Fabricate(:contact_disclosure, phone: true, email: true))
xml = {
@ -245,7 +245,8 @@ describe 'EPP Contact', epp: true do
it 'deletes contact' do
@contact_deleted =
Fabricate(:contact, code: 'dwa1234', created_by_id: ApiUser.first.id, registrar: registrar1)
# Fabricate(:contact, code: 'dwa1234', created_by_id: ApiUser.first.id, registrar: registrar1)
Fabricate(:contact, code: 'dwa1234', registrar: registrar1)
response = epp_plain_request(delete_contact_xml({ id: { value: 'dwa1234' } }), :xml)
response[:msg].should == 'Command completed successfully'
@ -268,7 +269,7 @@ describe 'EPP Contact', epp: true do
owner_contact: Fabricate(
:contact,
code: 'dwa1234',
created_by_id: registrar1.id,
# created_by_id: registrar1.id,
registrar: registrar1)
)
Domain.last.owner_contact.address.present?.should == true

View file

@ -55,7 +55,7 @@ describe 'EPP Domain', epp: true do
log.request_command.should == 'create'
log.request_object.should == 'domain'
log.request_successful.should == false
log.api_user_name.should == 'registrar1'
log.api_user_name.should == '1-api-registrar1'
log.api_user_registrar.should == 'Registrar OÜ'
log.request.should_not be_blank
log.response.should_not be_blank
@ -819,7 +819,7 @@ describe 'EPP Domain', epp: true do
log.request_command.should == 'transfer'
log.request_object.should == 'domain'
log.request_successful.should == true
log.api_user_name.should == 'registrar2'
log.api_user_name.should == '2-api-registrar2'
log.api_user_registrar.should == 'registrar2'
log.request.should_not be_blank
log.response.should_not be_blank

View file

@ -33,7 +33,7 @@ describe 'EPP Poll', epp: true do
log.request_command.should == 'poll'
log.request_object.should == 'poll'
log.request_successful.should == true
log.api_user_name.should == 'registrar1'
log.api_user_name.should == '1-api-registrar1'
log.api_user_registrar.should == 'Registrar OÜ'
log.request.should_not be_blank
log.response.should_not be_blank

View file

@ -66,7 +66,7 @@ describe 'EPP Session', epp: true do
log = ApiLog::EppLog.last
log.request_command.should == 'login'
log.request_successful.should == false
log.api_user_name.should == 'gitlab'
log.api_user_name.should == '1-api-gitlab'
log.api_user_registrar.should == 'Registrar OÜ'
end

View file

@ -1,4 +1,4 @@
Fabricator(:epp_session) do
session_id 'test'
data { { epp_user_id: 1 } }
data { { api_user_id: 1 } }
end

View file

@ -3,10 +3,55 @@ require 'rails_helper'
describe Address do
it { should belong_to(:contact) }
it { should belong_to(:country) }
context 'about class' do
it 'should have versioning enabled?' do
Address.paper_trail_enabled_for_model?.should == true
end
it 'should have custom log prexied table name for versions table' do
AddressVersion.table_name.should == 'log_addresses'
end
end
context 'with invalid attribute' do
before :all do
@address = Address.new
end
it 'should not be valid' do
@address.valid?
@address.errors.full_messages.should match_array([
])
end
it 'should not have any versions' do
@address.versions.should == []
end
end
context 'with valid attributes' do
before :all do
@address = Fabricate(:address)
end
it 'should be valid' do
@address.valid?
@address.errors.full_messages.should match_array([])
end
it 'should not have one version' do
with_versioning do
@address.versions.should == []
@address.zip = 'New zip'
@address.save
@address.versions.size.should == 1
end
end
end
end
describe Address, '.extract_params' do
it 'returns params hash' do
Fabricate(:country, iso: 'EE')
ph = { postalInfo: { name: 'fred', addr: { cc: 'EE', city: 'Village', street: 'street1' } } }

View file

@ -2,6 +2,54 @@ require 'rails_helper'
describe ContactDisclosure do
it { should belong_to(:contact) }
context 'about class' do
it 'should have versioning enabled?' do
Country.paper_trail_enabled_for_model?.should == true
end
it 'should have custom log prexied table name for versions table' do
CountryVersion.table_name.should == 'log_countries'
end
end
context 'with invalid attribute' do
before :all do
@contact_disclosure = Country.new
end
it 'should not be valid' do
@contact_disclosure.valid?
@contact_disclosure.errors.full_messages.should match_array([
"Name is missing"
])
end
it 'should not have any versions' do
@contact_disclosure.versions.should == []
end
end
context 'with valid attributes' do
before :all do
@contact_disclosure = Fabricate(:contact_disclosure)
end
it 'should be valid' do
@contact_disclosure.valid?
@contact_disclosure.errors.full_messages.should match_array([])
end
it 'should not have one version' do
with_versioning do
@contact_disclosure.versions.should == []
@contact_disclosure.name = false
@contact_disclosure.save
@contact_disclosure.versions.size.should == 1
end
end
end
end
describe '.extract_attributes' do

View file

@ -8,6 +8,16 @@ describe Contact do
it { should have_one(:address) }
context 'about class' do
it 'should have versioning enabled?' do
Contact.paper_trail_enabled_for_model?.should == true
end
it 'should have custom log prexied table name for versions table' do
ContactVersion.table_name.should == 'log_contacts'
end
end
context 'with invalid attribute' do
before :all do
@contact = Contact.new
@ -41,6 +51,10 @@ describe Contact do
@contact.valid?
@contact.errors[:phone].should == ["Phone nr is invalid"]
end
it 'should not have any versions' do
@contact.versions.should == []
end
end
context 'with valid attributes' do
@ -57,6 +71,15 @@ describe Contact do
@contact.relations_with_domain?.should == false
end
it 'should not have one version' do
with_versioning do
@contact.versions.should == []
@contact.name = 'New name'
@contact.save
@contact.versions.size.should == 1
end
end
# it 'ico should be valid' do
# @contact.ident_type = 'ico'
# @contact.ident = '1234'
@ -150,23 +173,23 @@ describe Contact do
context 'with creator' do
before :all do
@contact.created_by = @api_user
# @contact.created_by = @api_user
end
# TODO: change cr_id to something else
it 'should return username of creator' do
@contact.cr_id.should == 'gitlab'
# @contact.cr_id.should == 'gitlab'
end
end
context 'with updater' do
before :all do
@contact.updated_by = @api_user
# @contact.updated_by = @api_user
end
# TODO: change up_id to something else
it 'should return username of updater' do
@contact.up_id.should == 'gitlab'
# @contact.up_id.should == 'gitlab'
end
end

View file

@ -0,0 +1,81 @@
require 'rails_helper'
describe Country do
context 'about class' do
it 'should have versioning enabled?' do
Country.paper_trail_enabled_for_model?.should == true
end
it 'should have custom log prexied table name for versions table' do
CountryVersion.table_name.should == 'log_countries'
end
end
context 'with invalid attribute' do
before :all do
@country = Country.new
end
it 'should not be valid' do
@country.valid?
@country.errors.full_messages.should match_array([
"Name is missing"
])
end
it 'should not have any versions' do
@country.versions.should == []
end
it 'should not have any creator' do
@country.creator_str.should == nil
end
it 'should not have any updater' do
@country.updator_str.should == nil
end
end
context 'with valid attributes' do
before :all do
@country = Fabricate(:country)
end
it 'should be valid' do
@country.valid?
@country.errors.full_messages.should match_array([])
end
it 'should not have a version' do
with_versioning do
@country.versions.should == []
@country.name = 'New name'
@country.save
@country.versions.size.should == 1
end
end
it 'should have creator' do
PaperTrail.whodunnit = 'test-user'
with_versioning do
@country = Fabricate(:country)
@country.name = 'Updated name'
@country.save
@country.creator_str.should == 'test-user'
@country.updator_str.should == 'test-user'
end
end
it 'should have creator' do
PaperTrail.whodunnit = 'test-user-2'
with_versioning do
@country.name = 'Updated name'
@country.save
@country.updator_str.should == 'test-user-2'
@country.creator_str.should == nil # Factory does not have it
end
end
end
end

View file

@ -1,192 +1,193 @@
require 'rails_helper'
describe DomainVersion do
with_versioning do
before(:each) do
Setting.ns_min_count = 1
Fabricate(:domain, name: 'version.ee', dnskeys: [], domain_contacts: []) do
owner_contact { Fabricate(:contact, name: 'owner_contact', code: 'asd', email: 'owner1@v.ee') }
nameservers(count: 1) { Fabricate(:nameserver, hostname: 'ns.test.ee', ipv4: nil) }
admin_contacts(count: 1) { Fabricate(:contact, name: 'admin_contact 1', code: 'qwe', email: 'admin1@v.ee') }
tech_contacts(count: 1) { Fabricate(:contact, name: 'tech_contact 1', code: 'zxc', email: 'tech1@v.ee') }
end
end
# TODO: update to new stac
# with_versioning do
# before(:each) do
# Setting.ns_min_count = 1
# Fabricate(:domain, name: 'version.ee', dnskeys: [], domain_contacts: []) do
# owner_contact { Fabricate(:contact, name: 'owner_contact', code: 'asd', email: 'owner1@v.ee') }
# nameservers(count: 1) { Fabricate(:nameserver, hostname: 'ns.test.ee', ipv4: nil) }
# admin_contacts(count: 1) { Fabricate(:contact, name: 'admin_contact 1', code: 'qwe', email: 'admin1@v.ee') }
# tech_contacts(count: 1) { Fabricate(:contact, name: 'tech_contact 1', code: 'zxc', email: 'tech1@v.ee') }
# end
# end
context 'when domain is created' do
it('creates a domain version') { expect(DomainVersion.count).to eq(1) }
it('has a snapshot') { expect(DomainVersion.first.snapshot).not_to be_empty }
# context 'when domain is created' do
# it('creates a domain version') { expect(DomainVersion.count).to eq(1) }
# it('has a snapshot') { expect(DomainVersion.first.snapshot).not_to be_empty }
it('has a snapshot with admin_contacts') do
expect(DomainVersion.last.load_snapshot[:admin_contacts].first).to include(
name: 'admin_contact 1', phone: '+372.12345678', ident: '37605030299', email: 'admin1@v.ee'
)
end
# it('has a snapshot with admin_contacts') do
# expect(DomainVersion.last.load_snapshot[:admin_contacts].first).to include(
# name: 'admin_contact 1', phone: '+372.12345678', ident: '37605030299', email: 'admin1@v.ee'
# )
# end
it('has a snapshot with domain') do
expect(DomainVersion.last.load_snapshot[:domain]).to include(
name: 'version.ee', status: nil
)
end
# it('has a snapshot with domain') do
# expect(DomainVersion.last.load_snapshot[:domain]).to include(
# name: 'version.ee', status: nil
# )
# end
it('has a snapshot with nameservers') do
expect(DomainVersion.last.load_snapshot[:nameservers]).to include(
hostname: 'ns.test.ee', ipv4: nil, ipv6: nil
)
end
# it('has a snapshot with nameservers') do
# expect(DomainVersion.last.load_snapshot[:nameservers]).to include(
# hostname: 'ns.test.ee', ipv4: nil, ipv6: nil
# )
# end
it('has a snapshot with owner contact') do
expect(DomainVersion.last.load_snapshot[:owner_contact]).to include(
name: 'owner_contact', phone: '+372.12345678', ident: '37605030299', email: 'owner1@v.ee'
)
end
# it('has a snapshot with owner contact') do
# expect(DomainVersion.last.load_snapshot[:owner_contact]).to include(
# name: 'owner_contact', phone: '+372.12345678', ident: '37605030299', email: 'owner1@v.ee'
# )
# end
it('has a snapshot with tech contacts') do
expect(DomainVersion.last.load_snapshot[:tech_contacts].first).to include(
name: 'tech_contact 1', phone: '+372.12345678', ident: '37605030299', email: 'tech1@v.ee'
)
end
end
# it('has a snapshot with tech contacts') do
# expect(DomainVersion.last.load_snapshot[:tech_contacts].first).to include(
# name: 'tech_contact 1', phone: '+372.12345678', ident: '37605030299', email: 'tech1@v.ee'
# )
# end
# end
context 'when domain is deleted' do
it 'creates a version' do
expect(DomainVersion.count).to eq(1)
Domain.first.destroy
expect(DomainVersion.count).to eq(2)
expect(DomainVersion.last.load_snapshot).to include({
admin_contacts: [],
# domain: { name: 'version.ee', status: nil },
nameservers: [],
tech_contacts: []
})
expect(DomainVersion.last.load_snapshot[:owner_contact]).to include(
{ name: 'owner_contact', phone: '+372.12345678', ident: '37605030299', email: 'owner1@v.ee' }
)
end
end
# context 'when domain is deleted' do
# it 'creates a version' do
# expect(DomainVersion.count).to eq(1)
# Domain.first.destroy
# expect(DomainVersion.count).to eq(2)
# expect(DomainVersion.last.load_snapshot).to include({
# admin_contacts: [],
# # domain: { name: 'version.ee', status: nil },
# nameservers: [],
# tech_contacts: []
# })
# expect(DomainVersion.last.load_snapshot[:owner_contact]).to include(
# { name: 'owner_contact', phone: '+372.12345678', ident: '37605030299', email: 'owner1@v.ee' }
# )
# end
# end
context 'when adding child' do
it 'contact creates a version' do
expect(DomainVersion.count).to eq(1)
expect(Domain.last.tech_contacts.count).to eq(1)
Domain.last.tech_contacts << Fabricate(:contact, name: 'tech contact 2', phone: '+371.12345678',
code: '123', email: 'tech2@v.ee')
expect(Domain.last.tech_contacts.count).to eq(2)
expect(DomainVersion.count).to eq(2)
end
# context 'when adding child' do
# it 'contact creates a version' do
# expect(DomainVersion.count).to eq(1)
# expect(Domain.last.tech_contacts.count).to eq(1)
# Domain.last.tech_contacts << Fabricate(:contact, name: 'tech contact 2', phone: '+371.12345678',
# code: '123', email: 'tech2@v.ee')
# expect(Domain.last.tech_contacts.count).to eq(2)
# expect(DomainVersion.count).to eq(2)
# end
it 'nameserver creates a version' do
expect(DomainVersion.count).to eq(1)
expect(Domain.last.nameservers.count).to eq(1)
Domain.last.nameservers << Fabricate(:nameserver, hostname: 'ns.server.ee', created_at: Time.now - 20)
expect(DomainVersion.count).to eq(2)
end
end
# it 'nameserver creates a version' do
# expect(DomainVersion.count).to eq(1)
# expect(Domain.last.nameservers.count).to eq(1)
# Domain.last.nameservers << Fabricate(:nameserver, hostname: 'ns.server.ee', created_at: Time.now - 20)
# expect(DomainVersion.count).to eq(2)
# end
# end
context 'when removing child' do
it('has one domain version before events') { expect(DomainVersion.count).to eq(1) }
# context 'when removing child' do
# it('has one domain version before events') { expect(DomainVersion.count).to eq(1) }
it 'contact creates a version' do
expect(DomainVersion.count).to eq(1)
DomainContact.last.destroy
expect(Domain.last.valid?).to be(true)
expect(DomainVersion.count).to eq(2)
end
# it 'contact creates a version' do
# expect(DomainVersion.count).to eq(1)
# DomainContact.last.destroy
# expect(Domain.last.valid?).to be(true)
# expect(DomainVersion.count).to eq(2)
# end
end
# end
context 'when deleting child' do
it 'contact creates a version' do
expect(DomainVersion.count).to eq(1)
Contact.find_by(name: 'tech_contact 1').destroy
expect(DomainVersion.count).to eq(2)
expect(DomainVersion.last.load_snapshot[:admin_contacts].size).to eq(1)
expect(DomainVersion.last.load_snapshot[:admin_contacts].first).to include(
name: 'admin_contact 1', phone: '+372.12345678', ident: '37605030299', email: 'admin1@v.ee'
)
# context 'when deleting child' do
# it 'contact creates a version' do
# expect(DomainVersion.count).to eq(1)
# Contact.find_by(name: 'tech_contact 1').destroy
# expect(DomainVersion.count).to eq(2)
# expect(DomainVersion.last.load_snapshot[:admin_contacts].size).to eq(1)
# expect(DomainVersion.last.load_snapshot[:admin_contacts].first).to include(
# name: 'admin_contact 1', phone: '+372.12345678', ident: '37605030299', email: 'admin1@v.ee'
# )
expect(DomainVersion.last.load_snapshot[:domain][:name]).to eq('version.ee')
expect(DomainVersion.last.load_snapshot[:domain][:status]).to eq(nil)
expect(DomainVersion.last.load_snapshot[:domain][:period]).to eq(1)
expect(DomainVersion.last.load_snapshot[:domain][:period_unit]).to eq('y')
expect(DomainVersion.last.load_snapshot[:domain][:valid_from]).to eq(Time.now.utc.beginning_of_day)
expect(DomainVersion.last.load_snapshot[:domain][:valid_to]).to eq(Time.now.utc.beginning_of_day + 1.year)
expect(DomainVersion.last.load_snapshot[:domain][:period]).to eq(1)
# expect(DomainVersion.last.load_snapshot[:domain][:name]).to eq('version.ee')
# expect(DomainVersion.last.load_snapshot[:domain][:status]).to eq(nil)
# expect(DomainVersion.last.load_snapshot[:domain][:period]).to eq(1)
# expect(DomainVersion.last.load_snapshot[:domain][:period_unit]).to eq('y')
# expect(DomainVersion.last.load_snapshot[:domain][:valid_from]).to eq(Time.now.utc.beginning_of_day)
# expect(DomainVersion.last.load_snapshot[:domain][:valid_to]).to eq(Time.now.utc.beginning_of_day + 1.year)
# expect(DomainVersion.last.load_snapshot[:domain][:period]).to eq(1)
expect(DomainVersion.last.load_snapshot[:nameservers].size).to eq(1)
expect(DomainVersion.last.load_snapshot[:nameservers].first).to include(
hostname: 'ns.test.ee', ipv4: nil, ipv6: nil
)
expect(DomainVersion.last.load_snapshot[:owner_contact]).to include(
{ name: 'owner_contact', phone: '+372.12345678', ident: '37605030299', email: 'owner1@v.ee' }
)
expect(DomainVersion.last.load_snapshot[:tech_contacts]).to eq([])
end
# expect(DomainVersion.last.load_snapshot[:nameservers].size).to eq(1)
# expect(DomainVersion.last.load_snapshot[:nameservers].first).to include(
# hostname: 'ns.test.ee', ipv4: nil, ipv6: nil
# )
# expect(DomainVersion.last.load_snapshot[:owner_contact]).to include(
# { name: 'owner_contact', phone: '+372.12345678', ident: '37605030299', email: 'owner1@v.ee' }
# )
# expect(DomainVersion.last.load_snapshot[:tech_contacts]).to eq([])
# end
it 'nameserver creates a version' do
Domain.last.nameservers << Fabricate(:nameserver, created_at: Time.now - 30)
Domain.last.nameservers.last.destroy
expect(DomainVersion.count).to eq(3)
expect(Domain.last.nameservers.count).to eq(1)
# it 'nameserver creates a version' do
# Domain.last.nameservers << Fabricate(:nameserver, created_at: Time.now - 30)
# Domain.last.nameservers.last.destroy
# expect(DomainVersion.count).to eq(3)
# expect(Domain.last.nameservers.count).to eq(1)
expect(DomainVersion.last.load_snapshot[:admin_contacts].size).to eq(1)
expect(DomainVersion.last.load_snapshot[:admin_contacts].first).to include(
name: 'admin_contact 1', phone: '+372.12345678', ident: '37605030299', email: 'admin1@v.ee'
)
expect(DomainVersion.last.load_snapshot[:domain][:name]).to eq('version.ee')
expect(DomainVersion.last.load_snapshot[:domain][:status]).to eq(nil)
expect(DomainVersion.last.load_snapshot[:domain][:period]).to eq(1)
expect(DomainVersion.last.load_snapshot[:domain][:period_unit]).to eq('y')
# expect(DomainVersion.last.load_snapshot[:admin_contacts].size).to eq(1)
# expect(DomainVersion.last.load_snapshot[:admin_contacts].first).to include(
# name: 'admin_contact 1', phone: '+372.12345678', ident: '37605030299', email: 'admin1@v.ee'
# )
# expect(DomainVersion.last.load_snapshot[:domain][:name]).to eq('version.ee')
# expect(DomainVersion.last.load_snapshot[:domain][:status]).to eq(nil)
# expect(DomainVersion.last.load_snapshot[:domain][:period]).to eq(1)
# expect(DomainVersion.last.load_snapshot[:domain][:period_unit]).to eq('y')
expect(DomainVersion.last.load_snapshot[:nameservers].size).to eq(1)
expect(DomainVersion.last.load_snapshot[:nameservers].first).to include(
hostname: 'ns.test.ee', ipv4: nil, ipv6: nil
)
expect(DomainVersion.last.load_snapshot[:owner_contact]).to include(
{ name: 'owner_contact', phone: '+372.12345678', ident: '37605030299', email: 'owner1@v.ee' }
)
expect(DomainVersion.last.load_snapshot[:tech_contacts].size).to eq(1)
expect(DomainVersion.last.load_snapshot[:tech_contacts].first).to include(
name: 'tech_contact 1', phone: '+372.12345678', ident: '37605030299', email: 'tech1@v.ee'
)
end
end
# expect(DomainVersion.last.load_snapshot[:nameservers].size).to eq(1)
# expect(DomainVersion.last.load_snapshot[:nameservers].first).to include(
# hostname: 'ns.test.ee', ipv4: nil, ipv6: nil
# )
# expect(DomainVersion.last.load_snapshot[:owner_contact]).to include(
# { name: 'owner_contact', phone: '+372.12345678', ident: '37605030299', email: 'owner1@v.ee' }
# )
# expect(DomainVersion.last.load_snapshot[:tech_contacts].size).to eq(1)
# expect(DomainVersion.last.load_snapshot[:tech_contacts].first).to include(
# name: 'tech_contact 1', phone: '+372.12345678', ident: '37605030299', email: 'tech1@v.ee'
# )
# end
# end
context 'when editing children' do
it 'creates a version' do
expect(DomainVersion.count).to eq(1)
Contact.find_by(name: 'owner_contact').update_attributes!(name: 'edited owner_contact')
expect(DomainVersion.count).to eq(2)
end
# context 'when editing children' do
# it 'creates a version' do
# expect(DomainVersion.count).to eq(1)
# Contact.find_by(name: 'owner_contact').update_attributes!(name: 'edited owner_contact')
# expect(DomainVersion.count).to eq(2)
# end
it 'creates 3 versions' do
expect(DomainVersion.count).to eq(1)
Contact.find_by(name: 'owner_contact').update_attributes!(name: 'edited owner_contact')
expect(DomainVersion.count).to eq(2)
Contact.find_by(name: 'tech_contact 1').update_attributes!(name: 'edited tech_contact')
expect(DomainVersion.count).to eq(3)
Contact.find_by(name: 'admin_contact 1').update_attributes!(name: 'edited admin_contact')
expect(DomainVersion.count).to eq(4)
expect(DomainVersion.last.load_snapshot[:admin_contacts].size).to eq(1)
expect(DomainVersion.last.load_snapshot[:admin_contacts].first).to include(
name: 'edited admin_contact', phone: '+372.12345678', ident: '37605030299', email: 'admin1@v.ee'
)
expect(DomainVersion.last.load_snapshot[:domain][:name]).to eq('version.ee')
expect(DomainVersion.last.load_snapshot[:domain][:status]).to eq(nil)
expect(DomainVersion.last.load_snapshot[:domain][:period]).to eq(1)
expect(DomainVersion.last.load_snapshot[:domain][:period_unit]).to eq('y')
# it 'creates 3 versions' do
# expect(DomainVersion.count).to eq(1)
# Contact.find_by(name: 'owner_contact').update_attributes!(name: 'edited owner_contact')
# expect(DomainVersion.count).to eq(2)
# Contact.find_by(name: 'tech_contact 1').update_attributes!(name: 'edited tech_contact')
# expect(DomainVersion.count).to eq(3)
# Contact.find_by(name: 'admin_contact 1').update_attributes!(name: 'edited admin_contact')
# expect(DomainVersion.count).to eq(4)
# expect(DomainVersion.last.load_snapshot[:admin_contacts].size).to eq(1)
# expect(DomainVersion.last.load_snapshot[:admin_contacts].first).to include(
# name: 'edited admin_contact', phone: '+372.12345678', ident: '37605030299', email: 'admin1@v.ee'
# )
# expect(DomainVersion.last.load_snapshot[:domain][:name]).to eq('version.ee')
# expect(DomainVersion.last.load_snapshot[:domain][:status]).to eq(nil)
# expect(DomainVersion.last.load_snapshot[:domain][:period]).to eq(1)
# expect(DomainVersion.last.load_snapshot[:domain][:period_unit]).to eq('y')
expect(DomainVersion.last.load_snapshot[:nameservers].size).to eq(1)
expect(DomainVersion.last.load_snapshot[:nameservers].first).to include(
hostname: 'ns.test.ee', ipv4: nil, ipv6: nil
)
expect(DomainVersion.last.load_snapshot[:owner_contact]).to include(
{ name: 'edited owner_contact', phone: '+372.12345678', ident: '37605030299', email: 'owner1@v.ee' }
)
expect(DomainVersion.last.load_snapshot[:tech_contacts].size).to eq(1)
expect(DomainVersion.last.load_snapshot[:tech_contacts].first).to include(
name: 'edited tech_contact', phone: '+372.12345678', ident: '37605030299', email: 'tech1@v.ee'
)
end
end
end
# expect(DomainVersion.last.load_snapshot[:nameservers].size).to eq(1)
# expect(DomainVersion.last.load_snapshot[:nameservers].first).to include(
# hostname: 'ns.test.ee', ipv4: nil, ipv6: nil
# )
# expect(DomainVersion.last.load_snapshot[:owner_contact]).to include(
# { name: 'edited owner_contact', phone: '+372.12345678', ident: '37605030299', email: 'owner1@v.ee' }
# )
# expect(DomainVersion.last.load_snapshot[:tech_contacts].size).to eq(1)
# expect(DomainVersion.last.load_snapshot[:tech_contacts].first).to include(
# name: 'edited tech_contact', phone: '+372.12345678', ident: '37605030299', email: 'tech1@v.ee'
# )
# end
# end
# end
end

View file

@ -6,6 +6,7 @@ require 'rspec/rails'
require 'shoulda/matchers'
require 'capybara/poltergeist'
require 'paper_trail/frameworks/rspec'
PaperTrail.whodunnit = 'autotest'
if ENV['ROBOT']
require 'simplecov'
@ -26,6 +27,9 @@ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
ActiveRecord::Migration.maintain_test_schema!
RSpec.configure do |config|
config.filter_run focus: true
config.run_all_when_everything_filtered = true
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.