mirror of
https://github.com/internetee/registry.git
synced 2025-08-12 20:49:36 +02:00
Always require contact.registrar
This commit is contained in:
parent
af53313608
commit
821fabd083
2 changed files with 14 additions and 4 deletions
|
@ -3,11 +3,11 @@ class Contact < ActiveRecord::Base
|
||||||
include EppErrors
|
include EppErrors
|
||||||
include UserEvents
|
include UserEvents
|
||||||
|
|
||||||
belongs_to :registrar
|
belongs_to :registrar, required: true
|
||||||
has_many :domain_contacts
|
has_many :domain_contacts
|
||||||
has_many :domains, through: :domain_contacts
|
has_many :domains, through: :domain_contacts
|
||||||
has_many :legal_documents, as: :documentable
|
has_many :legal_documents, as: :documentable
|
||||||
has_many :registrant_domains, class_name: 'Domain', foreign_key: 'registrant_id' # when contant is registrant
|
has_many :registrant_domains, class_name: 'Domain', foreign_key: 'registrant_id'
|
||||||
|
|
||||||
# TODO: remove later
|
# TODO: remove later
|
||||||
has_many :depricated_statuses, class_name: 'DepricatedContactStatus', dependent: :destroy
|
has_many :depricated_statuses, class_name: 'DepricatedContactStatus', dependent: :destroy
|
||||||
|
@ -19,7 +19,7 @@ class Contact < ActiveRecord::Base
|
||||||
|
|
||||||
accepts_nested_attributes_for :legal_documents
|
accepts_nested_attributes_for :legal_documents
|
||||||
|
|
||||||
validates :name, :phone, :email, :ident, :ident_type, :registrar, presence: true
|
validates :name, :phone, :email, :ident, :ident_type, presence: true
|
||||||
validates :street, :city, :zip, :country_code, presence: true, if: 'self.class.address_processing?'
|
validates :street, :city, :zip, :country_code, presence: true, if: 'self.class.address_processing?'
|
||||||
|
|
||||||
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/, phone: true
|
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/, phone: true
|
||||||
|
|
|
@ -354,7 +354,7 @@ describe Contact, '.destroy_orphans' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.describe Contact, db: false do
|
RSpec.describe Contact do
|
||||||
it { is_expected.to alias_attribute(:kind, :ident_type) }
|
it { is_expected.to alias_attribute(:kind, :ident_type) }
|
||||||
|
|
||||||
describe '::names' do
|
describe '::names' do
|
||||||
|
@ -400,6 +400,16 @@ RSpec.describe Contact, db: false do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'registrar validation', db: false do
|
||||||
|
let(:contact) { described_class.new }
|
||||||
|
|
||||||
|
it 'rejects absent' do
|
||||||
|
contact.registrar = nil
|
||||||
|
contact.validate
|
||||||
|
expect(contact.errors).to have_key(:registrar)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'address validation', db: false do
|
describe 'address validation', db: false do
|
||||||
let(:contact) { described_class.new }
|
let(:contact) { described_class.new }
|
||||||
subject(:errors) { contact.errors }
|
subject(:errors) { contact.errors }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue