mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 18:29:40 +02:00
Merge branch 'master' of github.com:domify/registry
This commit is contained in:
commit
08a5f4e76a
9 changed files with 32 additions and 25 deletions
|
@ -23,7 +23,7 @@ class Contact < ActiveRecord::Base
|
|||
validates :ident,
|
||||
format: { with: /\d{4}-\d{2}-\d{2}/, message: :invalid_birthday_format },
|
||||
if: proc { |c| c.ident_type == 'birthday' }
|
||||
validates :ident_country_code, presence: true, if: proc { |c| %w(bic priv).include? c.ident_type }
|
||||
validates :ident_country_code, presence: true, if: proc { |c| %w(org priv).include? c.ident_type }
|
||||
validates :code,
|
||||
uniqueness: { message: :epp_id_taken },
|
||||
format: { with: /\A[\w\-\:]*\Z/i, message: :invalid },
|
||||
|
@ -64,13 +64,13 @@ class Contact < ActiveRecord::Base
|
|||
|
||||
scope :current_registrars, ->(id) { where(registrar_id: id) }
|
||||
|
||||
BIC = 'bic'
|
||||
ORG = 'org'
|
||||
PRIV = 'priv'
|
||||
BIRTHDAY = 'birthday'
|
||||
PASSPORT = 'passport'
|
||||
|
||||
IDENT_TYPES = [
|
||||
BIC, # Company registry code (or similar)
|
||||
ORG, # Company registry code (or similar)
|
||||
PRIV, # National idendtification number
|
||||
BIRTHDAY # Birthday date
|
||||
]
|
||||
|
@ -226,12 +226,13 @@ class Contact < ActiveRecord::Base
|
|||
false
|
||||
end
|
||||
|
||||
def bic?
|
||||
ident_type == BIC
|
||||
def org?
|
||||
ident_type == ORG
|
||||
end
|
||||
|
||||
# it might mean priv or birthday type
|
||||
def priv?
|
||||
ident_type != BIC
|
||||
!org?
|
||||
end
|
||||
|
||||
def generate_auth_info
|
||||
|
|
|
@ -267,8 +267,8 @@ module Depp
|
|||
Country.new(country_code)
|
||||
end
|
||||
|
||||
def bic?
|
||||
ident_type == 'bic'
|
||||
def org?
|
||||
ident_type == 'org'
|
||||
end
|
||||
|
||||
def priv?
|
||||
|
|
|
@ -137,7 +137,7 @@ class Epp::Domain < Domain
|
|||
return if registrant.blank?
|
||||
regt = Registrant.find(registrant.id) # temp for bullet
|
||||
tech_contacts << regt if tech_domain_contacts.blank?
|
||||
admin_contacts << regt if admin_domain_contacts.blank? && regt.priv?
|
||||
admin_contacts << regt if admin_domain_contacts.blank? && !regt.org?
|
||||
end
|
||||
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
|
@ -283,7 +283,7 @@ class Epp::Domain < Domain
|
|||
end
|
||||
|
||||
if action != 'rem'
|
||||
if x['type'] == 'admin' && c.bic?
|
||||
if x['type'] == 'admin' && c.org?
|
||||
add_epp_error('2306', 'contact', x.text, [:domain_contacts, :admin_contact_can_be_only_private_person])
|
||||
next
|
||||
end
|
||||
|
|
|
@ -201,6 +201,7 @@ ActiveRecord::Schema.define(version: 20150915094707) do
|
|||
t.integer "legacy_id"
|
||||
t.string "statuses", array: true
|
||||
t.hstore "status_notes"
|
||||
t.integer "legacy_history_id"
|
||||
t.integer "copy_from_id"
|
||||
end
|
||||
|
||||
|
@ -887,8 +888,8 @@ ActiveRecord::Schema.define(version: 20150915094707) do
|
|||
t.string "cc"
|
||||
t.text "body", null: false
|
||||
t.text "text_body", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "messages", force: :cascade do |t|
|
||||
|
|
|
@ -597,6 +597,7 @@ CREATE TABLE contacts (
|
|||
legacy_id integer,
|
||||
statuses character varying[],
|
||||
status_notes hstore,
|
||||
legacy_history_id integer,
|
||||
copy_from_id integer
|
||||
);
|
||||
|
||||
|
@ -2242,8 +2243,8 @@ CREATE TABLE mail_templates (
|
|||
cc character varying,
|
||||
body text NOT NULL,
|
||||
text_body text NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL,
|
||||
updated_at timestamp without time zone NOT NULL
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone
|
||||
);
|
||||
|
||||
|
||||
|
@ -4927,8 +4928,12 @@ INSERT INTO schema_migrations (version) VALUES ('20150803080914');
|
|||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150810114746');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150810114747');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150825125118');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150827151906');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150910113839');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150915094707');
|
||||
|
|
|
@ -138,7 +138,7 @@ namespace :import do
|
|||
ident_type_map = {
|
||||
2 => Contact::PRIV,
|
||||
3 => Contact::PASSPORT,
|
||||
4 => Contact::BIC,
|
||||
4 => Contact::ORG,
|
||||
6 => Contact::BIRTHDAY
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ describe 'EPP Domain', epp: true do
|
|||
Fabricate(:contact, code: 'FIXED:CITIZEN_1234')
|
||||
Fabricate(:contact, code: 'FIXED:SH8013')
|
||||
Fabricate(:contact, code: 'FIXED:SH801333')
|
||||
Fabricate(:contact, code: 'FIXED:JURIDICAL_1234', ident_type: 'bic')
|
||||
Fabricate(:contact, code: 'FIXED:JURIDICAL_1234', ident_type: 'org')
|
||||
Fabricate(:reserved_domain)
|
||||
Fabricate(:blocked_domain)
|
||||
@pricelist_reg_1_year = Fabricate(:pricelist, valid_to: nil)
|
||||
|
|
|
@ -62,7 +62,7 @@ feature 'Contact', type: :feature do
|
|||
visit '/registrar/contacts/new'
|
||||
current_path.should == '/registrar/contacts/new'
|
||||
|
||||
fill_in 'depp_contact_ident', with: 'bic-ident'
|
||||
fill_in 'depp_contact_ident', with: 'org-ident'
|
||||
fill_in 'depp_contact_name', with: 'Business Name Ltd'
|
||||
fill_in 'depp_contact_email', with: 'example@example.com'
|
||||
fill_in 'depp_contact_street', with: 'Example street 12'
|
||||
|
@ -72,7 +72,7 @@ feature 'Contact', type: :feature do
|
|||
click_button 'Create'
|
||||
|
||||
page.should have_text('Business Name Ltd')
|
||||
page.should have_text('bic-ident [EE bic]')
|
||||
page.should have_text('org-ident [EE org]')
|
||||
end
|
||||
|
||||
it 'should create new contact with success' do
|
||||
|
|
|
@ -53,8 +53,8 @@ describe Contact do
|
|||
@contact.errors[:phone].should == ["Phone nr is invalid"]
|
||||
end
|
||||
|
||||
it 'should require country code when bic' do
|
||||
@contact.ident_type = 'bic'
|
||||
it 'should require country code when org' do
|
||||
@contact.ident_type = 'org'
|
||||
@contact.valid?
|
||||
@contact.errors[:ident_country_code].should == ['is missing']
|
||||
end
|
||||
|
@ -66,7 +66,7 @@ describe Contact do
|
|||
end
|
||||
|
||||
it 'should validate correct country code' do
|
||||
@contact.ident_type = 'bic'
|
||||
@contact.ident_type = 'org'
|
||||
@contact.ident_country_code = 'EE'
|
||||
@contact.valid?
|
||||
|
||||
|
@ -75,7 +75,7 @@ describe Contact do
|
|||
|
||||
it 'should require valid country code' do
|
||||
@contact.ident = '123'
|
||||
@contact.ident_type = 'bic'
|
||||
@contact.ident_type = 'org'
|
||||
@contact.ident_country_code = 'INVALID'
|
||||
@contact.valid?
|
||||
|
||||
|
@ -84,7 +84,7 @@ describe Contact do
|
|||
end
|
||||
|
||||
it 'should convert to alpha2 country code' do
|
||||
@contact.ident_type = 'bic'
|
||||
@contact.ident_type = 'org'
|
||||
@contact.ident_country_code = 'ee'
|
||||
@contact.valid?
|
||||
|
||||
|
@ -148,8 +148,8 @@ describe Contact do
|
|||
@contact.domains_present?.should == false
|
||||
end
|
||||
|
||||
it 'bic should be valid' do
|
||||
@contact.ident_type = 'bic'
|
||||
it 'org should be valid' do
|
||||
@contact.ident_type = 'org'
|
||||
@contact.ident = '1234'
|
||||
@contact.valid?
|
||||
@contact.errors.full_messages.should match_array([])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue