From fd5217250084ec3a2f465f4f41089aa9f17741dd Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Thu, 17 Sep 2015 17:52:47 +0300 Subject: [PATCH] Ident type update #2834 --- app/models/contact.rb | 13 +++++++------ app/models/depp/contact.rb | 4 ++-- app/models/epp/domain.rb | 4 ++-- db/schema-read-only.rb | 5 +++-- db/structure.sql | 9 +++++++-- lib/tasks/import.rake | 2 +- spec/epp/domain_spec.rb | 2 +- spec/features/registrar/contact_spec.rb | 4 ++-- spec/models/contact_spec.rb | 14 +++++++------- 9 files changed, 32 insertions(+), 25 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index a995e2f03..a9dfe8cbb 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -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 diff --git a/app/models/depp/contact.rb b/app/models/depp/contact.rb index 316d78818..a1f781971 100644 --- a/app/models/depp/contact.rb +++ b/app/models/depp/contact.rb @@ -267,8 +267,8 @@ module Depp Country.new(country_code) end - def bic? - ident_type == 'bic' + def org? + ident_type == 'org' end def priv? diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 34d0e01e3..c8ceef2dc 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -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 diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb index 0a9fea6ec..615e64008 100644 --- a/db/schema-read-only.rb +++ b/db/schema-read-only.rb @@ -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| diff --git a/db/structure.sql b/db/structure.sql index d08361887..75246ec42 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -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'); diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index 7b3625ad2..54f85b105 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -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 } diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index a3efb30da..473ea3cf3 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -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) diff --git a/spec/features/registrar/contact_spec.rb b/spec/features/registrar/contact_spec.rb index bf0ebcda4..6e3b1dfba 100644 --- a/spec/features/registrar/contact_spec.rb +++ b/spec/features/registrar/contact_spec.rb @@ -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 diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 4407fdac2..79d96030b 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -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([])