From a24781f6cb605f8ad341af271f91e60d3de9be20 Mon Sep 17 00:00:00 2001 From: Dmitry Sinina Date: Mon, 16 Dec 2024 14:39:04 +0200 Subject: [PATCH] remove customer_auth_number_fields tables (#1655) * remove customer_auth_number_fields tables * remove transport protocol FK in customer auth --- app/admin/cdr/cdrs.rb | 1 + app/admin/import/import_customers_auths.rb | 2 +- app/admin/routing/customers_auths.rb | 59 +++++---- app/models/cdr/cdr.rb | 1 + app/models/customers_auth.rb | 67 ++++++++-- app/models/importing/customers_auth.rb | 13 +- .../routing/customer_auth_dst_number_field.rb | 22 ---- .../routing/customer_auth_src_name_field.rb | 22 ---- .../routing/customer_auth_src_number_field.rb | 22 ---- .../api/rest/admin/customers_auth_resource.rb | 18 ++- ...5451_remove_customer_auth_number_fields.rb | 57 +++++++++ db/seeds/main/class4.sql | 9 -- db/structure.sql | 117 +----------------- spec/factories/customers_auths.rb | 4 - spec/factories/importing/customers_auths.rb | 4 +- .../export_customers_auth_spec.rb | 10 +- ...lass4.customers_auth_dst_number_fields.yml | 17 --- .../class4.customers_auth_src_name_fields.yml | 20 --- ...lass4.customers_auth_src_number_fields.yml | 20 --- spec/models/customers_auth_spec.rb | 4 - .../api/rest/admin/customers_auth_spec.rb | 10 +- spec/spec_helper.rb | 3 - spec/sql/switch22/route_spec.rb | 16 +-- 23 files changed, 200 insertions(+), 318 deletions(-) delete mode 100644 app/models/routing/customer_auth_dst_number_field.rb delete mode 100644 app/models/routing/customer_auth_src_name_field.rb delete mode 100644 app/models/routing/customer_auth_src_number_field.rb create mode 100644 db/migrate/20241215155451_remove_customer_auth_number_fields.rb delete mode 100644 spec/fixtures/class4.customers_auth_dst_number_fields.yml delete mode 100644 spec/fixtures/class4.customers_auth_src_name_fields.yml delete mode 100644 spec/fixtures/class4.customers_auth_src_number_fields.yml diff --git a/app/admin/cdr/cdrs.rb b/app/admin/cdr/cdrs.rb index 2ed325334..1f5b52a04 100644 --- a/app/admin/cdr/cdrs.rb +++ b/app/admin/cdr/cdrs.rb @@ -46,6 +46,7 @@ def scoped_collection scope :short_calls, show_count: false scope :rerouted_calls, show_count: false scope :with_trace, show_count: false + scope :with_recording, show_count: false scope :not_authorized, show_count: false scope :bad_routing, show_count: false scope :package_billing, show_count: false diff --git a/app/admin/import/import_customers_auths.rb b/app/admin/import/import_customers_auths.rb index 257cb9d41..be8f6a60e 100644 --- a/app/admin/import/import_customers_auths.rb +++ b/app/admin/import/import_customers_auths.rb @@ -31,7 +31,7 @@ def resource_params column :name column :enabled column :reject_calls - column :transport_protocol, sortable: :transport_protocol_name + column :transport_protocol, &:transport_protocol_display_name column :ip column :pop, sortable: :pop_name column :src_prefix diff --git a/app/admin/routing/customers_auths.rb b/app/admin/routing/customers_auths.rb index f43be4328..8075098bf 100644 --- a/app/admin/routing/customers_auths.rb +++ b/app/admin/routing/customers_auths.rb @@ -18,7 +18,7 @@ decorate_with CustomersAuthDecorator acts_as_export :id, :enabled, :reject_calls, :name, - [:transport_protocol_name, proc { |row| row.transport_protocol.try(:name) || '' }], + :transport_protocol_name, :ip, [:pop_name, proc { |row| row.pop.try(:name) || '' }], :src_prefix, @@ -46,9 +46,9 @@ :diversion_policy_name, :diversion_rewrite_rule, :diversion_rewrite_result, :pai_policy_name, :pai_rewrite_rule, :pai_rewrite_result, - [:src_number_field_name, proc { |row| row.src_number_field.try(:name) }], - [:src_name_field_name, proc { |row| row.src_name_field.try(:name) }], - [:dst_number_field_name, proc { |row| row.dst_number_field.try(:name) }], + :src_number_field_name, + :src_name_field_name, + :dst_number_field_name, :src_name_rewrite_rule, :src_name_rewrite_result, :src_rewrite_rule, :src_rewrite_result, :dst_rewrite_rule, :dst_rewrite_result, @@ -100,8 +100,8 @@ # , :enable_redirect, :redirect_method, :redirect_to includes :tag_action, :rateplan, :routing_plan, :gateway, :src_numberlist, :dst_numberlist, - :pop, :radius_auth_profile, :radius_accounting_profile, :customer, :transport_protocol, - :lua_script, :src_name_field, :src_number_field, :dst_number_field, :cnam_database, + :pop, :radius_auth_profile, :radius_accounting_profile, :customer, + :lua_script, :cnam_database, account: :contractor controller do @@ -130,7 +130,7 @@ def update column :name column :enabled column :reject_calls - column :transport_protocol + column :transport_protocol, &:transport_protocol_name column :ip column :pop column :src_prefix @@ -177,20 +177,17 @@ def update column :send_billing_information column :diversion_policy, &:diversion_policy_name - column :diversion_rewrite_rule - column :diversion_rewrite_result - column :pai_policy, &:pai_policy_name - column :src_name_field + column :src_name_field, &:src_name_field_name column :src_name_rewrite_rule column :src_name_rewrite_result - column :src_number_field + column :src_number_field, &:src_number_field_name column :src_rewrite_rule column :src_rewrite_result - column :dst_number_field + column :dst_number_field, &:dst_number_field_name column :dst_rewrite_rule column :dst_rewrite_result @@ -235,7 +232,7 @@ def update filter :pai_policy_id_eq, label: 'PAI policy', as: :select, collection: CustomersAuth::PAI_POLICIES.invert filter :privacy_mode_id_eq, label: 'Privacy mode', as: :select, collection: CustomersAuth::PRIVACY_MODES.invert, input_html: { class: 'chosen' } filter :enable_audio_recording, as: :select, collection: [['Yes', true], ['No', false]] - filter :transport_protocol + filter :transport_protocol_id_eq, label: 'Transport protocol', as: :select, collection: CustomersAuth::TRANSPORT_PROTOCOLS.invert filter :ip_covers, as: :string, input_html: { class: 'search_filter_string' }, @@ -325,7 +322,12 @@ def update end f.inputs 'Match conditions' do - f.input :transport_protocol, as: :select, include_blank: 'Any' + f.input :transport_protocol_id, + as: :select, + include_blank: 'Any', + collection: CustomersAuth::TRANSPORT_PROTOCOLS.invert, + input_html: { class: :chosen } + f.input :ip, as: :array_of_strings f.input :pop, as: :select, include_blank: 'Any', input_html: { class: 'chosen' } f.input :src_prefix, as: :array_of_strings @@ -367,17 +369,30 @@ def update f.input :pai_rewrite_rule f.input :pai_rewrite_result - f.input :src_name_field, as: :select, include_blank: false, input_html: { class: :chosen } + f.input :src_name_field_id, + as: :select, + include_blank: false, + collection: CustomersAuth::SRC_NAME_FIELDS.invert, + input_html: { class: :chosen } f.input :src_name_rewrite_rule f.input :src_name_rewrite_result - f.input :src_number_field, as: :select, include_blank: false, input_html: { class: :chosen } + f.input :src_number_field_id, + as: :select, + include_blank: false, + collection: CustomersAuth::SRC_NUMBER_FIELDS.invert, + input_html: { class: :chosen } f.input :src_rewrite_rule f.input :src_rewrite_result - f.input :dst_number_field, as: :select, include_blank: false, input_html: { class: :chosen } + f.input :dst_number_field_id, + as: :select, + include_blank: false, + collection: CustomersAuth::DST_NUMBER_FIELDS.invert, + input_html: { class: :chosen } f.input :dst_rewrite_rule f.input :dst_rewrite_result + f.input :lua_script, input_html: { class: 'chosen' }, include_blank: 'None' f.input :cnam_database, input_html: { class: 'chosen' }, include_blank: 'None' end @@ -457,7 +472,7 @@ def update end panel 'Match conditions' do attributes_table_for s do - row :transport_protocol + row :transport_protocol, &:transport_protocol_name row :ip row :pop row :src_prefix @@ -486,15 +501,15 @@ def update row :pai_rewrite_rule row :pai_rewrite_result - row :src_name_field + row :src_name_field, &:src_name_field_name row :src_name_rewrite_rule row :src_name_rewrite_result - row :src_number_field + row :src_number_field, &:src_number_field_name row :src_rewrite_rule row :src_rewrite_result - row :dst_number_field + row :dst_number_field, &:dst_number_field_name row :dst_rewrite_rule row :dst_rewrite_result diff --git a/app/models/cdr/cdr.rb b/app/models/cdr/cdr.rb index 766638e13..499c4af8e 100644 --- a/app/models/cdr/cdr.rb +++ b/app/models/cdr/cdr.rb @@ -272,6 +272,7 @@ class Cdr::Cdr < Cdr::Base scope :not_authorized, -> { where('customer_auth_id is null') } scope :bad_routing, -> { where('customer_auth_id is not null AND disconnect_initiator_id=0') } scope :with_trace, -> { where('dump_level_id > 0') } + scope :with_recording, -> { where('audio_recorded and duration > 0 and local_tag is not null') } scope :package_billing, -> { where('package_counter_id is not null') } scope :account_id_eq, ->(account_id) { where('vendor_acc_id =? OR customer_acc_id =?', account_id, account_id) } diff --git a/app/models/customers_auth.rb b/app/models/customers_auth.rb index 6a600f7a4..85edf31ca 100644 --- a/app/models/customers_auth.rb +++ b/app/models/customers_auth.rb @@ -91,7 +91,6 @@ # customers_auth_cnam_database_id_fkey (cnam_database_id => cnam_databases.id) # customers_auth_customer_id_fkey (customer_id => contractors.id) # customers_auth_dst_blacklist_id_fkey (dst_numberlist_id => numberlists.id) -# customers_auth_dst_number_field_id_fkey (dst_number_field_id => customers_auth_dst_number_fields.id) # customers_auth_gateway_id_fkey (gateway_id => gateways.id) # customers_auth_lua_script_id_fkey (lua_script_id => lua_scripts.id) # customers_auth_pop_id_fkey (pop_id => pops.id) @@ -100,15 +99,21 @@ # customers_auth_rateplan_id_fkey (rateplan_id => rateplans.id) # customers_auth_routing_plan_id_fkey (routing_plan_id => routing_plans.id) # customers_auth_src_blacklist_id_fkey (src_numberlist_id => numberlists.id) -# customers_auth_src_name_field_id_fkey (src_name_field_id => customers_auth_src_name_fields.id) -# customers_auth_src_number_field_id_fkey (src_number_field_id => customers_auth_src_number_fields.id) # customers_auth_tag_action_id_fkey (tag_action_id => tag_actions.id) -# customers_auth_transport_protocol_id_fkey (transport_protocol_id => transport_protocols.id) # class CustomersAuth < ApplicationRecord self.table_name = 'class4.customers_auth' + TRANSPORT_PROTOCOL_UDP = 1 + TRANSPORT_PROTOCOL_TCP = 2 + TRANSPORT_PROTOCOL_TLS = 3 + TRANSPORT_PROTOCOLS = { + TRANSPORT_PROTOCOL_UDP => 'UDP', + TRANSPORT_PROTOCOL_TCP => 'TCP', + TRANSPORT_PROTOCOL_TLS => 'TLS' + }.freeze + DUMP_LEVEL_DISABLED = 0 DUMP_LEVEL_CAPTURE_SIP = 1 DUMP_LEVEL_CAPTURE_RTP = 2 @@ -183,6 +188,29 @@ class CustomersAuth < ApplicationRecord PAI_POLICY_REQUIRE => 'Require' }.freeze + DST_NUMBER_FIELD_RURI_USERPART = 1 + DST_NUMBER_FIELD_TO_USERPART = 2 + DST_NUMBER_FIELD_DIVERSION_USERPART = 3 + DST_NUMBER_FIELDS = { + DST_NUMBER_FIELD_RURI_USERPART => 'R-URI userpart', + DST_NUMBER_FIELD_TO_USERPART => 'To URI userpart', + DST_NUMBER_FIELD_DIVERSION_USERPART => 'Top Diversion header userpart' + }.freeze + + SRC_NUMBER_FIELD_FROM_USERPART = 1 + SRC_NUMBER_FIELD_FROM_DSP = 2 + SRC_NUMBER_FIELDS = { + SRC_NUMBER_FIELD_FROM_USERPART => 'From URI userpart', + SRC_NUMBER_FIELD_FROM_DSP => 'From URI display name' + }.freeze + + SRC_NAME_FIELD_FROM_DSP = 1 + SRC_NAME_FIELD_FROM_USERPART = 2 + SRC_NAME_FIELDS = { + SRC_NAME_FIELD_FROM_DSP => 'From URI display name', + SRC_NAME_FIELD_FROM_USERPART => 'From URI userpart' + }.freeze + module CONST MATCH_CONDITION_ATTRIBUTES = %i[ip src_prefix @@ -211,15 +239,10 @@ module CONST belongs_to :src_numberlist, class_name: 'Routing::Numberlist', foreign_key: :src_numberlist_id, optional: true belongs_to :radius_auth_profile, class_name: 'Equipment::Radius::AuthProfile', foreign_key: :radius_auth_profile_id, optional: true belongs_to :radius_accounting_profile, class_name: 'Equipment::Radius::AccountingProfile', foreign_key: :radius_accounting_profile_id, optional: true - belongs_to :transport_protocol, class_name: 'Equipment::TransportProtocol', foreign_key: :transport_protocol_id, optional: true belongs_to :tag_action, class_name: 'Routing::TagAction', optional: true belongs_to :lua_script, class_name: 'System::LuaScript', foreign_key: :lua_script_id, optional: true - belongs_to :dst_number_field, class_name: 'Routing::CustomerAuthDstNumberField', foreign_key: :dst_number_field_id - belongs_to :src_number_field, class_name: 'Routing::CustomerAuthSrcNumberField', foreign_key: :src_number_field_id - belongs_to :src_name_field, class_name: 'Routing::CustomerAuthSrcNameField', foreign_key: :src_name_field_id - belongs_to :cnam_database, class_name: 'Cnam::Database', foreign_key: :cnam_database_id, optional: true array_belongs_to :tag_action_values, class_name: 'Routing::RoutingTag', foreign_key: :tag_action_value @@ -257,8 +280,6 @@ module CONST validate :validate_account validate :validate_gateway - validates :src_name_field, :src_number_field, :dst_number_field, presence: true - validates :dst_number_min_length, :dst_number_max_length, :src_number_min_length, :src_number_max_length, presence: true validates :src_number_min_length, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 100, allow_nil: false, only_integer: true } validates :src_number_max_length, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 100, allow_nil: false, only_integer: true } @@ -280,6 +301,14 @@ module CONST validate :validate_rewrite_ss_status validates :privacy_mode_id, inclusion: { in: PRIVACY_MODES.keys }, allow_nil: false + validates :src_name_field_id, :src_number_field_id, :dst_number_field_id, presence: true + + validates :src_name_field_id, inclusion: { in: CustomersAuth::SRC_NAME_FIELDS.keys }, allow_nil: false + validates :src_number_field_id, inclusion: { in: CustomersAuth::SRC_NUMBER_FIELDS.keys }, allow_nil: false + validates :dst_number_field_id, inclusion: { in: CustomersAuth::DST_NUMBER_FIELDS.keys }, allow_nil: false + + validates :transport_protocol_id, inclusion: { in: CustomersAuth::TRANSPORT_PROTOCOLS.keys }, allow_nil: true + validates_with TagActionValueValidator include Yeti::StateUpdater @@ -321,6 +350,10 @@ def display_name "#{name} | #{id}" end + def transport_protocol_name + transport_protocol_id.nil? ? 'Any' : TRANSPORT_PROTOCOLS[transport_protocol_id] + end + def dump_level_name dump_level_id.nil? ? DUMP_LEVELS[0] : DUMP_LEVELS[dump_level_id] end @@ -349,6 +382,18 @@ def diversion_policy_name DIVERSION_POLICIES[diversion_policy_id] end + def dst_number_field_name + DST_NUMBER_FIELDS[dst_number_field_id] + end + + def src_number_field_name + SRC_NUMBER_FIELDS[src_number_field_id] + end + + def src_name_field_name + SRC_NAME_FIELDS[src_name_field_id] + end + # TODO: move to decorator when ActiveAdmin fix problem # Problem is: # on "update" AA uses decorated object diff --git a/app/models/importing/customers_auth.rb b/app/models/importing/customers_auth.rb index 41dccbf6a..7cd24a8c4 100644 --- a/app/models/importing/customers_auth.rb +++ b/app/models/importing/customers_auth.rb @@ -14,7 +14,7 @@ # diversion_policy_name :string # diversion_rewrite_result :string # diversion_rewrite_rule :string -# dst_number_field_name :integer(2) +# dst_number_field_name :string # dst_number_max_length :integer(4) # dst_number_min_length :integer(4) # dst_number_radius_rewrite_result :string @@ -48,7 +48,7 @@ # routing_group_name :string # routing_plan_name :string # send_billing_information :boolean default(FALSE), not null -# src_name_field_name :integer(2) +# src_name_field_name :string # src_name_rewrite_result :string # src_name_rewrite_rule :string # src_number_field_name :string @@ -106,7 +106,6 @@ class Importing::CustomersAuth < Importing::Base belongs_to :src_numberlist, class_name: '::Routing::Numberlist', foreign_key: :src_numberlist_id, optional: true belongs_to :radius_auth_profile, class_name: '::Equipment::Radius::AuthProfile', foreign_key: :radius_auth_profile_id, optional: true belongs_to :radius_accounting_profile, class_name: '::Equipment::Radius::AccountingProfile', foreign_key: :radius_accounting_profile_id, optional: true - belongs_to :transport_protocol, class_name: 'Equipment::TransportProtocol', foreign_key: :transport_protocol_id, optional: true belongs_to :tag_action, class_name: 'Routing::TagAction', optional: true belongs_to :lua_script, class_name: 'System::LuaScript', foreign_key: :lua_script_id, optional: true @@ -163,6 +162,10 @@ class Importing::CustomersAuth < Importing::Base import_for ::CustomersAuth + def transport_protocol_display_name + transport_protocol_id.nil? ? 'Any' : CustomersAuth::TRANSPORT_PROTOCOLS[transport_protocol_id] + end + def dump_level_display_name dump_level_id.nil? ? 'unknown' : CustomersAuth::DUMP_LEVELS[dump_level_id] end @@ -179,10 +182,14 @@ def self.after_import_hook where(src_prefix: nil).update_all(src_prefix: '') where(dst_prefix: nil).update_all(dst_prefix: '') resolve_array_of_tags('tag_action_value', 'tag_action_value_names') + resolve_integer_constant('transport_protocol_id', 'transport_protocol_name', CustomersAuth::TRANSPORT_PROTOCOLS) resolve_integer_constant('dump_level_id', 'dump_level_name', CustomersAuth::DUMP_LEVELS) resolve_integer_constant('privacy_mode_id', 'privacy_mode_name', CustomersAuth::PRIVACY_MODES) resolve_integer_constant('diversion_policy_id', 'diversion_policy_name', CustomersAuth::DIVERSION_POLICIES) resolve_integer_constant('pai_policy_id', 'pai_policy_name', CustomersAuth::PAI_POLICIES) + resolve_integer_constant('src_name_field_id', 'src_name_field_name', CustomersAuth::SRC_NAME_FIELDS) + resolve_integer_constant('src_number_field_id', 'src_number_field_name', CustomersAuth::SRC_NUMBER_FIELDS) + resolve_integer_constant('dst_number_field_id', 'dst_number_field_name', CustomersAuth::DST_NUMBER_FIELDS) super CustomersAuth.increment_state_value end diff --git a/app/models/routing/customer_auth_dst_number_field.rb b/app/models/routing/customer_auth_dst_number_field.rb deleted file mode 100644 index 686ab07e2..000000000 --- a/app/models/routing/customer_auth_dst_number_field.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# == Schema Information -# -# Table name: class4.customers_auth_dst_number_fields -# -# id :integer(2) not null, primary key -# name :string not null -# -# Indexes -# -# customers_auth_dst_number_fields_name_key (name) UNIQUE -# -class Routing::CustomerAuthDstNumberField < ApplicationRecord - self.table_name = 'class4.customers_auth_dst_number_fields' - - validates :name, presence: true, uniqueness: true - - def display_name - name.to_s - end -end diff --git a/app/models/routing/customer_auth_src_name_field.rb b/app/models/routing/customer_auth_src_name_field.rb deleted file mode 100644 index 714ebb419..000000000 --- a/app/models/routing/customer_auth_src_name_field.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# == Schema Information -# -# Table name: class4.customers_auth_src_name_fields -# -# id :integer(2) not null, primary key -# name :string not null -# -# Indexes -# -# customers_auth_src_name_fields_name_key (name) UNIQUE -# -class Routing::CustomerAuthSrcNameField < ApplicationRecord - self.table_name = 'class4.customers_auth_src_name_fields' - - validates :name, presence: true, uniqueness: true - - def display_name - name.to_s - end -end diff --git a/app/models/routing/customer_auth_src_number_field.rb b/app/models/routing/customer_auth_src_number_field.rb deleted file mode 100644 index 31f212974..000000000 --- a/app/models/routing/customer_auth_src_number_field.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# == Schema Information -# -# Table name: class4.customers_auth_src_number_fields -# -# id :integer(2) not null, primary key -# name :string not null -# -# Indexes -# -# customers_auth_src_number_fields_name_key (name) UNIQUE -# -class Routing::CustomerAuthSrcNumberField < ApplicationRecord - self.table_name = 'class4.customers_auth_src_number_fields' - - validates :name, presence: true, uniqueness: true - - def display_name - name.to_s - end -end diff --git a/app/resources/api/rest/admin/customers_auth_resource.rb b/app/resources/api/rest/admin/customers_auth_resource.rb index 995a7a0ce..e58f2ea47 100644 --- a/app/resources/api/rest/admin/customers_auth_resource.rb +++ b/app/resources/api/rest/admin/customers_auth_resource.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Api::Rest::Admin::CustomersAuthResource < BaseResource - attributes :name, :ip, :enabled, :reject_calls, :src_rewrite_rule, :src_rewrite_result, :dst_rewrite_rule, :dst_rewrite_result, + attributes :name, :transport_protocol_id, :ip, :enabled, :reject_calls, :src_rewrite_rule, :src_rewrite_result, :dst_rewrite_rule, :dst_rewrite_result, :src_prefix, :src_number_min_length, :src_number_max_length, :dst_prefix, :dst_number_min_length, :dst_number_max_length, :x_yeti_auth, :capacity, :cps_limit, :uri_domain, @@ -24,7 +24,6 @@ class Api::Rest::Admin::CustomersAuthResource < BaseResource has_one :tag_action, class_name: 'TagAction', always_include_linkage_data: true has_one :radius_auth_profile, class_name: 'RadiusAuthProfile', always_include_linkage_data: true has_one :radius_accounting_profile, class_name: 'RadiusAccountingProfile', always_include_linkage_data: true - has_one :transport_protocol, class_name: 'TransportProtocol', always_include_linkage_data: true filter :name @@ -39,15 +38,21 @@ class Api::Rest::Admin::CustomersAuthResource < BaseResource relationship_filter :tag_action relationship_filter :radius_auth_profile relationship_filter :radius_accounting_profile - relationship_filter :transport_protocol ransack_filter :name, type: :string ransack_filter :enabled, type: :boolean ransack_filter :reject_calls, type: :boolean + + ransack_filter :src_name_field_id, type: :number + ransack_filter :src_name_rewrite_rule, type: :string + ransack_filter :src_name_rewrite_result, type: :string + ransack_filter :src_number_field_id, type: :number ransack_filter :src_rewrite_rule, type: :string ransack_filter :src_rewrite_result, type: :string + ransack_filter :dst_number_field_id, type: :number ransack_filter :dst_rewrite_rule, type: :string ransack_filter :dst_rewrite_result, type: :string + ransack_filter :src_prefix, type: :string ransack_filter :src_number_min_length, type: :number ransack_filter :src_number_max_length, type: :number @@ -58,8 +63,7 @@ class Api::Rest::Admin::CustomersAuthResource < BaseResource ransack_filter :capacity, type: :number ransack_filter :cps_limit, type: :number ransack_filter :uri_domain, type: :string - ransack_filter :src_name_rewrite_rule, type: :string - ransack_filter :src_name_rewrite_result, type: :string + ransack_filter :diversion_policy_id, type: :number ransack_filter :diversion_rewrite_rule, type: :string ransack_filter :diversion_rewrite_result, type: :string @@ -77,6 +81,7 @@ class Api::Rest::Admin::CustomersAuthResource < BaseResource ransack_filter :tag_action_value, type: :number ransack_filter :external_id, type: :number ransack_filter :external_type, type: :string + ransack_filter :transport_protocol_id, type: :number ransack_filter :dump_level_id, type: :number def self.updatable_fields(_context) @@ -89,8 +94,10 @@ def self.updatable_fields(_context) ip account gateway + src_number_field_id src_rewrite_rule src_rewrite_result + dst_number_field_id dst_rewrite_rule dst_rewrite_result src_prefix @@ -106,6 +113,7 @@ def self.updatable_fields(_context) cps_limit pop uri_domain + src_name_field_id src_name_rewrite_rule src_name_rewrite_result diversion_policy diff --git a/db/migrate/20241215155451_remove_customer_auth_number_fields.rb b/db/migrate/20241215155451_remove_customer_auth_number_fields.rb new file mode 100644 index 000000000..0933c6141 --- /dev/null +++ b/db/migrate/20241215155451_remove_customer_auth_number_fields.rb @@ -0,0 +1,57 @@ +class RemoveCustomerAuthNumberFields < ActiveRecord::Migration[7.0] + def up + execute %q{ + alter table class4.customers_auth + drop constraint "customers_auth_dst_number_field_id_fkey", + drop constraint "customers_auth_src_number_field_id_fkey", + drop constraint "customers_auth_src_name_field_id_fkey", + drop constraint "customers_auth_transport_protocol_id_fkey"; + + drop table class4.customers_auth_src_name_fields; + drop table class4.customers_auth_src_number_fields; + drop table class4.customers_auth_dst_number_fields; + + delete from data_import.import_customers_auth; + alter table data_import.import_customers_auth + alter column src_name_field_name type varchar, + alter column dst_number_field_name type varchar; + } + end + + def down + execute %q{ + create table class4.customers_auth_src_name_fields ( + id smallint PRIMARY KEY, + name varchar not null unique + ); + insert into class4.customers_auth_src_name_fields(id,name) values(1,'From header display name'); + insert into class4.customers_auth_src_name_fields(id,name) values(2,'From header userpart'); + + create table class4.customers_auth_src_number_fields ( + id smallint PRIMARY KEY, + name varchar not null unique + ); + insert into class4.customers_auth_src_number_fields(id,name) values(1,'From header userpart'); + insert into class4.customers_auth_src_number_fields(id,name) values(2,'From header display name'); + + create table class4.customers_auth_dst_number_fields ( + id smallint PRIMARY KEY, + name varchar not null unique + ); + insert into class4.customers_auth_dst_number_fields(id,name) values(1,'R-URI userpart'); + insert into class4.customers_auth_dst_number_fields(id,name) values(2,'To URI userpart'); + insert into class4.customers_auth_dst_number_fields(id,name) values(3,'Top Diversion header userpart'); + + alter table class4.customers_auth + add constraint "customers_auth_dst_number_field_id_fkey" FOREIGN KEY (dst_number_field_id) REFERENCES class4.customers_auth_dst_number_fields(id), + add constraint "customers_auth_src_name_field_id_fkey" FOREIGN KEY (src_name_field_id) REFERENCES class4.customers_auth_src_name_fields(id), + add constraint "customers_auth_src_number_field_id_fkey" FOREIGN KEY (src_number_field_id) REFERENCES class4.customers_auth_src_number_fields(id), + add constraint "customers_auth_transport_protocol_id_fkey" FOREIGN KEY (transport_protocol_id) REFERENCES class4.transport_protocols(id); + + delete from data_import.import_customers_auth; + alter table data_import.import_customers_auth + alter column src_name_field_name type smallint USING src_name_field_name::smallint, + alter column dst_number_field_name type smallint USING dst_number_field_name::smallint; + } + end +end diff --git a/db/seeds/main/class4.sql b/db/seeds/main/class4.sql index 7e672babb..d737d9fbd 100644 --- a/db/seeds/main/class4.sql +++ b/db/seeds/main/class4.sql @@ -861,14 +861,5 @@ insert into class4.gateway_group_balancing_modes(id,name) values(2,'Priority/Wei insert into class4.gateway_group_balancing_modes(id,name) values(3,'Priority/Weigth balancing. Exclude gateways from other POPs'); -insert into class4.customers_auth_src_number_fields(id,name) values(1,'From header userpart'); -insert into class4.customers_auth_src_number_fields(id,name) values(2,'From header display name'); - -insert into class4.customers_auth_src_name_fields(id,name) values(1,'From header display name'); - -insert into class4.customers_auth_dst_number_fields(id,name) values(1,'R-URI userpart'); -insert into class4.customers_auth_dst_number_fields(id,name) values(2,'To URI userpart'); -insert into class4.customers_auth_dst_number_fields(id,name) values(3,'Top Diversion header userpart'); - insert into class4.lnp_databases_30x_redirect_formats(id, name) values (1,'Contact URI username rn parameter'); insert into class4.lnp_databases_30x_redirect_formats(id, name) values (2,'Contact URI username'); diff --git a/db/structure.sql b/db/structure.sql index 729c2f03d..8b158c228 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -40824,16 +40824,6 @@ CREATE TABLE class4.customers_auth ( ); --- --- Name: customers_auth_dst_number_fields; Type: TABLE; Schema: class4; Owner: - --- - -CREATE TABLE class4.customers_auth_dst_number_fields ( - id smallint NOT NULL, - name character varying NOT NULL -); - - -- -- Name: customers_auth_id_seq; Type: SEQUENCE; Schema: class4; Owner: - -- @@ -40955,26 +40945,6 @@ CREATE SEQUENCE class4.customers_auth_normalized_id_seq ALTER SEQUENCE class4.customers_auth_normalized_id_seq OWNED BY class4.customers_auth_normalized.id; --- --- Name: customers_auth_src_name_fields; Type: TABLE; Schema: class4; Owner: - --- - -CREATE TABLE class4.customers_auth_src_name_fields ( - id smallint NOT NULL, - name character varying NOT NULL -); - - --- --- Name: customers_auth_src_number_fields; Type: TABLE; Schema: class4; Owner: - --- - -CREATE TABLE class4.customers_auth_src_number_fields ( - id smallint NOT NULL, - name character varying NOT NULL -); - - -- -- Name: destination_next_rates; Type: TABLE; Schema: class4; Owner: - -- @@ -42607,9 +42577,9 @@ CREATE TABLE data_import.import_customers_auth ( src_number_field_id smallint, src_number_field_name character varying, src_name_field_id smallint, - src_name_field_name smallint, + src_name_field_name character varying, dst_number_field_id smallint, - dst_number_field_name smallint, + dst_number_field_name character varying, cps_limit double precision, privacy_mode_id smallint, privacy_mode_name character varying, @@ -46426,22 +46396,6 @@ ALTER TABLE ONLY class4.codecs ADD CONSTRAINT codecs_pkey PRIMARY KEY (id); --- --- Name: customers_auth_dst_number_fields customers_auth_dst_number_fields_name_key; Type: CONSTRAINT; Schema: class4; Owner: - --- - -ALTER TABLE ONLY class4.customers_auth_dst_number_fields - ADD CONSTRAINT customers_auth_dst_number_fields_name_key UNIQUE (name); - - --- --- Name: customers_auth_dst_number_fields customers_auth_dst_number_fields_pkey; Type: CONSTRAINT; Schema: class4; Owner: - --- - -ALTER TABLE ONLY class4.customers_auth_dst_number_fields - ADD CONSTRAINT customers_auth_dst_number_fields_pkey PRIMARY KEY (id); - - -- -- Name: customers_auth customers_auth_name_key; Type: CONSTRAINT; Schema: class4; Owner: - -- @@ -46466,38 +46420,6 @@ ALTER TABLE ONLY class4.customers_auth ADD CONSTRAINT customers_auth_pkey PRIMARY KEY (id); --- --- Name: customers_auth_src_name_fields customers_auth_src_name_fields_name_key; Type: CONSTRAINT; Schema: class4; Owner: - --- - -ALTER TABLE ONLY class4.customers_auth_src_name_fields - ADD CONSTRAINT customers_auth_src_name_fields_name_key UNIQUE (name); - - --- --- Name: customers_auth_src_name_fields customers_auth_src_name_fields_pkey; Type: CONSTRAINT; Schema: class4; Owner: - --- - -ALTER TABLE ONLY class4.customers_auth_src_name_fields - ADD CONSTRAINT customers_auth_src_name_fields_pkey PRIMARY KEY (id); - - --- --- Name: customers_auth_src_number_fields customers_auth_src_number_fields_name_key; Type: CONSTRAINT; Schema: class4; Owner: - --- - -ALTER TABLE ONLY class4.customers_auth_src_number_fields - ADD CONSTRAINT customers_auth_src_number_fields_name_key UNIQUE (name); - - --- --- Name: customers_auth_src_number_fields customers_auth_src_number_fields_pkey; Type: CONSTRAINT; Schema: class4; Owner: - --- - -ALTER TABLE ONLY class4.customers_auth_src_number_fields - ADD CONSTRAINT customers_auth_src_number_fields_pkey PRIMARY KEY (id); - - -- -- Name: destination_next_rates destination_next_rates_pkey; Type: CONSTRAINT; Schema: class4; Owner: - -- @@ -49020,14 +48942,6 @@ ALTER TABLE ONLY class4.customers_auth ADD CONSTRAINT customers_auth_dst_blacklist_id_fkey FOREIGN KEY (dst_numberlist_id) REFERENCES class4.numberlists(id); --- --- Name: customers_auth customers_auth_dst_number_field_id_fkey; Type: FK CONSTRAINT; Schema: class4; Owner: - --- - -ALTER TABLE ONLY class4.customers_auth - ADD CONSTRAINT customers_auth_dst_number_field_id_fkey FOREIGN KEY (dst_number_field_id) REFERENCES class4.customers_auth_dst_number_fields(id); - - -- -- Name: customers_auth customers_auth_gateway_id_fkey; Type: FK CONSTRAINT; Schema: class4; Owner: - -- @@ -49100,22 +49014,6 @@ ALTER TABLE ONLY class4.customers_auth ADD CONSTRAINT customers_auth_src_blacklist_id_fkey FOREIGN KEY (src_numberlist_id) REFERENCES class4.numberlists(id); --- --- Name: customers_auth customers_auth_src_name_field_id_fkey; Type: FK CONSTRAINT; Schema: class4; Owner: - --- - -ALTER TABLE ONLY class4.customers_auth - ADD CONSTRAINT customers_auth_src_name_field_id_fkey FOREIGN KEY (src_name_field_id) REFERENCES class4.customers_auth_src_name_fields(id); - - --- --- Name: customers_auth customers_auth_src_number_field_id_fkey; Type: FK CONSTRAINT; Schema: class4; Owner: - --- - -ALTER TABLE ONLY class4.customers_auth - ADD CONSTRAINT customers_auth_src_number_field_id_fkey FOREIGN KEY (src_number_field_id) REFERENCES class4.customers_auth_src_number_fields(id); - - -- -- Name: customers_auth customers_auth_tag_action_id_fkey; Type: FK CONSTRAINT; Schema: class4; Owner: - -- @@ -49124,14 +49022,6 @@ ALTER TABLE ONLY class4.customers_auth ADD CONSTRAINT customers_auth_tag_action_id_fkey FOREIGN KEY (tag_action_id) REFERENCES class4.tag_actions(id); --- --- Name: customers_auth customers_auth_transport_protocol_id_fkey; Type: FK CONSTRAINT; Schema: class4; Owner: - --- - -ALTER TABLE ONLY class4.customers_auth - ADD CONSTRAINT customers_auth_transport_protocol_id_fkey FOREIGN KEY (transport_protocol_id) REFERENCES class4.transport_protocols(id); - - -- -- Name: destination_next_rates destination_next_rates_destination_id_fkey; Type: FK CONSTRAINT; Schema: class4; Owner: - -- @@ -50225,6 +50115,7 @@ INSERT INTO "public"."schema_migrations" (version) VALUES ('20241017124729'), ('20241107212537'), ('20241213172819'), -('20241213175248'); +('20241213175248'), +('20241215155451'); diff --git a/spec/factories/customers_auths.rb b/spec/factories/customers_auths.rb index bbbf1d9fd..43aa7f190 100644 --- a/spec/factories/customers_auths.rb +++ b/spec/factories/customers_auths.rb @@ -91,7 +91,6 @@ # customers_auth_cnam_database_id_fkey (cnam_database_id => cnam_databases.id) # customers_auth_customer_id_fkey (customer_id => contractors.id) # customers_auth_dst_blacklist_id_fkey (dst_numberlist_id => numberlists.id) -# customers_auth_dst_number_field_id_fkey (dst_number_field_id => customers_auth_dst_number_fields.id) # customers_auth_gateway_id_fkey (gateway_id => gateways.id) # customers_auth_lua_script_id_fkey (lua_script_id => lua_scripts.id) # customers_auth_pop_id_fkey (pop_id => pops.id) @@ -100,10 +99,7 @@ # customers_auth_rateplan_id_fkey (rateplan_id => rateplans.id) # customers_auth_routing_plan_id_fkey (routing_plan_id => routing_plans.id) # customers_auth_src_blacklist_id_fkey (src_numberlist_id => numberlists.id) -# customers_auth_src_name_field_id_fkey (src_name_field_id => customers_auth_src_name_fields.id) -# customers_auth_src_number_field_id_fkey (src_number_field_id => customers_auth_src_number_fields.id) # customers_auth_tag_action_id_fkey (tag_action_id => tag_actions.id) -# customers_auth_transport_protocol_id_fkey (transport_protocol_id => transport_protocols.id) # FactoryBot.define do factory :customers_auth, class: 'CustomersAuth' do diff --git a/spec/factories/importing/customers_auths.rb b/spec/factories/importing/customers_auths.rb index c71ae9ea0..06c4f3692 100644 --- a/spec/factories/importing/customers_auths.rb +++ b/spec/factories/importing/customers_auths.rb @@ -14,7 +14,7 @@ # diversion_policy_name :string # diversion_rewrite_result :string # diversion_rewrite_rule :string -# dst_number_field_name :integer(2) +# dst_number_field_name :string # dst_number_max_length :integer(4) # dst_number_min_length :integer(4) # dst_number_radius_rewrite_result :string @@ -48,7 +48,7 @@ # routing_group_name :string # routing_plan_name :string # send_billing_information :boolean default(FALSE), not null -# src_name_field_name :integer(2) +# src_name_field_name :string # src_name_rewrite_result :string # src_name_rewrite_rule :string # src_number_field_name :string diff --git a/spec/features/routing/customers_auths/export_customers_auth_spec.rb b/spec/features/routing/customers_auths/export_customers_auth_spec.rb index cd4ca0602..de7ca0f36 100644 --- a/spec/features/routing/customers_auths/export_customers_auth_spec.rb +++ b/spec/features/routing/customers_auths/export_customers_auth_spec.rb @@ -9,7 +9,7 @@ let!(:item) do create(:customers_auth, - transport_protocol: Equipment::TransportProtocol.take, + transport_protocol_id: CustomersAuth::TRANSPORT_PROTOCOL_TCP, pop: create(:pop), dst_numberlist: create(:numberlist), src_numberlist: create(:numberlist), @@ -44,7 +44,7 @@ ['Enabled', item.enabled.to_s, anything], ['Reject calls', item.reject_calls.to_s, anything], ['Name', item.name, anything], - ['Transport protocol name', item.transport_protocol.name, anything], + ['Transport protocol name', item.transport_protocol_name, anything], ['IP', item.ip.join(', '), anything], ['Pop name', item.pop.name, anything], ['SRC Prefix', item.src_prefix.join(', '), anything], @@ -80,13 +80,13 @@ ['Pai policy name', item.pai_policy_name, anything], ['Pai rewrite rule', item.pai_rewrite_rule.to_s, anything], ['Pai rewrite result', item.pai_rewrite_result.to_s, anything], - ['Src name field name', item.src_name_field.name, anything], + ['Src name field name', item.src_name_field_name, anything], ['Src name rewrite rule', item.src_name_rewrite_rule.to_s, anything], ['Src name rewrite result', item.src_name_rewrite_result.to_s, anything], - ['Src number field name', item.src_number_field.name, anything], + ['Src number field name', item.src_number_field_name, anything], ['Src rewrite rule', item.src_rewrite_rule.to_s, anything], ['Src rewrite result', item.src_rewrite_result.to_s, anything], - ['Dst number field name', item.dst_number_field.name, anything], + ['Dst number field name', item.dst_number_field_name, anything], ['Dst rewrite rule', item.dst_rewrite_rule.to_s, anything], ['Dst rewrite result', item.dst_rewrite_result.to_s, anything], ['Lua script name', item.lua_script.name, anything], diff --git a/spec/fixtures/class4.customers_auth_dst_number_fields.yml b/spec/fixtures/class4.customers_auth_dst_number_fields.yml deleted file mode 100644 index 5c6eb3db0..000000000 --- a/spec/fixtures/class4.customers_auth_dst_number_fields.yml +++ /dev/null @@ -1,17 +0,0 @@ -# == Schema Information -# -# Table name: class4.customers_auth_dst_number_fields -# -# id :integer(2) not null, primary key -# name :string not null -# -# Indexes -# -# customers_auth_dst_number_fields_name_key (name) UNIQUE -# -el_1: - id: 1 - name: R-URI userpart -el_2: - id: 2 - name: To URI userpart diff --git a/spec/fixtures/class4.customers_auth_src_name_fields.yml b/spec/fixtures/class4.customers_auth_src_name_fields.yml deleted file mode 100644 index f7f2cd030..000000000 --- a/spec/fixtures/class4.customers_auth_src_name_fields.yml +++ /dev/null @@ -1,20 +0,0 @@ -# == Schema Information -# -# Table name: class4.customers_auth_src_name_fields -# -# id :integer(2) not null, primary key -# name :string not null -# -# Indexes -# -# customers_auth_src_name_fields_name_key (name) UNIQUE -# -el_1: - id: 1 - name: From header userpart -el_2: - id: 2 - name: P-Preferred-Identity header userpart -el_3: - id: 3 - name: P-Asserted-Identity header userpart diff --git a/spec/fixtures/class4.customers_auth_src_number_fields.yml b/spec/fixtures/class4.customers_auth_src_number_fields.yml deleted file mode 100644 index ae3e9788f..000000000 --- a/spec/fixtures/class4.customers_auth_src_number_fields.yml +++ /dev/null @@ -1,20 +0,0 @@ -# == Schema Information -# -# Table name: class4.customers_auth_src_number_fields -# -# id :integer(2) not null, primary key -# name :string not null -# -# Indexes -# -# customers_auth_src_number_fields_name_key (name) UNIQUE -# -el_1: - id: 1 - name: From header userpart -el_2: - id: 2 - name: P-Preferred-Identity header userpart -el_3: - id: 3 - name: P-Asserted-Identity header userpart diff --git a/spec/models/customers_auth_spec.rb b/spec/models/customers_auth_spec.rb index 4f463fbc5..d83ab9109 100644 --- a/spec/models/customers_auth_spec.rb +++ b/spec/models/customers_auth_spec.rb @@ -91,7 +91,6 @@ # customers_auth_cnam_database_id_fkey (cnam_database_id => cnam_databases.id) # customers_auth_customer_id_fkey (customer_id => contractors.id) # customers_auth_dst_blacklist_id_fkey (dst_numberlist_id => numberlists.id) -# customers_auth_dst_number_field_id_fkey (dst_number_field_id => customers_auth_dst_number_fields.id) # customers_auth_gateway_id_fkey (gateway_id => gateways.id) # customers_auth_lua_script_id_fkey (lua_script_id => lua_scripts.id) # customers_auth_pop_id_fkey (pop_id => pops.id) @@ -100,10 +99,7 @@ # customers_auth_rateplan_id_fkey (rateplan_id => rateplans.id) # customers_auth_routing_plan_id_fkey (routing_plan_id => routing_plans.id) # customers_auth_src_blacklist_id_fkey (src_numberlist_id => numberlists.id) -# customers_auth_src_name_field_id_fkey (src_name_field_id => customers_auth_src_name_fields.id) -# customers_auth_src_number_field_id_fkey (src_number_field_id => customers_auth_src_number_fields.id) # customers_auth_tag_action_id_fkey (tag_action_id => tag_actions.id) -# customers_auth_transport_protocol_id_fkey (transport_protocol_id => transport_protocols.id) # RSpec.describe CustomersAuth, type: :model do diff --git a/spec/requests/api/rest/admin/customers_auth_spec.rb b/spec/requests/api/rest/admin/customers_auth_spec.rb index 5bab5aafe..042c7c31e 100644 --- a/spec/requests/api/rest/admin/customers_auth_spec.rb +++ b/spec/requests/api/rest/admin/customers_auth_spec.rb @@ -257,13 +257,13 @@ end context 'with filter by transport_protocol.id' do - let!(:transport_protocol) { Equipment::TransportProtocol.first } - let!(:other_transport_protocol) { Equipment::TransportProtocol.second } - let!(:customers_auths) { create_list(:customers_auth, 3, transport_protocol: transport_protocol) } - before { create(:customers_auth, transport_protocol: other_transport_protocol) } + let!(:transport_protocol_id) { CustomersAuth::TRANSPORT_PROTOCOL_UDP } + let!(:other_transport_protocol_id) { CustomersAuth::TRANSPORT_PROTOCOL_TCP } + let!(:customers_auths) { create_list(:customers_auth, 3, transport_protocol_id: transport_protocol_id) } + before { create(:customers_auth, transport_protocol_id: other_transport_protocol_id) } let(:request_params) do - { filter: { 'transport_protocol.id': transport_protocol.id } } + { filter: { 'transport_protocol_id_eq': transport_protocol_id } } end it 'returns filtered gateways by transport_protocol.id' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 80b0f5f4a..2e84dc238 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -70,9 +70,6 @@ :filter_types, :sdp_c_location, :codecs, - 'class4.customers_auth_dst_number_fields', - 'class4.customers_auth_src_number_fields', - 'class4.customers_auth_src_name_fields', 'class4.dtmf_send_modes', 'class4.dtmf_receive_modes', 'class4.gateway_rel100_modes', diff --git a/spec/sql/switch22/route_spec.rb b/spec/sql/switch22/route_spec.rb index f45465d30..fba62836e 100644 --- a/spec/sql/switch22/route_spec.rb +++ b/spec/sql/switch22/route_spec.rb @@ -552,8 +552,8 @@ def routing_sp let(:customer_auth_ss_dst_rewrite_rule) { nil } let(:customer_auth_ss_dst_rewrite_result) { nil } let(:customer_auth_privacy_mode_id) { CustomersAuth::PRIVACY_MODE_REJECT_ANONYMOUS } - let(:customer_auth_src_name_field_id) { 1 } - let(:customer_auth_src_number_field_id) { 1 } + let(:customer_auth_src_name_field_id) { CustomersAuth::SRC_NAME_FIELD_FROM_DSP } + let(:customer_auth_src_number_field_id) { CustomersAuth::SRC_NUMBER_FIELD_FROM_USERPART } let(:remote_ip) { '1.1.1.1' } let(:x_orig_ip) { '3.3.3.3' } @@ -943,7 +943,7 @@ def routing_sp let(:from_name) { 'from_username' } context 'From Display name' do - let!(:customer_auth_src_name_field_id) { 1 } + let!(:customer_auth_src_name_field_id) { CustomersAuth::SRC_NAME_FIELD_FROM_DSP } it 'routing OK ' do expect(subject.size).to eq(2) expect(subject.first[:src_name_in]).to eq('from_display_name') @@ -952,7 +952,7 @@ def routing_sp end context 'From Userpart' do - let!(:customer_auth_src_name_field_id) { 2 } + let!(:customer_auth_src_name_field_id) { CustomersAuth::SRC_NAME_FIELD_FROM_USERPART } it 'routing OK ' do expect(subject.size).to eq(2) expect(subject.first[:src_name_in]).to eq('from_username') @@ -965,8 +965,8 @@ def routing_sp let(:from_dsp) { 'from_display_name' } let(:from_name) { 'from_username' } - context 'From Display name' do - let!(:customer_auth_src_number_field_id) { 1 } + context 'From User part' do + let!(:customer_auth_src_number_field_id) { CustomersAuth::SRC_NUMBER_FIELD_FROM_USERPART } it 'routing OK ' do expect(subject.size).to eq(2) expect(subject.first[:src_prefix_in]).to eq('from_username') @@ -974,8 +974,8 @@ def routing_sp end end - context 'From Userpart' do - let!(:customer_auth_src_number_field_id) { 2 } + context 'From display name' do + let!(:customer_auth_src_number_field_id) { CustomersAuth::SRC_NUMBER_FIELD_FROM_DSP } it 'routing OK ' do expect(subject.size).to eq(2) expect(subject.first[:src_prefix_in]).to eq('from_display_name')