From 712ee75b6a159c099a1d6dcae2a0a3a91f1b9411 Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Fri, 10 Apr 2026 13:09:02 +0300 Subject: [PATCH 1/8] Add admin toggle for business contacts validation Introduces `validate_business_contacts` SettingEntry (group: contacts) that controls whether org contacts are validated against the Estonian business register in Actions::ContactCreate#maybe_company_is_relevant. When disabled, the validation is skipped entirely; the existing ENV fallback is preserved. Refs: https://github.com/internetee/registrant_center/issues/166 --- app/interactions/actions/contact_create.rb | 1 + ...24_add_validate_business_contacts_to_settings.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 db/migrate/20260410130124_add_validate_business_contacts_to_settings.rb diff --git a/app/interactions/actions/contact_create.rb b/app/interactions/actions/contact_create.rb index 782efdf9a4..d3986e2885 100644 --- a/app/interactions/actions/contact_create.rb +++ b/app/interactions/actions/contact_create.rb @@ -84,6 +84,7 @@ def validate_ident_birthday end def maybe_company_is_relevant + return true unless Setting.validate_business_contacts return true if ENV['allow_validate_business_contacts'] && ENV['allow_validate_business_contacts'] == 'false' return true unless contact.org? return true unless contact.ident_country_code == 'EE' diff --git a/db/migrate/20260410130124_add_validate_business_contacts_to_settings.rb b/db/migrate/20260410130124_add_validate_business_contacts_to_settings.rb new file mode 100644 index 0000000000..36166f2b14 --- /dev/null +++ b/db/migrate/20260410130124_add_validate_business_contacts_to_settings.rb @@ -0,0 +1,13 @@ +class AddValidateBusinessContactsToSettings < ActiveRecord::Migration[6.1] + def up + execute <<~SQL + INSERT INTO setting_entries (code, value, format, "group", created_at, updated_at) + SELECT 'validate_business_contacts', 'true', 'boolean', 'contacts', NOW(), NOW() + WHERE NOT EXISTS (SELECT 1 FROM setting_entries WHERE code = 'validate_business_contacts'); + SQL + end + + def down + execute "DELETE FROM setting_entries WHERE code = 'validate_business_contacts';" + end +end From 51cadcba1fe4a383310930213bfc11ead81c713e Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Fri, 10 Apr 2026 13:13:17 +0300 Subject: [PATCH 2/8] Wrap setting_entries insert in safety_assured strong_migrations cannot inspect raw execute blocks, so the INSERT/DELETE statements for the validate_business_contacts setting need an explicit safety_assured wrapper to pass the migration guard. Refs: https://github.com/internetee/registrant_center/issues/166 --- ...add_validate_business_contacts_to_settings.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/db/migrate/20260410130124_add_validate_business_contacts_to_settings.rb b/db/migrate/20260410130124_add_validate_business_contacts_to_settings.rb index 36166f2b14..a59af4d339 100644 --- a/db/migrate/20260410130124_add_validate_business_contacts_to_settings.rb +++ b/db/migrate/20260410130124_add_validate_business_contacts_to_settings.rb @@ -1,13 +1,17 @@ class AddValidateBusinessContactsToSettings < ActiveRecord::Migration[6.1] def up - execute <<~SQL - INSERT INTO setting_entries (code, value, format, "group", created_at, updated_at) - SELECT 'validate_business_contacts', 'true', 'boolean', 'contacts', NOW(), NOW() - WHERE NOT EXISTS (SELECT 1 FROM setting_entries WHERE code = 'validate_business_contacts'); - SQL + safety_assured do + execute <<~SQL + INSERT INTO setting_entries (code, value, format, "group", created_at, updated_at) + SELECT 'validate_business_contacts', 'true', 'boolean', 'contacts', NOW(), NOW() + WHERE NOT EXISTS (SELECT 1 FROM setting_entries WHERE code = 'validate_business_contacts'); + SQL + end end def down - execute "DELETE FROM setting_entries WHERE code = 'validate_business_contacts';" + safety_assured do + execute "DELETE FROM setting_entries WHERE code = 'validate_business_contacts';" + end end end From 6dc33e0399c68160389ded7eea88204814e144c5 Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Fri, 10 Apr 2026 13:21:02 +0300 Subject: [PATCH 3/8] Test business contacts validation toggle Covers Actions::ContactCreate#maybe_company_is_relevant: - skips the company register lookup entirely when the setting is off - honours REGISTERED status when the setting is on - surfaces the company_not_registered EPP error otherwise Refs: https://github.com/internetee/registrant_center/issues/166 --- test/fixtures/setting_entries.yml | 8 ++++ .../actions/contact_create_test.rb | 47 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 test/interactions/actions/contact_create_test.rb diff --git a/test/fixtures/setting_entries.yml b/test/fixtures/setting_entries.yml index 2df870258e..4211e1a2b5 100644 --- a/test/fixtures/setting_entries.yml +++ b/test/fixtures/setting_entries.yml @@ -493,3 +493,11 @@ admin_contacts_allowed_ident_type: format: array created_at: <%= Time.zone.parse('2010-07-05') %> updated_at: <%= Time.zone.parse('2010-07-05') %> + +validate_business_contacts: + code: validate_business_contacts + value: 'true' + group: contacts + format: boolean + created_at: <%= Time.zone.parse('2010-07-05') %> + updated_at: <%= Time.zone.parse('2010-07-05') %> diff --git a/test/interactions/actions/contact_create_test.rb b/test/interactions/actions/contact_create_test.rb new file mode 100644 index 0000000000..ac58f82b9f --- /dev/null +++ b/test/interactions/actions/contact_create_test.rb @@ -0,0 +1,47 @@ +require 'test_helper' + +class Actions::ContactCreateTest < ActiveSupport::TestCase + setup do + @contact = contacts(:acme_ltd) + @contact.ident_country_code = 'EE' + @ident = { ident: @contact.ident, + ident_type: @contact.ident_type, + ident_country_code: @contact.ident_country_code } + end + + teardown do + Setting.validate_business_contacts = 'true' + end + + def test_maybe_company_is_relevant_returns_true_when_toggle_disabled + Setting.validate_business_contacts = 'false' + + @contact.stub :return_company_status, ->(*) { flunk 'company register must not be called' } do + action = Actions::ContactCreate.new(@contact, nil, @ident) + assert_equal true, action.maybe_company_is_relevant + end + + epp_msgs = @contact.errors.where(:epp_errors).map { |e| e.options[:msg] } + assert_empty epp_msgs + end + + def test_maybe_company_is_relevant_checks_register_when_toggle_enabled_and_company_registered + Setting.validate_business_contacts = 'true' + + @contact.stub :return_company_status, Contact::REGISTERED do + action = Actions::ContactCreate.new(@contact, nil, @ident) + assert_equal true, action.maybe_company_is_relevant + end + end + + def test_maybe_company_is_relevant_adds_error_when_toggle_enabled_and_company_missing + Setting.validate_business_contacts = 'true' + + @contact.stub :return_company_status, 'N' do + action = Actions::ContactCreate.new(@contact, nil, @ident) + action.maybe_company_is_relevant + error_texts = @contact.errors.where(:epp_errors).map { |e| e.options[:msg] } + assert(error_texts.any? { |msg| msg.to_s.include?(I18n.t('errors.messages.company_not_registered')) }) + end + end +end From 84a6365ec4770cf6e063e36f1b35e77a20c952c2 Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Fri, 10 Apr 2026 13:38:27 +0300 Subject: [PATCH 4/8] added new migration into schema --- db/structure.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/structure.sql b/db/structure.sql index f9fcd64f8c..14261c743b 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -3,6 +3,7 @@ -- Dumped from database version 13.4 (Debian 13.4-4.pgdg110+1) -- Dumped by pg_dump version 13.23 (Debian 13.23-1.pgdg11+1) + SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; @@ -5863,6 +5864,6 @@ INSERT INTO "schema_migrations" (version) VALUES ('20260406125446'), ('20260529120000'), ('20260601120000'), -('20260608120000'); - +('20260608120000'), +('20260410130124'); From d1d010133282fa5a76b57da80e2f66f2ce07d8be Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Mon, 13 Apr 2026 16:01:07 +0300 Subject: [PATCH 5/8] Add admin toggle to disable company register API for registrant Introduces `company_register_api_enabled` SettingEntry (group: contacts) that controls whether the registrant API queries the company register service. When disabled, RegistrantUser#companies returns an empty array, effectively skipping all company-based lookups in the registrant API controllers (companies, domains, contacts). Refs: https://github.com/internetee/registrant_center/issues/166 --- app/models/registrant_user.rb | 1 + ..._company_register_api_enabled_to_settings.rb | 17 +++++++++++++++++ db/structure.sql | 5 +++-- test/fixtures/setting_entries.yml | 8 ++++++++ test/models/registrant_user_test.rb | 12 ++++++++++++ 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20260413125925_add_company_register_api_enabled_to_settings.rb diff --git a/app/models/registrant_user.rb b/app/models/registrant_user.rb index 073ab3214a..cf39c8601d 100644 --- a/app/models/registrant_user.rb +++ b/app/models/registrant_user.rb @@ -18,6 +18,7 @@ def country end def companies(company_register = CompanyRegister::Client.new) + return [] unless Setting.company_register_api_enabled return [] if ident.include?('-') company_register.representation_rights(citizen_personal_code: ident, diff --git a/db/migrate/20260413125925_add_company_register_api_enabled_to_settings.rb b/db/migrate/20260413125925_add_company_register_api_enabled_to_settings.rb new file mode 100644 index 0000000000..ed099e855e --- /dev/null +++ b/db/migrate/20260413125925_add_company_register_api_enabled_to_settings.rb @@ -0,0 +1,17 @@ +class AddCompanyRegisterApiEnabledToSettings < ActiveRecord::Migration[6.1] + def up + safety_assured do + execute <<~SQL + INSERT INTO setting_entries (code, value, format, "group", created_at, updated_at) + SELECT 'company_register_api_enabled', 'true', 'boolean', 'contacts', NOW(), NOW() + WHERE NOT EXISTS (SELECT 1 FROM setting_entries WHERE code = 'company_register_api_enabled'); + SQL + end + end + + def down + safety_assured do + execute "DELETE FROM setting_entries WHERE code = 'company_register_api_enabled';" + end + end +end diff --git a/db/structure.sql b/db/structure.sql index 14261c743b..c0806d0f66 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1,5 +1,6 @@ \restrict WmlyozFAnc1c6zHWXudb7s2jRC1uKwHPlCMDikRGHsbNPX1TGBaq3KQ01YXVO8T + -- Dumped from database version 13.4 (Debian 13.4-4.pgdg110+1) -- Dumped by pg_dump version 13.23 (Debian 13.23-1.pgdg11+1) @@ -5865,5 +5866,5 @@ INSERT INTO "schema_migrations" (version) VALUES ('20260529120000'), ('20260601120000'), ('20260608120000'), -('20260410130124'); - +('20260410130124'), +('20260413125925'); diff --git a/test/fixtures/setting_entries.yml b/test/fixtures/setting_entries.yml index 4211e1a2b5..8b74f035c4 100644 --- a/test/fixtures/setting_entries.yml +++ b/test/fixtures/setting_entries.yml @@ -501,3 +501,11 @@ validate_business_contacts: format: boolean created_at: <%= Time.zone.parse('2010-07-05') %> updated_at: <%= Time.zone.parse('2010-07-05') %> + +company_register_api_enabled: + code: company_register_api_enabled + value: 'true' + group: contacts + format: boolean + created_at: <%= Time.zone.parse('2010-07-05') %> + updated_at: <%= Time.zone.parse('2010-07-05') %> diff --git a/test/models/registrant_user_test.rb b/test/models/registrant_user_test.rb index fb60c88fc9..079db94f3d 100644 --- a/test/models/registrant_user_test.rb +++ b/test/models/registrant_user_test.rb @@ -81,6 +81,18 @@ def test_should_update_contacts_if_names_dismatch end end + def test_companies_returns_empty_when_company_register_api_disabled + Setting.company_register_api_enabled = 'false' + + company_register = Minitest::Mock.new + result = @user.companies(company_register) + + assert_equal [], result + company_register.verify + ensure + Setting.company_register_api_enabled = 'true' + end + def test_queries_company_register_for_associated_companies assert_equal 'US-1234', @user.registrant_ident From a602a070819de7dbb8f22294ca3d37c500ee6c4a Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Mon, 13 Apr 2026 16:05:23 +0300 Subject: [PATCH 6/8] Move company register toggle to registrant API controllers The setting should only affect the registrant portal context (registrant server <-> registry), not global company register usage (EPP validation, phone checker jobs, etc). Moves the `company_register_api_enabled` check from RegistrantUser#companies into the three registrant API controllers: - CompaniesController: returns empty list - DomainsController: falls back to direct_domains - ContactsController: falls back to direct_contacts --- .../api/v1/registrant/companies_controller.rb | 2 ++ .../api/v1/registrant/contacts_controller.rb | 3 +++ .../api/v1/registrant/domains_controller.rb | 4 ++++ app/models/registrant_user.rb | 1 - .../api/registrant/registrant_api_companies_test.rb | 12 ++++++++++++ .../api/registrant/registrant_api_contacts_test.rb | 13 +++++++++++++ .../api/registrant/registrant_api_domains_test.rb | 12 ++++++++++++ test/models/registrant_user_test.rb | 12 ------------ 8 files changed, 46 insertions(+), 13 deletions(-) diff --git a/app/controllers/api/v1/registrant/companies_controller.rb b/app/controllers/api/v1/registrant/companies_controller.rb index d2060276d9..71f3f2b8d8 100644 --- a/app/controllers/api/v1/registrant/companies_controller.rb +++ b/app/controllers/api/v1/registrant/companies_controller.rb @@ -16,6 +16,8 @@ def index end def current_user_companies + return [:ok, []] unless Setting.company_register_api_enabled + [:ok, current_registrant_user.companies] rescue CompanyRegister::NotAvailableError [:service_unavailable, []] diff --git a/app/controllers/api/v1/registrant/contacts_controller.rb b/app/controllers/api/v1/registrant/contacts_controller.rb index 1c22277df7..e57159d220 100644 --- a/app/controllers/api/v1/registrant/contacts_controller.rb +++ b/app/controllers/api/v1/registrant/contacts_controller.rb @@ -85,6 +85,7 @@ def representable_contact(uuid) contact = Contact.find_by(uuid: uuid, ident: current_registrant_user.ident, ident_type: 'priv', ident_country_code: country) return contact if contact + return nil unless Setting.company_register_api_enabled Contact.find_by(uuid: uuid, ident_type: 'org', ident: company_codes, ident_country_code: country) @@ -97,6 +98,8 @@ def company_codes end def current_user_contacts + return current_registrant_user.direct_contacts unless Setting.company_register_api_enabled + current_registrant_user.contacts(representable: false) rescue CompanyRegister::NotAvailableError current_registrant_user.direct_contacts diff --git a/app/controllers/api/v1/registrant/domains_controller.rb b/app/controllers/api/v1/registrant/domains_controller.rb index 95475a4989..bc3be0c73c 100644 --- a/app/controllers/api/v1/registrant/domains_controller.rb +++ b/app/controllers/api/v1/registrant/domains_controller.rb @@ -53,12 +53,16 @@ def set_tech_flag end def current_user_domains_total_count + return current_registrant_user.direct_domains.count unless Setting.company_register_api_enabled + current_registrant_user.domains.count rescue CompanyRegister::NotAvailableError current_registrant_user.direct_domains.count end def current_user_domains + return init_count_of_direct_domains unless Setting.company_register_api_enabled + init_count_of_domains rescue CompanyRegister::NotAvailableError init_count_of_direct_domains diff --git a/app/models/registrant_user.rb b/app/models/registrant_user.rb index cf39c8601d..073ab3214a 100644 --- a/app/models/registrant_user.rb +++ b/app/models/registrant_user.rb @@ -18,7 +18,6 @@ def country end def companies(company_register = CompanyRegister::Client.new) - return [] unless Setting.company_register_api_enabled return [] if ident.include?('-') company_register.representation_rights(citizen_personal_code: ident, diff --git a/test/integration/api/registrant/registrant_api_companies_test.rb b/test/integration/api/registrant/registrant_api_companies_test.rb index 4f23aeac1d..b101035f5d 100644 --- a/test/integration/api/registrant/registrant_api_companies_test.rb +++ b/test/integration/api/registrant/registrant_api_companies_test.rb @@ -34,6 +34,18 @@ def test_format assert_equal(:companies, response_json.keys.first) end + def test_returns_empty_companies_when_company_register_api_disabled + Setting.company_register_api_enabled = 'false' + + get '/api/v1/registrant/companies', headers: @auth_headers + response_json = JSON.parse(response.body, symbolize_names: true) + + assert_equal(200, response.status) + assert_equal([], response_json[:companies]) + ensure + Setting.company_register_api_enabled = 'true' + end + private def auth_token diff --git a/test/integration/api/registrant/registrant_api_contacts_test.rb b/test/integration/api/registrant/registrant_api_contacts_test.rb index f3998a2e91..cd8ff3d29b 100644 --- a/test/integration/api/registrant/registrant_api_contacts_test.rb +++ b/test/integration/api/registrant/registrant_api_contacts_test.rb @@ -66,6 +66,19 @@ def test_gets_contact_domain_links_when_requested assert_empty expected_links - response_json[:links] end + + def test_returns_only_direct_contacts_when_company_register_api_disabled + Setting.company_register_api_enabled = 'false' + + get '/api/v1/registrant/contacts', headers: @auth_headers + assert_equal(200, response.status) + + response_json = JSON.parse(response.body, symbolize_names: true) + assert response_json.is_a?(Array) + ensure + Setting.company_register_api_enabled = 'true' + end + private def auth_token diff --git a/test/integration/api/registrant/registrant_api_domains_test.rb b/test/integration/api/registrant/registrant_api_domains_test.rb index a8801f1b4a..bca8f3fd5b 100644 --- a/test/integration/api/registrant/registrant_api_domains_test.rb +++ b/test/integration/api/registrant/registrant_api_domains_test.rb @@ -153,6 +153,18 @@ def test_details_returns_401_without_authorization assert_equal({ errors: [base: ['Not authorized']] }, json_body) end + def test_returns_only_direct_domains_when_company_register_api_disabled + Setting.company_register_api_enabled = 'false' + + get '/api/v1/registrant/domains', headers: @auth_headers + assert_equal(200, response.status) + + response_json = JSON.parse(response.body, symbolize_names: true) + assert response_json[:domains].is_a?(Array) + ensure + Setting.company_register_api_enabled = 'true' + end + private def auth_token diff --git a/test/models/registrant_user_test.rb b/test/models/registrant_user_test.rb index 079db94f3d..fb60c88fc9 100644 --- a/test/models/registrant_user_test.rb +++ b/test/models/registrant_user_test.rb @@ -81,18 +81,6 @@ def test_should_update_contacts_if_names_dismatch end end - def test_companies_returns_empty_when_company_register_api_disabled - Setting.company_register_api_enabled = 'false' - - company_register = Minitest::Mock.new - result = @user.companies(company_register) - - assert_equal [], result - company_register.verify - ensure - Setting.company_register_api_enabled = 'true' - end - def test_queries_company_register_for_associated_companies assert_equal 'US-1234', @user.registrant_ident From d264a8454cb37172bf48835bde448faaac181298 Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Mon, 13 Apr 2026 16:09:09 +0300 Subject: [PATCH 7/8] Refactor: extract company_register_api_enabled? helper to BaseController Replaces direct Setting.company_register_api_enabled calls in three controllers with a shared predicate in BaseController. Also guards do_need_update_contacts and update_contacts endpoints which call companies internally. --- .../api/v1/registrant/base_controller.rb | 4 ++++ .../api/v1/registrant/companies_controller.rb | 2 +- .../api/v1/registrant/contacts_controller.rb | 14 ++++++++++++-- .../api/v1/registrant/domains_controller.rb | 4 ++-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/v1/registrant/base_controller.rb b/app/controllers/api/v1/registrant/base_controller.rb index 16980be8b6..d85368bbcb 100644 --- a/app/controllers/api/v1/registrant/base_controller.rb +++ b/app/controllers/api/v1/registrant/base_controller.rb @@ -54,6 +54,10 @@ def show_not_found_error def show_invalid_record_error(exception) render json: { errors: exception.record.errors }, status: :bad_request end + + def company_register_api_enabled? + Setting.company_register_api_enabled + end end end end diff --git a/app/controllers/api/v1/registrant/companies_controller.rb b/app/controllers/api/v1/registrant/companies_controller.rb index 71f3f2b8d8..0c7a1f42dc 100644 --- a/app/controllers/api/v1/registrant/companies_controller.rb +++ b/app/controllers/api/v1/registrant/companies_controller.rb @@ -16,7 +16,7 @@ def index end def current_user_companies - return [:ok, []] unless Setting.company_register_api_enabled + return [:ok, []] unless company_register_api_enabled? [:ok, current_registrant_user.companies] rescue CompanyRegister::NotAvailableError diff --git a/app/controllers/api/v1/registrant/contacts_controller.rb b/app/controllers/api/v1/registrant/contacts_controller.rb index e57159d220..a3b31bd224 100644 --- a/app/controllers/api/v1/registrant/contacts_controller.rb +++ b/app/controllers/api/v1/registrant/contacts_controller.rb @@ -35,11 +35,21 @@ def show end def do_need_update_contacts + unless company_register_api_enabled? + render json: { update_contacts: false, counter: 0 } + return + end + result = current_registrant_user.do_need_update_contacts? render json: { update_contacts: result[:result], counter: result[:counter] } end def update_contacts + unless company_register_api_enabled? + render json: { message: 'get it', contacts: [] } + return + end + contacts = current_registrant_user.update_contacts render json: { message: 'get it', contacts: contacts } @@ -85,7 +95,7 @@ def representable_contact(uuid) contact = Contact.find_by(uuid: uuid, ident: current_registrant_user.ident, ident_type: 'priv', ident_country_code: country) return contact if contact - return nil unless Setting.company_register_api_enabled + return nil unless company_register_api_enabled? Contact.find_by(uuid: uuid, ident_type: 'org', ident: company_codes, ident_country_code: country) @@ -98,7 +108,7 @@ def company_codes end def current_user_contacts - return current_registrant_user.direct_contacts unless Setting.company_register_api_enabled + return current_registrant_user.direct_contacts unless company_register_api_enabled? current_registrant_user.contacts(representable: false) rescue CompanyRegister::NotAvailableError diff --git a/app/controllers/api/v1/registrant/domains_controller.rb b/app/controllers/api/v1/registrant/domains_controller.rb index bc3be0c73c..5840e326cb 100644 --- a/app/controllers/api/v1/registrant/domains_controller.rb +++ b/app/controllers/api/v1/registrant/domains_controller.rb @@ -53,7 +53,7 @@ def set_tech_flag end def current_user_domains_total_count - return current_registrant_user.direct_domains.count unless Setting.company_register_api_enabled + return current_registrant_user.direct_domains.count unless company_register_api_enabled? current_registrant_user.domains.count rescue CompanyRegister::NotAvailableError @@ -61,7 +61,7 @@ def current_user_domains_total_count end def current_user_domains - return init_count_of_direct_domains unless Setting.company_register_api_enabled + return init_count_of_direct_domains unless company_register_api_enabled? init_count_of_domains rescue CompanyRegister::NotAvailableError From 7001778b8476d7f6e2df1faa1b7a300d9459c659 Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Mon, 4 May 2026 16:27:51 +0300 Subject: [PATCH 8/8] Remove deprecated ENV allow_validate_business_contacts toggle The Setting.validate_business_contacts replaces the legacy ENV-based toggle. Drop the duplicate ENV check from contact_create and update the integration test to use the Setting accessor. --- app/interactions/actions/contact_create.rb | 1 - test/integration/repp/v1/contacts/create_test.rb | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/interactions/actions/contact_create.rb b/app/interactions/actions/contact_create.rb index d3986e2885..6acc98f326 100644 --- a/app/interactions/actions/contact_create.rb +++ b/app/interactions/actions/contact_create.rb @@ -85,7 +85,6 @@ def validate_ident_birthday def maybe_company_is_relevant return true unless Setting.validate_business_contacts - return true if ENV['allow_validate_business_contacts'] && ENV['allow_validate_business_contacts'] == 'false' return true unless contact.org? return true unless contact.ident_country_code == 'EE' diff --git a/test/integration/repp/v1/contacts/create_test.rb b/test/integration/repp/v1/contacts/create_test.rb index a57e0d0d7c..a821846ee8 100644 --- a/test/integration/repp/v1/contacts/create_test.rb +++ b/test/integration/repp/v1/contacts/create_test.rb @@ -222,7 +222,7 @@ def object.simple_data(registration_number:) end def test_skip_company_validation_if_flag_is_set - ENV['allow_validate_business_contacts'] = 'false' + Setting.validate_business_contacts = false original_new_method = CompanyRegister::Client.method(:new) CompanyRegister::Client.define_singleton_method(:new) do object = original_new_method.call @@ -253,7 +253,7 @@ def object.simple_data(registration_number:) assert_equal 'Command completed successfully', json[:message] CompanyRegister::Client.define_singleton_method(:new, original_new_method) - ENV['allow_validate_business_contacts'] = 'true' + Setting.validate_business_contacts = true end