Merge pull request #2713 from internetee/registred-company-return-not-exists

Registred company return not exists
This commit is contained in:
OlegPhenomenon 2024-11-26 13:31:23 +02:00 committed by GitHub
commit 475b1e7fbd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 100 additions and 47 deletions

View file

@ -14,7 +14,7 @@ module Actions
maybe_attach_legal_doc
validate_ident
maybe_change_email
maybe_company_is_relevant
# maybe_company_is_relevant
commit
validate_contact
end
@ -78,15 +78,16 @@ module Actions
@error = true
end
def maybe_company_is_relevant
return true unless contact.org?
# def maybe_company_is_relevant
# return true unless contact.org?
company_status = contact.return_company_status
return if [Contact::REGISTERED, Contact::LIQUIDATED].include? company_status
# company_status = contact.return_company_status
contact.add_epp_error('2003', nil, 'ident', I18n.t('errors.messages.company_not_registered'))
@error = true
end
# return if [Contact::REGISTERED, Contact::LIQUIDATED].include? company_status
# contact.add_epp_error('2003', nil, 'ident', I18n.t('errors.messages.company_not_registered'))
# @error = true
# end
def maybe_attach_legal_doc
::Actions::BaseAction.attach_legal_doc_to_new(contact, legal_document, domain: false)

View file

@ -19,7 +19,7 @@ module Contact::CompanyRegister
def return_company_data
return unless org?
company_register.simple_data(registration_number: ident)
company_register.simple_data(registration_number: ident.to_s)
rescue CompanyRegister::NotAvailableError
[]
end

View file

@ -9,13 +9,6 @@ SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
--
-- *not* creating schema, since initdb creates it
--
-- Name: btree_gin; Type: EXTENSION; Schema: -; Owner: -
--
@ -2636,6 +2629,40 @@ CREATE SEQUENCE public.repp_logs_id_seq
ALTER SEQUENCE public.repp_logs_id_seq OWNED BY public.repp_logs.id;
--
-- Name: reserve_domain_invoices; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.reserve_domain_invoices (
id bigint NOT NULL,
invoice_number character varying,
domain_names character varying[] DEFAULT '{}'::character varying[],
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL,
status integer DEFAULT 0,
metainfo character varying
);
--
-- Name: reserve_domain_invoices_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.reserve_domain_invoices_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: reserve_domain_invoices_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.reserve_domain_invoices_id_seq OWNED BY public.reserve_domain_invoices.id;
--
-- Name: reserved_domains; Type: TABLE; Schema: public; Owner: -
--
@ -3417,6 +3444,13 @@ ALTER TABLE ONLY public.registrars ALTER COLUMN id SET DEFAULT nextval('public.r
ALTER TABLE ONLY public.repp_logs ALTER COLUMN id SET DEFAULT nextval('public.repp_logs_id_seq'::regclass);
--
-- Name: reserve_domain_invoices id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.reserve_domain_invoices ALTER COLUMN id SET DEFAULT nextval('public.reserve_domain_invoices_id_seq'::regclass);
--
-- Name: reserved_domains id; Type: DEFAULT; Schema: public; Owner: -
--
@ -3976,6 +4010,14 @@ ALTER TABLE ONLY public.repp_logs
ADD CONSTRAINT repp_logs_pkey PRIMARY KEY (id);
--
-- Name: reserve_domain_invoices reserve_domain_invoices_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.reserve_domain_invoices
ADD CONSTRAINT reserve_domain_invoices_pkey PRIMARY KEY (id);
--
-- Name: reserved_domains reserved_domains_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
@ -4784,6 +4826,13 @@ CREATE INDEX index_registrant_verifications_on_created_at ON public.registrant_v
CREATE INDEX index_registrant_verifications_on_domain_id ON public.registrant_verifications USING btree (domain_id);
--
-- Name: index_reserve_domain_invoices_on_invoice_number; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_reserve_domain_invoices_on_invoice_number ON public.reserve_domain_invoices USING btree (invoice_number);
--
-- Name: index_setting_entries_on_code; Type: INDEX; Schema: public; Owner: -
--
@ -5613,8 +5662,11 @@ INSERT INTO "schema_migrations" (version) VALUES
('20230711083811'),
('20240816091049'),
('20240816092636'),
('20240903131540'),
('20240924103554'),
('20241015071505');
('20241015071505'),
('20241030095636'),
('20241104104620'),
('20241112093540'),
('20241112124405');

View file

@ -188,39 +188,39 @@ class ReppV1ContactsCreateTest < ActionDispatch::IntegrationTest
ENV['shunter_enabled'] = 'false'
end
def test_returns_error_response_if_company_not_existed
original_new_method = CompanyRegister::Client.method(:new)
CompanyRegister::Client.define_singleton_method(:new) do
object = original_new_method.call
def object.simple_data(registration_number:)
[Company.new('1234567', 'ACME Ltd', 'K')]
end
object
end
# def test_returns_error_response_if_company_not_existed
# original_new_method = CompanyRegister::Client.method(:new)
# CompanyRegister::Client.define_singleton_method(:new) do
# object = original_new_method.call
# def object.simple_data(registration_number:)
# [Company.new('1234567', 'ACME Ltd', 'K')]
# end
# object
# end
request_body = {
"contact": {
"name": 'Donald Trump',
"phone": '+372.51111112',
"email": 'donald@trumptower.com',
"ident": {
"ident_type": 'org',
"ident_country_code": 'EE',
"ident": '70000313',
},
},
}
# request_body = {
# "contact": {
# "name": 'Donald Trump',
# "phone": '+372.51111112',
# "email": 'donald@trumptower.com',
# "ident": {
# "ident_type": 'org',
# "ident_country_code": 'EE',
# "ident": '70000313',
# },
# },
# }
post '/repp/v1/contacts', headers: @auth_headers, params: request_body
json = JSON.parse(response.body, symbolize_names: true)
# post '/repp/v1/contacts', headers: @auth_headers, params: request_body
# json = JSON.parse(response.body, symbolize_names: true)
assert_response :bad_request
assert_equal 2003, json[:code]
puts json[:message]
assert json[:message].include? 'Company is not registered'
# assert_response :bad_request
# assert_equal 2003, json[:code]
# puts json[:message]
# assert json[:message].include? 'Company is not registered'
CompanyRegister::Client.define_singleton_method(:new, original_new_method)
end
# CompanyRegister::Client.define_singleton_method(:new, original_new_method)
# end
def test_contact_created_with_existed_company
original_new_method = CompanyRegister::Client.method(:new)