From a5d50274a775eb063cecbc41af60635fce0a522f Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Sun, 17 Nov 2024 15:36:13 +0200 Subject: [PATCH 1/2] normalize namespaces in Admin API --- .../admin/accounting_profiles_controller.rb | 4 + .../rest/admin/area_prefixes_controller.rb | 4 + .../api/rest/admin/areas_controller.rb | 4 + .../api/rest/admin/auth_logs_controller.rb | 4 + .../rest/admin/auth_profiles_controller.rb | 4 + ...oice_originated_destinations_controller.rb | 4 - .../invoice_originated_networks_controller.rb | 4 - .../billing/invoice_template_controller.rb | 4 - ...oice_terminated_destinations_controller.rb | 4 - .../invoice_terminated_networks_controller.rb | 4 - .../admin/billing/service_types_controller.rb | 4 - .../rest/admin/billing/services_controller.rb | 4 - .../admin/billing/transactions_controller.rb | 4 - .../rest/admin/cdr/auth_logs_controller.rb | 4 - .../admin/{cdr => }/cdr_exports_controller.rb | 4 +- .../rest/admin/{cdr => }/cdrs_controller.rb | 4 +- .../api/rest/admin/countries_controller.rb | 4 + .../destination_next_rates_controller.rb | 4 + .../api/rest/admin/destinations_controller.rb | 4 + .../admin/dtmf_receive_modes_controller.rb | 4 + .../rest/admin/dtmf_send_modes_controller.rb | 4 + ...gateway_diversion_send_modes_controller.rb | 4 - ..._inband_dtmf_filtering_modes_controller.rb | 4 - ...teway_media_encryption_modes_controller.rb | 4 - ..._network_protocol_priorities_controller.rb | 4 - .../radius/accounting_profiles_controller.rb | 4 - .../sip_options_probers_controller.rb | 4 - ...gateway_diversion_send_modes_controller.rb | 4 + ...inband_dtmf_filtering_modes_controller.rb} | 2 +- ...eway_media_encryption_modes_controller.rb} | 2 +- ..._network_protocol_priorities_controller.rb | 4 + .../admin/gateway_rel100_modes_controller.rb | 4 + ...ice_originated_destinations_controller.rb} | 2 +- .../invoice_originated_networks_controller.rb | 4 + .../admin/invoice_service_data_controller.rb | 4 + .../rest/admin/invoice_template_controller.rb | 4 + ...ice_terminated_destinations_controller.rb} | 2 +- .../invoice_terminated_networks_controller.rb | 4 + .../{billing => }/invoices_controller.rb | 2 +- .../rest/admin/network_types_controller.rb | 4 + .../api/rest/admin/networks_controller.rb | 4 + .../rest/admin/numberlist_items_controller.rb | 4 + .../api/rest/admin/numberlists_controller.rb | 4 + .../api/rest/admin/rate_groups_controller.rb | 4 + .../api/rest/admin/rateplans_controller.rb | 4 + .../rest/admin/registrations_controller.rb | 4 + .../routeset_discriminators_controller.rb | 4 + .../admin/routing/area_prefixes_controller.rb | 4 - .../rest/admin/routing/areas_controller.rb | 4 - .../destination_next_rates_controller.rb | 4 - .../admin/routing/destinations_controller.rb | 4 - .../routing/numberlist_items_controller.rb | 4 - .../admin/routing/numberlists_controller.rb | 4 - .../admin/routing/rate_groups_controller.rb | 4 - .../admin/routing/rateplans_controller.rb | 4 - .../routeset_discriminators_controller.rb | 4 - .../routing/routing_groups_controller.rb | 4 - .../routing_tag_detection_rules_controller.rb | 4 - .../routing/routing_tag_modes_controller.rb | 4 - .../admin/routing/routing_tags_controller.rb | 4 - .../admin/routing/tag_actions_controller.rb | 4 - .../rest/admin/routing_groups_controller.rb | 4 + ...routing_tag_detection_rules_controller.rb} | 2 +- .../admin/routing_tag_modes_controller.rb | 4 + .../api/rest/admin/routing_tags_controller.rb | 4 + .../rest/admin/sensor_levels_controller.rb | 4 + .../api/rest/admin/sensors_controller.rb | 4 + .../rest/admin/service_types_controller.rb | 4 + .../api/rest/admin/services_controller.rb | 4 + .../admin/sip_options_probers_controller.rb | 4 + .../rest/admin/smtp_connections_controller.rb | 4 + .../rest/admin/system/countries_controller.rb | 4 - .../system/dtmf_receive_modes_controller.rb | 4 - .../system/dtmf_send_modes_controller.rb | 4 - .../admin/system/network_types_controller.rb | 4 - .../rest/admin/system/networks_controller.rb | 4 - .../admin/system/sensor_levels_controller.rb | 4 - .../rest/admin/system/sensors_controller.rb | 4 - .../system/smtp_connections_controller.rb | 4 - .../rest/admin/system/timezones_controller.rb | 4 - .../api/rest/admin/tag_actions_controller.rb | 4 + .../api/rest/admin/timezones_controller.rb | 4 + .../api/rest/admin/transactions_controller.rb | 4 + .../admin/transport_protocols_controller.rb | 4 + app/forms/batch_update_form/base.rb | 2 +- .../api/rest/admin/account_resource.rb | 4 +- .../accounting_profile_resource.rb | 2 +- .../api/rest/admin/active_call_resource.rb | 6 +- .../{routing => }/area_prefix_resource.rb | 2 +- .../rest/admin/{routing => }/area_resource.rb | 2 +- .../rest/admin/{cdr => }/auth_log_resource.rb | 31 +-- .../radius => }/auth_profile_resource.rb | 2 +- .../admin/{cdr => }/cdr_export_resource.rb | 2 +- .../api/rest/admin/{cdr => }/cdr_resource.rb | 60 ++---- .../api/rest/admin/contractor_resource.rb | 2 +- .../admin/{system => }/country_resource.rb | 2 +- .../api/rest/admin/customers_auth_resource.rb | 14 +- .../destination_next_rate_resource.rb | 2 +- .../{routing => }/destination_resource.rb | 18 +- .../api/rest/admin/dialpeer_resource.rb | 6 +- .../dtmf_receive_mode_resource.rb | 2 +- .../{system => }/dtmf_send_mode_resource.rb | 2 +- .../gateway_diversion_send_mode_resource.rb | 2 +- ...way_inband_dtmf_filtering_mode_resource.rb | 2 +- .../gateway_media_encryption_mode_resource.rb | 2 +- ...eway_network_protocol_priority_resource.rb | 2 +- .../gateway_rel100_mode_resource.rb | 2 +- .../api/rest/admin/gateway_resource.rb | 26 +-- ...invoice_originated_destination_resource.rb | 2 +- .../invoice_originated_network_resource.rb | 2 +- .../admin/{billing => }/invoice_resource.rb | 2 +- .../invoice_service_datum_resource.rb | 2 +- .../invoice_template_resource.rb | 2 +- ...invoice_terminated_destination_resource.rb | 2 +- .../invoice_terminated_network_resource.rb | 2 +- .../admin/{system => }/network_resource.rb | 2 +- .../{system => }/network_type_resource.rb | 2 +- .../{routing => }/numberlist_item_resource.rb | 2 +- .../{routing => }/numberlist_resource.rb | 2 +- .../{routing => }/rate_group_resource.rb | 2 +- .../admin/{routing => }/rateplan_resource.rb | 2 +- .../{equipment => }/registration_resource.rb | 2 +- .../routeset_discriminator_resource.rb | 2 +- .../{routing => }/routing_group_resource.rb | 2 +- .../routing_tag_detection_rule_resource.rb | 2 +- .../routing_tag_mode_resource.rb | 2 +- .../{routing => }/routing_tag_resource.rb | 2 +- .../{system => }/sensor_level_resource.rb | 2 +- .../admin/{system => }/sensor_resource.rb | 2 +- .../admin/{billing => }/service_resource.rb | 2 +- .../{billing => }/service_type_resource.rb | 2 +- .../sip_options_prober_resource.rb | 2 +- .../{system => }/smtp_connection_resource.rb | 2 +- .../{routing => }/tag_action_resource.rb | 2 +- .../admin/{system => }/timezone_resource.rb | 2 +- .../{billing => }/transaction_resource.rb | 2 +- .../transport_protocol_resource.rb | 2 +- config/initializers/jsonapi_resources.rb | 90 --------- config/routes.rb | 128 ++++++------ .../radius => }/accounting_profiles_spec.rb | 12 +- .../api/{routing => }/area_prefixes_spec.rb | 8 +- .../rest/admin/api/{routing => }/area_spec.rb | 2 +- .../radius => }/auth_profiles_spec.rb | 12 +- .../admin/api/{cdr => }/cdr_exports_spec.rb | 4 +- .../rest/admin/api/{cdr => }/cdrs_spec.rb | 10 +- .../destination_next_rates_spec.rb | 12 +- .../api/{routing => }/destinations_spec.rb | 12 +- .../{system => }/dtmf_receive_modes_spec.rb | 6 +- .../api/{system => }/dtmf_send_modes_spec.rb | 6 +- ...ateway_inband_dtmf_filtering_modes_spec.rb | 6 +- .../gateway_media_encryption_modes_spec.rb | 6 +- ...ateway_network_protocol_priorities_spec.rb | 6 +- .../gateway_rel100_modes_spec.rb | 6 +- .../invoice_originated_destinations_spec.rb | 6 +- .../invoice_originated_networks_spec.rb | 6 +- .../invoice_service_data_spec.rb | 6 +- .../{billing => }/invoice_template_spec.rb | 12 +- .../invoice_terminated_destinations_spec.rb | 6 +- .../invoice_terminated_networks_spec.rb | 6 +- .../admin/api/{billing => }/invoices_spec.rb | 10 +- .../api/{system => }/network_types_spec.rb | 12 +- .../admin/api/{system => }/networks_spec.rb | 12 +- .../{routing => }/numberlist_items_spec.rb | 12 +- .../api/{routing => }/numberlists_spec.rb | 8 +- .../admin/api/{routing => }/rateplans_spec.rb | 12 +- .../routeset_discriminators_spec.rb | 12 +- .../api/{routing => }/routing_groups_spec.rb | 12 +- .../routing_tag_detection_rules_spec.rb | 8 +- .../{routing => }/routing_tag_modes_spec.rb | 2 +- .../api/{routing => }/routing_tags_spec.rb | 8 +- .../api/{system => }/sensor_levels_spec.rb | 6 +- .../admin/api/{system => }/sensors_spec.rb | 12 +- .../api/{billing => }/service_types_spec.rb | 12 +- .../admin/api/{billing => }/services_spec.rb | 10 +- .../sip_options_probers_spec.rb | 12 +- .../api/{system => }/smtp_connections_spec.rb | 12 +- .../api/{routing => }/tag_actions_spec.rb | 2 +- .../admin/api/{system => }/timezones_spec.rb | 6 +- .../transport_protocols_spec.rb | 6 +- .../{routing => }/area_prefixes_controller.rb | 2 +- .../{routing => }/areas_controller_spec.rb | 2 +- .../{cdr => }/auth_logs_controller_spec.rb | 8 +- .../admin/{cdr => }/cdrs_controller_spec.rb | 17 +- .../{system => }/countries_controller_spec.rb | 11 +- .../destination_next_rates_spec.rb | 2 +- .../destinations_controller_spec.rb | 2 +- .../dialpeer_next_rates_controller_spec.rb | 9 +- .../network_types_controller_spec.rb | 11 +- .../{system => }/networks_controller_spec.rb | 11 +- .../numberlist_items_controller_spec.rb | 2 +- .../numberlists_controller_spec.rb | 2 +- .../rateplans_controller_spec.rb | 11 +- .../routing_groups_controller_spec.rb | 11 +- ...ing_tag_detection_rules_controller_spec.rb | 2 +- .../routing_tag_modes_controller_spec.rb | 2 +- .../routing_tags_controller_spec.rb | 2 +- .../tag_actions_controller_spec.rb | 2 +- .../radius => }/accounting_profiles_spec.rb | 6 +- .../admin/{routing => }/area_prefixes_spec.rb | 6 +- .../rest/admin/{routing => }/areas_spec.rb | 6 +- .../rest/admin/{cdr => }/auth_logs_spec.rb | 6 +- .../radius => }/auth_profile_spec.rb | 6 +- .../rest/admin/{cdr => }/cdr_exports_spec.rb | 14 +- .../api/rest/admin/{cdr => }/cdrs_spec.rb | 10 +- .../rest/admin/{system => }/country_spec.rb | 6 +- ...pec.rb => destination_next_rates2_spec.rb} | 6 +- .../rest/admin/destination_next_rates_spec.rb | 14 +- .../api/rest/admin/destinations_spec.rb | 187 ++++++++++++++++++ .../{system => }/dtmf_receive_modes_spec.rb | 6 +- .../{system => }/dtmf_send_modes_spec.rb | 6 +- .../gateway_diversion_send_modes_spec.rb | 6 +- ...ateway_inband_dtmf_filtering_modes_spec.rb | 6 +- .../gateway_media_encryption_modes_spec.rb | 6 +- ...ateway_network_protocol_priorities_spec.rb | 6 +- .../gateway_rel100_modes_spec.rb | 6 +- .../invoice_originated_destinations_spec.rb | 4 +- .../invoice_originated_networks_spec.rb | 4 +- .../invoice_service_data_spec.rb | 4 +- .../{billing => }/invoice_templates_spec.rb | 6 +- .../invoice_terminated_destinations_spec.rb | 4 +- .../invoice_terminated_networks_spec.rb | 4 +- .../rest/admin/{billing => }/invoices_spec.rb | 4 +- .../admin/{system => }/network_types_spec.rb | 6 +- .../rest/admin/{system => }/networks_spec.rb | 6 +- .../{routing => }/numberlist_items_spec.rb | 6 +- .../admin/{routing => }/numberlists_spec.rb | 6 +- .../admin/{routing => }/rateplans_spec.rb | 6 +- .../{equipment => }/registrations_spec.rb | 14 +- .../routeset_discriminators_spec.rb | 6 +- .../rest/admin/routing/destinations_spec.rb | 183 ----------------- .../{routing => }/routing_groups_spec.rb | 6 +- .../routing_tag_detection_rules_spec.rb | 6 +- .../{routing => }/routing_tag_modes_spec.rb | 6 +- .../admin/{routing => }/routing_tags_spec.rb | 6 +- .../admin/{system => }/sensor_levels_spec.rb | 6 +- .../rest/admin/{system => }/sensors_spec.rb | 6 +- .../sip_oprions_probers_spec.rb | 14 +- .../{system => }/smtp_connections_spec.rb | 6 +- .../admin/{routing => }/tag_action_spec.rb | 6 +- .../rest/admin/{system => }/timezones_spec.rb | 6 +- .../transport_protocols_spec.rb | 6 +- .../contexts/acceptance/acceptance_delete.rb | 8 +- .../acceptance/acceptance_index_show.rb | 8 +- .../json_api/json_api_admin_helpers.rb | 4 +- .../json_api/returns_json_api_record.rb | 5 +- 245 files changed, 853 insertions(+), 1060 deletions(-) create mode 100644 app/controllers/api/rest/admin/accounting_profiles_controller.rb create mode 100644 app/controllers/api/rest/admin/area_prefixes_controller.rb create mode 100644 app/controllers/api/rest/admin/areas_controller.rb create mode 100644 app/controllers/api/rest/admin/auth_logs_controller.rb create mode 100644 app/controllers/api/rest/admin/auth_profiles_controller.rb delete mode 100644 app/controllers/api/rest/admin/billing/invoice_originated_destinations_controller.rb delete mode 100644 app/controllers/api/rest/admin/billing/invoice_originated_networks_controller.rb delete mode 100644 app/controllers/api/rest/admin/billing/invoice_template_controller.rb delete mode 100644 app/controllers/api/rest/admin/billing/invoice_terminated_destinations_controller.rb delete mode 100644 app/controllers/api/rest/admin/billing/invoice_terminated_networks_controller.rb delete mode 100644 app/controllers/api/rest/admin/billing/service_types_controller.rb delete mode 100644 app/controllers/api/rest/admin/billing/services_controller.rb delete mode 100644 app/controllers/api/rest/admin/billing/transactions_controller.rb delete mode 100644 app/controllers/api/rest/admin/cdr/auth_logs_controller.rb rename app/controllers/api/rest/admin/{cdr => }/cdr_exports_controller.rb (83%) rename app/controllers/api/rest/admin/{cdr => }/cdrs_controller.rb (81%) create mode 100644 app/controllers/api/rest/admin/countries_controller.rb create mode 100644 app/controllers/api/rest/admin/destination_next_rates_controller.rb create mode 100644 app/controllers/api/rest/admin/destinations_controller.rb create mode 100644 app/controllers/api/rest/admin/dtmf_receive_modes_controller.rb create mode 100644 app/controllers/api/rest/admin/dtmf_send_modes_controller.rb delete mode 100644 app/controllers/api/rest/admin/equipment/gateway_diversion_send_modes_controller.rb delete mode 100644 app/controllers/api/rest/admin/equipment/gateway_inband_dtmf_filtering_modes_controller.rb delete mode 100644 app/controllers/api/rest/admin/equipment/gateway_media_encryption_modes_controller.rb delete mode 100644 app/controllers/api/rest/admin/equipment/gateway_network_protocol_priorities_controller.rb delete mode 100644 app/controllers/api/rest/admin/equipment/radius/accounting_profiles_controller.rb delete mode 100644 app/controllers/api/rest/admin/equipment/sip_options_probers_controller.rb create mode 100644 app/controllers/api/rest/admin/gateway_diversion_send_modes_controller.rb rename app/controllers/api/rest/admin/{equipment/radius/auth_profiles_controller.rb => gateway_inband_dtmf_filtering_modes_controller.rb} (52%) rename app/controllers/api/rest/admin/{billing/invoice_service_data_controller.rb => gateway_media_encryption_modes_controller.rb} (51%) create mode 100644 app/controllers/api/rest/admin/gateway_network_protocol_priorities_controller.rb create mode 100644 app/controllers/api/rest/admin/gateway_rel100_modes_controller.rb rename app/controllers/api/rest/admin/{equipment/gateway_rel100_modes_controller.rb => invoice_originated_destinations_controller.rb} (52%) create mode 100644 app/controllers/api/rest/admin/invoice_originated_networks_controller.rb create mode 100644 app/controllers/api/rest/admin/invoice_service_data_controller.rb create mode 100644 app/controllers/api/rest/admin/invoice_template_controller.rb rename app/controllers/api/rest/admin/{equipment/transport_protocols_controller.rb => invoice_terminated_destinations_controller.rb} (52%) create mode 100644 app/controllers/api/rest/admin/invoice_terminated_networks_controller.rb rename app/controllers/api/rest/admin/{billing => }/invoices_controller.rb (83%) create mode 100644 app/controllers/api/rest/admin/network_types_controller.rb create mode 100644 app/controllers/api/rest/admin/networks_controller.rb create mode 100644 app/controllers/api/rest/admin/numberlist_items_controller.rb create mode 100644 app/controllers/api/rest/admin/numberlists_controller.rb create mode 100644 app/controllers/api/rest/admin/rate_groups_controller.rb create mode 100644 app/controllers/api/rest/admin/rateplans_controller.rb create mode 100644 app/controllers/api/rest/admin/registrations_controller.rb create mode 100644 app/controllers/api/rest/admin/routeset_discriminators_controller.rb delete mode 100644 app/controllers/api/rest/admin/routing/area_prefixes_controller.rb delete mode 100644 app/controllers/api/rest/admin/routing/areas_controller.rb delete mode 100644 app/controllers/api/rest/admin/routing/destination_next_rates_controller.rb delete mode 100644 app/controllers/api/rest/admin/routing/destinations_controller.rb delete mode 100644 app/controllers/api/rest/admin/routing/numberlist_items_controller.rb delete mode 100644 app/controllers/api/rest/admin/routing/numberlists_controller.rb delete mode 100644 app/controllers/api/rest/admin/routing/rate_groups_controller.rb delete mode 100644 app/controllers/api/rest/admin/routing/rateplans_controller.rb delete mode 100644 app/controllers/api/rest/admin/routing/routeset_discriminators_controller.rb delete mode 100644 app/controllers/api/rest/admin/routing/routing_groups_controller.rb delete mode 100644 app/controllers/api/rest/admin/routing/routing_tag_detection_rules_controller.rb delete mode 100644 app/controllers/api/rest/admin/routing/routing_tag_modes_controller.rb delete mode 100644 app/controllers/api/rest/admin/routing/routing_tags_controller.rb delete mode 100644 app/controllers/api/rest/admin/routing/tag_actions_controller.rb create mode 100644 app/controllers/api/rest/admin/routing_groups_controller.rb rename app/controllers/api/rest/admin/{equipment/registrations_controller.rb => routing_tag_detection_rules_controller.rb} (50%) create mode 100644 app/controllers/api/rest/admin/routing_tag_modes_controller.rb create mode 100644 app/controllers/api/rest/admin/routing_tags_controller.rb create mode 100644 app/controllers/api/rest/admin/sensor_levels_controller.rb create mode 100644 app/controllers/api/rest/admin/sensors_controller.rb create mode 100644 app/controllers/api/rest/admin/service_types_controller.rb create mode 100644 app/controllers/api/rest/admin/services_controller.rb create mode 100644 app/controllers/api/rest/admin/sip_options_probers_controller.rb create mode 100644 app/controllers/api/rest/admin/smtp_connections_controller.rb delete mode 100644 app/controllers/api/rest/admin/system/countries_controller.rb delete mode 100644 app/controllers/api/rest/admin/system/dtmf_receive_modes_controller.rb delete mode 100644 app/controllers/api/rest/admin/system/dtmf_send_modes_controller.rb delete mode 100644 app/controllers/api/rest/admin/system/network_types_controller.rb delete mode 100644 app/controllers/api/rest/admin/system/networks_controller.rb delete mode 100644 app/controllers/api/rest/admin/system/sensor_levels_controller.rb delete mode 100644 app/controllers/api/rest/admin/system/sensors_controller.rb delete mode 100644 app/controllers/api/rest/admin/system/smtp_connections_controller.rb delete mode 100644 app/controllers/api/rest/admin/system/timezones_controller.rb create mode 100644 app/controllers/api/rest/admin/tag_actions_controller.rb create mode 100644 app/controllers/api/rest/admin/timezones_controller.rb create mode 100644 app/controllers/api/rest/admin/transactions_controller.rb create mode 100644 app/controllers/api/rest/admin/transport_protocols_controller.rb rename app/resources/api/rest/admin/{equipment/radius => }/accounting_profile_resource.rb (78%) rename app/resources/api/rest/admin/{routing => }/area_prefix_resource.rb (73%) rename app/resources/api/rest/admin/{routing => }/area_resource.rb (69%) rename app/resources/api/rest/admin/{cdr => }/auth_log_resource.rb (73%) rename app/resources/api/rest/admin/{equipment/radius => }/auth_profile_resource.rb (71%) rename app/resources/api/rest/admin/{cdr => }/cdr_export_resource.rb (95%) rename app/resources/api/rest/admin/{cdr => }/cdr_resource.rb (83%) rename app/resources/api/rest/admin/{system => }/country_resource.rb (68%) rename app/resources/api/rest/admin/{routing => }/destination_next_rate_resource.rb (92%) rename app/resources/api/rest/admin/{routing => }/destination_resource.rb (87%) rename app/resources/api/rest/admin/{system => }/dtmf_receive_mode_resource.rb (65%) rename app/resources/api/rest/admin/{system => }/dtmf_send_mode_resource.rb (66%) rename app/resources/api/rest/admin/{equipment => }/gateway_diversion_send_mode_resource.rb (63%) rename app/resources/api/rest/admin/{equipment => }/gateway_inband_dtmf_filtering_mode_resource.rb (63%) rename app/resources/api/rest/admin/{equipment => }/gateway_media_encryption_mode_resource.rb (64%) rename app/resources/api/rest/admin/{equipment => }/gateway_network_protocol_priority_resource.rb (63%) rename app/resources/api/rest/admin/{equipment => }/gateway_rel100_mode_resource.rb (64%) rename app/resources/api/rest/admin/{billing => }/invoice_originated_destination_resource.rb (94%) rename app/resources/api/rest/admin/{billing => }/invoice_originated_network_resource.rb (94%) rename app/resources/api/rest/admin/{billing => }/invoice_resource.rb (98%) rename app/resources/api/rest/admin/{billing => }/invoice_service_datum_resource.rb (91%) rename app/resources/api/rest/admin/{billing => }/invoice_template_resource.rb (73%) rename app/resources/api/rest/admin/{billing => }/invoice_terminated_destination_resource.rb (94%) rename app/resources/api/rest/admin/{billing => }/invoice_terminated_network_resource.rb (94%) rename app/resources/api/rest/admin/{system => }/network_resource.rb (74%) rename app/resources/api/rest/admin/{system => }/network_type_resource.rb (81%) rename app/resources/api/rest/admin/{routing => }/numberlist_item_resource.rb (93%) rename app/resources/api/rest/admin/{routing => }/numberlist_resource.rb (95%) rename app/resources/api/rest/admin/{routing => }/rate_group_resource.rb (82%) rename app/resources/api/rest/admin/{routing => }/rateplan_resource.rb (86%) rename app/resources/api/rest/admin/{equipment => }/registration_resource.rb (90%) rename app/resources/api/rest/admin/{routing => }/routeset_discriminator_resource.rb (79%) rename app/resources/api/rest/admin/{routing => }/routing_group_resource.rb (81%) rename app/resources/api/rest/admin/{routing => }/routing_tag_detection_rule_resource.rb (85%) rename app/resources/api/rest/admin/{routing => }/routing_tag_mode_resource.rb (70%) rename app/resources/api/rest/admin/{routing => }/routing_tag_resource.rb (68%) rename app/resources/api/rest/admin/{system => }/sensor_level_resource.rb (66%) rename app/resources/api/rest/admin/{system => }/sensor_resource.rb (75%) rename app/resources/api/rest/admin/{billing => }/service_resource.rb (95%) rename app/resources/api/rest/admin/{billing => }/service_type_resource.rb (89%) rename app/resources/api/rest/admin/{equipment => }/sip_options_prober_resource.rb (90%) rename app/resources/api/rest/admin/{system => }/smtp_connection_resource.rb (73%) rename app/resources/api/rest/admin/{routing => }/tag_action_resource.rb (70%) rename app/resources/api/rest/admin/{system => }/timezone_resource.rb (71%) rename app/resources/api/rest/admin/{billing => }/transaction_resource.rb (91%) rename app/resources/api/rest/admin/{equipment => }/transport_protocol_resource.rb (64%) rename spec/acceptance/rest/admin/api/{equipment/radius => }/accounting_profiles_spec.rb (80%) rename spec/acceptance/rest/admin/api/{routing => }/area_prefixes_spec.rb (82%) rename spec/acceptance/rest/admin/api/{routing => }/area_spec.rb (74%) rename spec/acceptance/rest/admin/api/{equipment/radius => }/auth_profiles_spec.rb (81%) rename spec/acceptance/rest/admin/api/{cdr => }/cdr_exports_spec.rb (97%) rename spec/acceptance/rest/admin/api/{cdr => }/cdrs_spec.rb (86%) rename spec/acceptance/rest/admin/api/{routing => }/destination_next_rates_spec.rb (84%) rename spec/acceptance/rest/admin/api/{routing => }/destinations_spec.rb (88%) rename spec/acceptance/rest/admin/api/{system => }/dtmf_receive_modes_spec.rb (76%) rename spec/acceptance/rest/admin/api/{system => }/dtmf_send_modes_spec.rb (76%) rename spec/acceptance/rest/admin/api/{equipment => }/gateway_inband_dtmf_filtering_modes_spec.rb (72%) rename spec/acceptance/rest/admin/api/{equipment => }/gateway_media_encryption_modes_spec.rb (73%) rename spec/acceptance/rest/admin/api/{equipment => }/gateway_network_protocol_priorities_spec.rb (72%) rename spec/acceptance/rest/admin/api/{equipment => }/gateway_rel100_modes_spec.rb (75%) rename spec/acceptance/rest/admin/api/{billing => }/invoice_originated_destinations_spec.rb (75%) rename spec/acceptance/rest/admin/api/{billing => }/invoice_originated_networks_spec.rb (76%) rename spec/acceptance/rest/admin/api/{billing => }/invoice_service_data_spec.rb (77%) rename spec/acceptance/rest/admin/api/{billing => }/invoice_template_spec.rb (79%) rename spec/acceptance/rest/admin/api/{billing => }/invoice_terminated_destinations_spec.rb (75%) rename spec/acceptance/rest/admin/api/{billing => }/invoice_terminated_networks_spec.rb (76%) rename spec/acceptance/rest/admin/api/{billing => }/invoices_spec.rb (83%) rename spec/acceptance/rest/admin/api/{system => }/network_types_spec.rb (82%) rename spec/acceptance/rest/admin/api/{system => }/networks_spec.rb (86%) rename spec/acceptance/rest/admin/api/{routing => }/numberlist_items_spec.rb (80%) rename spec/acceptance/rest/admin/api/{routing => }/numberlists_spec.rb (84%) rename spec/acceptance/rest/admin/api/{routing => }/rateplans_spec.rb (83%) rename spec/acceptance/rest/admin/api/{routing => }/routeset_discriminators_spec.rb (78%) rename spec/acceptance/rest/admin/api/{routing => }/routing_groups_spec.rb (79%) rename spec/acceptance/rest/admin/api/{routing => }/routing_tag_detection_rules_spec.rb (80%) rename spec/acceptance/rest/admin/api/{routing => }/routing_tag_modes_spec.rb (74%) rename spec/acceptance/rest/admin/api/{routing => }/routing_tags_spec.rb (81%) rename spec/acceptance/rest/admin/api/{system => }/sensor_levels_spec.rb (77%) rename spec/acceptance/rest/admin/api/{system => }/sensors_spec.rb (83%) rename spec/acceptance/rest/admin/api/{billing => }/service_types_spec.rb (82%) rename spec/acceptance/rest/admin/api/{billing => }/services_spec.rb (86%) rename spec/acceptance/rest/admin/api/{equipment => }/sip_options_probers_spec.rb (85%) rename spec/acceptance/rest/admin/api/{system => }/smtp_connections_spec.rb (81%) rename spec/acceptance/rest/admin/api/{routing => }/tag_actions_spec.rb (74%) rename spec/acceptance/rest/admin/api/{system => }/timezones_spec.rb (77%) rename spec/acceptance/rest/admin/api/{equipment => }/transport_protocols_spec.rb (75%) rename spec/controllers/api/rest/admin/{routing => }/area_prefixes_controller.rb (96%) rename spec/controllers/api/rest/admin/{routing => }/areas_controller_spec.rb (96%) rename spec/controllers/api/rest/admin/{cdr => }/auth_logs_controller_spec.rb (96%) rename spec/controllers/api/rest/admin/{cdr => }/cdrs_controller_spec.rb (98%) rename spec/controllers/api/rest/admin/{system => }/countries_controller_spec.rb (89%) rename spec/controllers/api/rest/admin/{routing => }/destination_next_rates_spec.rb (91%) rename spec/controllers/api/rest/admin/{routing => }/destinations_controller_spec.rb (99%) rename spec/controllers/api/rest/admin/{routing => }/dialpeer_next_rates_controller_spec.rb (76%) rename spec/controllers/api/rest/admin/{system => }/network_types_controller_spec.rb (88%) rename spec/controllers/api/rest/admin/{system => }/networks_controller_spec.rb (91%) rename spec/controllers/api/rest/admin/{routing => }/numberlist_items_controller_spec.rb (97%) rename spec/controllers/api/rest/admin/{routing => }/numberlists_controller_spec.rb (97%) rename spec/controllers/api/rest/admin/{routing => }/rateplans_controller_spec.rb (89%) rename spec/controllers/api/rest/admin/{routing => }/routing_groups_controller_spec.rb (88%) rename spec/controllers/api/rest/admin/{routing => }/routing_tag_detection_rules_controller_spec.rb (97%) rename spec/controllers/api/rest/admin/{routing => }/routing_tag_modes_controller_spec.rb (94%) rename spec/controllers/api/rest/admin/{routing => }/routing_tags_controller_spec.rb (95%) rename spec/controllers/api/rest/admin/{routing => }/tag_actions_controller_spec.rb (94%) rename spec/requests/api/rest/admin/{equipment/radius => }/accounting_profiles_spec.rb (73%) rename spec/requests/api/rest/admin/{routing => }/area_prefixes_spec.rb (93%) rename spec/requests/api/rest/admin/{routing => }/areas_spec.rb (70%) rename spec/requests/api/rest/admin/{cdr => }/auth_logs_spec.rb (72%) rename spec/requests/api/rest/admin/{equipment/radius => }/auth_profile_spec.rb (74%) rename spec/requests/api/rest/admin/{cdr => }/cdr_exports_spec.rb (96%) rename spec/requests/api/rest/admin/{cdr => }/cdrs_spec.rb (93%) rename spec/requests/api/rest/admin/{system => }/country_spec.rb (73%) rename spec/requests/api/rest/admin/{routing/destination_next_rates_spec.rb => destination_next_rates2_spec.rb} (75%) create mode 100644 spec/requests/api/rest/admin/destinations_spec.rb rename spec/requests/api/rest/admin/{system => }/dtmf_receive_modes_spec.rb (76%) rename spec/requests/api/rest/admin/{system => }/dtmf_send_modes_spec.rb (77%) rename spec/requests/api/rest/admin/{equipment => }/gateway_diversion_send_modes_spec.rb (73%) rename spec/requests/api/rest/admin/{equipment => }/gateway_inband_dtmf_filtering_modes_spec.rb (72%) rename spec/requests/api/rest/admin/{equipment => }/gateway_media_encryption_modes_spec.rb (73%) rename spec/requests/api/rest/admin/{equipment => }/gateway_network_protocol_priorities_spec.rb (72%) rename spec/requests/api/rest/admin/{equipment => }/gateway_rel100_modes_spec.rb (75%) rename spec/requests/api/rest/admin/{billing => }/invoice_originated_destinations_spec.rb (97%) rename spec/requests/api/rest/admin/{billing => }/invoice_originated_networks_spec.rb (97%) rename spec/requests/api/rest/admin/{billing => }/invoice_service_data_spec.rb (97%) rename spec/requests/api/rest/admin/{billing => }/invoice_templates_spec.rb (79%) rename spec/requests/api/rest/admin/{billing => }/invoice_terminated_destinations_spec.rb (97%) rename spec/requests/api/rest/admin/{billing => }/invoice_terminated_networks_spec.rb (97%) rename spec/requests/api/rest/admin/{billing => }/invoices_spec.rb (99%) rename spec/requests/api/rest/admin/{system => }/network_types_spec.rb (79%) rename spec/requests/api/rest/admin/{system => }/networks_spec.rb (74%) rename spec/requests/api/rest/admin/{routing => }/numberlist_items_spec.rb (76%) rename spec/requests/api/rest/admin/{routing => }/numberlists_spec.rb (69%) rename spec/requests/api/rest/admin/{routing => }/rateplans_spec.rb (69%) rename spec/requests/api/rest/admin/{equipment => }/registrations_spec.rb (96%) rename spec/requests/api/rest/admin/{routing => }/routeset_discriminators_spec.rb (77%) delete mode 100644 spec/requests/api/rest/admin/routing/destinations_spec.rb rename spec/requests/api/rest/admin/{routing => }/routing_groups_spec.rb (78%) rename spec/requests/api/rest/admin/{routing => }/routing_tag_detection_rules_spec.rb (74%) rename spec/requests/api/rest/admin/{routing => }/routing_tag_modes_spec.rb (76%) rename spec/requests/api/rest/admin/{routing => }/routing_tags_spec.rb (77%) rename spec/requests/api/rest/admin/{system => }/sensor_levels_spec.rb (78%) rename spec/requests/api/rest/admin/{system => }/sensors_spec.rb (70%) rename spec/requests/api/rest/admin/{equipment => }/sip_oprions_probers_spec.rb (96%) rename spec/requests/api/rest/admin/{system => }/smtp_connections_spec.rb (77%) rename spec/requests/api/rest/admin/{routing => }/tag_action_spec.rb (68%) rename spec/requests/api/rest/admin/{system => }/timezones_spec.rb (71%) rename spec/requests/api/rest/admin/{equipment => }/transport_protocols_spec.rb (75%) diff --git a/app/controllers/api/rest/admin/accounting_profiles_controller.rb b/app/controllers/api/rest/admin/accounting_profiles_controller.rb new file mode 100644 index 000000000..90b8be0e1 --- /dev/null +++ b/app/controllers/api/rest/admin/accounting_profiles_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::AccountingProfilesController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/area_prefixes_controller.rb b/app/controllers/api/rest/admin/area_prefixes_controller.rb new file mode 100644 index 000000000..841f1b359 --- /dev/null +++ b/app/controllers/api/rest/admin/area_prefixes_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::AreaPrefixesController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/areas_controller.rb b/app/controllers/api/rest/admin/areas_controller.rb new file mode 100644 index 000000000..669bfcdae --- /dev/null +++ b/app/controllers/api/rest/admin/areas_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::AreasController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/auth_logs_controller.rb b/app/controllers/api/rest/admin/auth_logs_controller.rb new file mode 100644 index 000000000..13932c042 --- /dev/null +++ b/app/controllers/api/rest/admin/auth_logs_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::AuthLogsController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/auth_profiles_controller.rb b/app/controllers/api/rest/admin/auth_profiles_controller.rb new file mode 100644 index 000000000..b9f73e9e9 --- /dev/null +++ b/app/controllers/api/rest/admin/auth_profiles_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::AuthProfilesController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/billing/invoice_originated_destinations_controller.rb b/app/controllers/api/rest/admin/billing/invoice_originated_destinations_controller.rb deleted file mode 100644 index 55055a01a..000000000 --- a/app/controllers/api/rest/admin/billing/invoice_originated_destinations_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Billing::InvoiceOriginatedDestinationsController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/billing/invoice_originated_networks_controller.rb b/app/controllers/api/rest/admin/billing/invoice_originated_networks_controller.rb deleted file mode 100644 index 642683afc..000000000 --- a/app/controllers/api/rest/admin/billing/invoice_originated_networks_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Billing::InvoiceOriginatedNetworksController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/billing/invoice_template_controller.rb b/app/controllers/api/rest/admin/billing/invoice_template_controller.rb deleted file mode 100644 index aff867538..000000000 --- a/app/controllers/api/rest/admin/billing/invoice_template_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Billing::InvoiceTemplateController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/billing/invoice_terminated_destinations_controller.rb b/app/controllers/api/rest/admin/billing/invoice_terminated_destinations_controller.rb deleted file mode 100644 index b2d6e49ac..000000000 --- a/app/controllers/api/rest/admin/billing/invoice_terminated_destinations_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Billing::InvoiceTerminatedDestinationsController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/billing/invoice_terminated_networks_controller.rb b/app/controllers/api/rest/admin/billing/invoice_terminated_networks_controller.rb deleted file mode 100644 index 28e06dcac..000000000 --- a/app/controllers/api/rest/admin/billing/invoice_terminated_networks_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Billing::InvoiceTerminatedNetworksController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/billing/service_types_controller.rb b/app/controllers/api/rest/admin/billing/service_types_controller.rb deleted file mode 100644 index 8b6ba0ad9..000000000 --- a/app/controllers/api/rest/admin/billing/service_types_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Billing::ServiceTypesController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/billing/services_controller.rb b/app/controllers/api/rest/admin/billing/services_controller.rb deleted file mode 100644 index 1a05ca7e6..000000000 --- a/app/controllers/api/rest/admin/billing/services_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Billing::ServicesController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/billing/transactions_controller.rb b/app/controllers/api/rest/admin/billing/transactions_controller.rb deleted file mode 100644 index ed0797c56..000000000 --- a/app/controllers/api/rest/admin/billing/transactions_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Billing::TransactionsController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/cdr/auth_logs_controller.rb b/app/controllers/api/rest/admin/cdr/auth_logs_controller.rb deleted file mode 100644 index bbaa58acc..000000000 --- a/app/controllers/api/rest/admin/cdr/auth_logs_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Cdr::AuthLogsController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/cdr/cdr_exports_controller.rb b/app/controllers/api/rest/admin/cdr_exports_controller.rb similarity index 83% rename from app/controllers/api/rest/admin/cdr/cdr_exports_controller.rb rename to app/controllers/api/rest/admin/cdr_exports_controller.rb index c6c62e05d..2ef44e48f 100644 --- a/app/controllers/api/rest/admin/cdr/cdr_exports_controller.rb +++ b/app/controllers/api/rest/admin/cdr_exports_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Cdr::CdrExportsController < Api::Rest::Admin::BaseController +class Api::Rest::Admin::CdrExportsController < Api::Rest::Admin::BaseController before_action :find_cdr_export, only: :download def download @@ -19,7 +19,7 @@ def download private def find_cdr_export - resource_klass = Api::Rest::Admin::Cdr::CdrExportResource + resource_klass = Api::Rest::Admin::CdrExportResource key = resource_klass.verify_key(params[:id], context) @cdr_export = resource_klass.find_by_key(key, context: context)._model rescue StandardError => e diff --git a/app/controllers/api/rest/admin/cdr/cdrs_controller.rb b/app/controllers/api/rest/admin/cdrs_controller.rb similarity index 81% rename from app/controllers/api/rest/admin/cdr/cdrs_controller.rb rename to app/controllers/api/rest/admin/cdrs_controller.rb index 4cbf0a0ff..54d91bcdc 100644 --- a/app/controllers/api/rest/admin/cdr/cdrs_controller.rb +++ b/app/controllers/api/rest/admin/cdrs_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Cdr::CdrsController < Api::Rest::Admin::BaseController +class Api::Rest::Admin::CdrsController < Api::Rest::Admin::BaseController before_action :find_cdr, only: :recording def recording if @cdr.has_recording? @@ -17,7 +17,7 @@ def recording private def find_cdr - resource_klass = Api::Rest::Admin::Cdr::CdrResource + resource_klass = Api::Rest::Admin::CdrResource key = resource_klass.verify_key(params[:id], context) @cdr = resource_klass.find_by_key(key, context: context)._model rescue StandardError => e diff --git a/app/controllers/api/rest/admin/countries_controller.rb b/app/controllers/api/rest/admin/countries_controller.rb new file mode 100644 index 000000000..bcb1974e5 --- /dev/null +++ b/app/controllers/api/rest/admin/countries_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::CountriesController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/destination_next_rates_controller.rb b/app/controllers/api/rest/admin/destination_next_rates_controller.rb new file mode 100644 index 000000000..52cf84c9f --- /dev/null +++ b/app/controllers/api/rest/admin/destination_next_rates_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::DestinationNextRatesController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/destinations_controller.rb b/app/controllers/api/rest/admin/destinations_controller.rb new file mode 100644 index 000000000..19bc9bb99 --- /dev/null +++ b/app/controllers/api/rest/admin/destinations_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::DestinationsController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/dtmf_receive_modes_controller.rb b/app/controllers/api/rest/admin/dtmf_receive_modes_controller.rb new file mode 100644 index 000000000..885500d16 --- /dev/null +++ b/app/controllers/api/rest/admin/dtmf_receive_modes_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::DtmfReceiveModesController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/dtmf_send_modes_controller.rb b/app/controllers/api/rest/admin/dtmf_send_modes_controller.rb new file mode 100644 index 000000000..faf3ab734 --- /dev/null +++ b/app/controllers/api/rest/admin/dtmf_send_modes_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::DtmfSendModesController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/equipment/gateway_diversion_send_modes_controller.rb b/app/controllers/api/rest/admin/equipment/gateway_diversion_send_modes_controller.rb deleted file mode 100644 index e32306146..000000000 --- a/app/controllers/api/rest/admin/equipment/gateway_diversion_send_modes_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Equipment::GatewayDiversionSendModesController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/equipment/gateway_inband_dtmf_filtering_modes_controller.rb b/app/controllers/api/rest/admin/equipment/gateway_inband_dtmf_filtering_modes_controller.rb deleted file mode 100644 index 9c11de0fa..000000000 --- a/app/controllers/api/rest/admin/equipment/gateway_inband_dtmf_filtering_modes_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Equipment::GatewayInbandDtmfFilteringModesController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/equipment/gateway_media_encryption_modes_controller.rb b/app/controllers/api/rest/admin/equipment/gateway_media_encryption_modes_controller.rb deleted file mode 100644 index 598aaf9d3..000000000 --- a/app/controllers/api/rest/admin/equipment/gateway_media_encryption_modes_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Equipment::GatewayMediaEncryptionModesController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/equipment/gateway_network_protocol_priorities_controller.rb b/app/controllers/api/rest/admin/equipment/gateway_network_protocol_priorities_controller.rb deleted file mode 100644 index 9d8a5ad7c..000000000 --- a/app/controllers/api/rest/admin/equipment/gateway_network_protocol_priorities_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Equipment::GatewayNetworkProtocolPrioritiesController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/equipment/radius/accounting_profiles_controller.rb b/app/controllers/api/rest/admin/equipment/radius/accounting_profiles_controller.rb deleted file mode 100644 index 75198c0a7..000000000 --- a/app/controllers/api/rest/admin/equipment/radius/accounting_profiles_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Equipment::Radius::AccountingProfilesController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/equipment/sip_options_probers_controller.rb b/app/controllers/api/rest/admin/equipment/sip_options_probers_controller.rb deleted file mode 100644 index 6c0993d6a..000000000 --- a/app/controllers/api/rest/admin/equipment/sip_options_probers_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Equipment::SipOptionsProbersController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/gateway_diversion_send_modes_controller.rb b/app/controllers/api/rest/admin/gateway_diversion_send_modes_controller.rb new file mode 100644 index 000000000..e3b0d2d3b --- /dev/null +++ b/app/controllers/api/rest/admin/gateway_diversion_send_modes_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::GatewayDiversionSendModesController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/equipment/radius/auth_profiles_controller.rb b/app/controllers/api/rest/admin/gateway_inband_dtmf_filtering_modes_controller.rb similarity index 52% rename from app/controllers/api/rest/admin/equipment/radius/auth_profiles_controller.rb rename to app/controllers/api/rest/admin/gateway_inband_dtmf_filtering_modes_controller.rb index cf148a264..53f06f338 100644 --- a/app/controllers/api/rest/admin/equipment/radius/auth_profiles_controller.rb +++ b/app/controllers/api/rest/admin/gateway_inband_dtmf_filtering_modes_controller.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true -class Api::Rest::Admin::Equipment::Radius::AuthProfilesController < Api::Rest::Admin::BaseController +class Api::Rest::Admin::GatewayInbandDtmfFilteringModesController < Api::Rest::Admin::BaseController end diff --git a/app/controllers/api/rest/admin/billing/invoice_service_data_controller.rb b/app/controllers/api/rest/admin/gateway_media_encryption_modes_controller.rb similarity index 51% rename from app/controllers/api/rest/admin/billing/invoice_service_data_controller.rb rename to app/controllers/api/rest/admin/gateway_media_encryption_modes_controller.rb index 5fb8eba06..33574aca5 100644 --- a/app/controllers/api/rest/admin/billing/invoice_service_data_controller.rb +++ b/app/controllers/api/rest/admin/gateway_media_encryption_modes_controller.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true -class Api::Rest::Admin::Billing::InvoiceServiceDataController < Api::Rest::Admin::BaseController +class Api::Rest::Admin::GatewayMediaEncryptionModesController < Api::Rest::Admin::BaseController end diff --git a/app/controllers/api/rest/admin/gateway_network_protocol_priorities_controller.rb b/app/controllers/api/rest/admin/gateway_network_protocol_priorities_controller.rb new file mode 100644 index 000000000..d69541339 --- /dev/null +++ b/app/controllers/api/rest/admin/gateway_network_protocol_priorities_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::GatewayNetworkProtocolPrioritiesController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/gateway_rel100_modes_controller.rb b/app/controllers/api/rest/admin/gateway_rel100_modes_controller.rb new file mode 100644 index 000000000..02476350f --- /dev/null +++ b/app/controllers/api/rest/admin/gateway_rel100_modes_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::GatewayRel100ModesController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/equipment/gateway_rel100_modes_controller.rb b/app/controllers/api/rest/admin/invoice_originated_destinations_controller.rb similarity index 52% rename from app/controllers/api/rest/admin/equipment/gateway_rel100_modes_controller.rb rename to app/controllers/api/rest/admin/invoice_originated_destinations_controller.rb index 706035547..c17762698 100644 --- a/app/controllers/api/rest/admin/equipment/gateway_rel100_modes_controller.rb +++ b/app/controllers/api/rest/admin/invoice_originated_destinations_controller.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true -class Api::Rest::Admin::Equipment::GatewayRel100ModesController < Api::Rest::Admin::BaseController +class Api::Rest::Admin::InvoiceOriginatedDestinationsController < Api::Rest::Admin::BaseController end diff --git a/app/controllers/api/rest/admin/invoice_originated_networks_controller.rb b/app/controllers/api/rest/admin/invoice_originated_networks_controller.rb new file mode 100644 index 000000000..7b4888d48 --- /dev/null +++ b/app/controllers/api/rest/admin/invoice_originated_networks_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::InvoiceOriginatedNetworksController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/invoice_service_data_controller.rb b/app/controllers/api/rest/admin/invoice_service_data_controller.rb new file mode 100644 index 000000000..16e1f89a7 --- /dev/null +++ b/app/controllers/api/rest/admin/invoice_service_data_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::InvoiceServiceDataController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/invoice_template_controller.rb b/app/controllers/api/rest/admin/invoice_template_controller.rb new file mode 100644 index 000000000..b152d40a9 --- /dev/null +++ b/app/controllers/api/rest/admin/invoice_template_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::InvoiceTemplateController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/equipment/transport_protocols_controller.rb b/app/controllers/api/rest/admin/invoice_terminated_destinations_controller.rb similarity index 52% rename from app/controllers/api/rest/admin/equipment/transport_protocols_controller.rb rename to app/controllers/api/rest/admin/invoice_terminated_destinations_controller.rb index bd1358ba4..44f84138d 100644 --- a/app/controllers/api/rest/admin/equipment/transport_protocols_controller.rb +++ b/app/controllers/api/rest/admin/invoice_terminated_destinations_controller.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true -class Api::Rest::Admin::Equipment::TransportProtocolsController < Api::Rest::Admin::BaseController +class Api::Rest::Admin::InvoiceTerminatedDestinationsController < Api::Rest::Admin::BaseController end diff --git a/app/controllers/api/rest/admin/invoice_terminated_networks_controller.rb b/app/controllers/api/rest/admin/invoice_terminated_networks_controller.rb new file mode 100644 index 000000000..777ad2f17 --- /dev/null +++ b/app/controllers/api/rest/admin/invoice_terminated_networks_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::InvoiceTerminatedNetworksController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/billing/invoices_controller.rb b/app/controllers/api/rest/admin/invoices_controller.rb similarity index 83% rename from app/controllers/api/rest/admin/billing/invoices_controller.rb rename to app/controllers/api/rest/admin/invoices_controller.rb index c1632dfa1..c3081ba68 100644 --- a/app/controllers/api/rest/admin/billing/invoices_controller.rb +++ b/app/controllers/api/rest/admin/invoices_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Billing::InvoicesController < Api::Rest::Admin::BaseController +class Api::Rest::Admin::InvoicesController < Api::Rest::Admin::BaseController def pdf doc = ::Billing::InvoiceDocument.find_by(invoice_id: params[:id]) return head 404 if doc.nil? || doc.pdf_data.blank? diff --git a/app/controllers/api/rest/admin/network_types_controller.rb b/app/controllers/api/rest/admin/network_types_controller.rb new file mode 100644 index 000000000..95853cdd4 --- /dev/null +++ b/app/controllers/api/rest/admin/network_types_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::NetworkTypesController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/networks_controller.rb b/app/controllers/api/rest/admin/networks_controller.rb new file mode 100644 index 000000000..f4a8b68e0 --- /dev/null +++ b/app/controllers/api/rest/admin/networks_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::NetworksController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/numberlist_items_controller.rb b/app/controllers/api/rest/admin/numberlist_items_controller.rb new file mode 100644 index 000000000..19973be08 --- /dev/null +++ b/app/controllers/api/rest/admin/numberlist_items_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::NumberlistItemsController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/numberlists_controller.rb b/app/controllers/api/rest/admin/numberlists_controller.rb new file mode 100644 index 000000000..f64f1697e --- /dev/null +++ b/app/controllers/api/rest/admin/numberlists_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::NumberlistsController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/rate_groups_controller.rb b/app/controllers/api/rest/admin/rate_groups_controller.rb new file mode 100644 index 000000000..92bf654f6 --- /dev/null +++ b/app/controllers/api/rest/admin/rate_groups_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::RateGroupsController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/rateplans_controller.rb b/app/controllers/api/rest/admin/rateplans_controller.rb new file mode 100644 index 000000000..e2a3c1005 --- /dev/null +++ b/app/controllers/api/rest/admin/rateplans_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::RateplansController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/registrations_controller.rb b/app/controllers/api/rest/admin/registrations_controller.rb new file mode 100644 index 000000000..e150bffe8 --- /dev/null +++ b/app/controllers/api/rest/admin/registrations_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::RegistrationsController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/routeset_discriminators_controller.rb b/app/controllers/api/rest/admin/routeset_discriminators_controller.rb new file mode 100644 index 000000000..772143663 --- /dev/null +++ b/app/controllers/api/rest/admin/routeset_discriminators_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::RoutesetDiscriminatorsController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/routing/area_prefixes_controller.rb b/app/controllers/api/rest/admin/routing/area_prefixes_controller.rb deleted file mode 100644 index bfdfd5dc2..000000000 --- a/app/controllers/api/rest/admin/routing/area_prefixes_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Routing::AreaPrefixesController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/routing/areas_controller.rb b/app/controllers/api/rest/admin/routing/areas_controller.rb deleted file mode 100644 index 95af95fa2..000000000 --- a/app/controllers/api/rest/admin/routing/areas_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Routing::AreasController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/routing/destination_next_rates_controller.rb b/app/controllers/api/rest/admin/routing/destination_next_rates_controller.rb deleted file mode 100644 index afb7adc4a..000000000 --- a/app/controllers/api/rest/admin/routing/destination_next_rates_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Routing::DestinationNextRatesController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/routing/destinations_controller.rb b/app/controllers/api/rest/admin/routing/destinations_controller.rb deleted file mode 100644 index 89957aa42..000000000 --- a/app/controllers/api/rest/admin/routing/destinations_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Routing::DestinationsController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/routing/numberlist_items_controller.rb b/app/controllers/api/rest/admin/routing/numberlist_items_controller.rb deleted file mode 100644 index c62283033..000000000 --- a/app/controllers/api/rest/admin/routing/numberlist_items_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Routing::NumberlistItemsController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/routing/numberlists_controller.rb b/app/controllers/api/rest/admin/routing/numberlists_controller.rb deleted file mode 100644 index 8043bd403..000000000 --- a/app/controllers/api/rest/admin/routing/numberlists_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Routing::NumberlistsController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/routing/rate_groups_controller.rb b/app/controllers/api/rest/admin/routing/rate_groups_controller.rb deleted file mode 100644 index cc3f177df..000000000 --- a/app/controllers/api/rest/admin/routing/rate_groups_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Routing::RateGroupsController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/routing/rateplans_controller.rb b/app/controllers/api/rest/admin/routing/rateplans_controller.rb deleted file mode 100644 index bc2031aab..000000000 --- a/app/controllers/api/rest/admin/routing/rateplans_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Routing::RateplansController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/routing/routeset_discriminators_controller.rb b/app/controllers/api/rest/admin/routing/routeset_discriminators_controller.rb deleted file mode 100644 index 593b1ee5f..000000000 --- a/app/controllers/api/rest/admin/routing/routeset_discriminators_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Routing::RoutesetDiscriminatorsController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/routing/routing_groups_controller.rb b/app/controllers/api/rest/admin/routing/routing_groups_controller.rb deleted file mode 100644 index 74d9f77dc..000000000 --- a/app/controllers/api/rest/admin/routing/routing_groups_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Routing::RoutingGroupsController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/routing/routing_tag_detection_rules_controller.rb b/app/controllers/api/rest/admin/routing/routing_tag_detection_rules_controller.rb deleted file mode 100644 index 8c35d2bc5..000000000 --- a/app/controllers/api/rest/admin/routing/routing_tag_detection_rules_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Routing::RoutingTagDetectionRulesController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/routing/routing_tag_modes_controller.rb b/app/controllers/api/rest/admin/routing/routing_tag_modes_controller.rb deleted file mode 100644 index 2aae284ca..000000000 --- a/app/controllers/api/rest/admin/routing/routing_tag_modes_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Routing::RoutingTagModesController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/routing/routing_tags_controller.rb b/app/controllers/api/rest/admin/routing/routing_tags_controller.rb deleted file mode 100644 index 0151aeaa5..000000000 --- a/app/controllers/api/rest/admin/routing/routing_tags_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Routing::RoutingTagsController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/routing/tag_actions_controller.rb b/app/controllers/api/rest/admin/routing/tag_actions_controller.rb deleted file mode 100644 index 7c626f831..000000000 --- a/app/controllers/api/rest/admin/routing/tag_actions_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::Routing::TagActionsController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/routing_groups_controller.rb b/app/controllers/api/rest/admin/routing_groups_controller.rb new file mode 100644 index 000000000..60ff7fa77 --- /dev/null +++ b/app/controllers/api/rest/admin/routing_groups_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::RoutingGroupsController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/equipment/registrations_controller.rb b/app/controllers/api/rest/admin/routing_tag_detection_rules_controller.rb similarity index 50% rename from app/controllers/api/rest/admin/equipment/registrations_controller.rb rename to app/controllers/api/rest/admin/routing_tag_detection_rules_controller.rb index ad6b2bc85..729ffc795 100644 --- a/app/controllers/api/rest/admin/equipment/registrations_controller.rb +++ b/app/controllers/api/rest/admin/routing_tag_detection_rules_controller.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true -class Api::Rest::Admin::Equipment::RegistrationsController < Api::Rest::Admin::BaseController +class Api::Rest::Admin::RoutingTagDetectionRulesController < Api::Rest::Admin::BaseController end diff --git a/app/controllers/api/rest/admin/routing_tag_modes_controller.rb b/app/controllers/api/rest/admin/routing_tag_modes_controller.rb new file mode 100644 index 000000000..cad9e1657 --- /dev/null +++ b/app/controllers/api/rest/admin/routing_tag_modes_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::RoutingTagModesController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/routing_tags_controller.rb b/app/controllers/api/rest/admin/routing_tags_controller.rb new file mode 100644 index 000000000..3ab6295a4 --- /dev/null +++ b/app/controllers/api/rest/admin/routing_tags_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::RoutingTagsController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/sensor_levels_controller.rb b/app/controllers/api/rest/admin/sensor_levels_controller.rb new file mode 100644 index 000000000..5489d1887 --- /dev/null +++ b/app/controllers/api/rest/admin/sensor_levels_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::SensorLevelsController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/sensors_controller.rb b/app/controllers/api/rest/admin/sensors_controller.rb new file mode 100644 index 000000000..2e5af7d75 --- /dev/null +++ b/app/controllers/api/rest/admin/sensors_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::SensorsController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/service_types_controller.rb b/app/controllers/api/rest/admin/service_types_controller.rb new file mode 100644 index 000000000..9781a5e06 --- /dev/null +++ b/app/controllers/api/rest/admin/service_types_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::ServiceTypesController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/services_controller.rb b/app/controllers/api/rest/admin/services_controller.rb new file mode 100644 index 000000000..234c275fa --- /dev/null +++ b/app/controllers/api/rest/admin/services_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::ServicesController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/sip_options_probers_controller.rb b/app/controllers/api/rest/admin/sip_options_probers_controller.rb new file mode 100644 index 000000000..7d1f86fb2 --- /dev/null +++ b/app/controllers/api/rest/admin/sip_options_probers_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::SipOptionsProbersController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/smtp_connections_controller.rb b/app/controllers/api/rest/admin/smtp_connections_controller.rb new file mode 100644 index 000000000..50782001c --- /dev/null +++ b/app/controllers/api/rest/admin/smtp_connections_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::SmtpConnectionsController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/system/countries_controller.rb b/app/controllers/api/rest/admin/system/countries_controller.rb deleted file mode 100644 index eecc2016f..000000000 --- a/app/controllers/api/rest/admin/system/countries_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::System::CountriesController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/system/dtmf_receive_modes_controller.rb b/app/controllers/api/rest/admin/system/dtmf_receive_modes_controller.rb deleted file mode 100644 index 08ba6c580..000000000 --- a/app/controllers/api/rest/admin/system/dtmf_receive_modes_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::System::DtmfReceiveModesController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/system/dtmf_send_modes_controller.rb b/app/controllers/api/rest/admin/system/dtmf_send_modes_controller.rb deleted file mode 100644 index 37b92940d..000000000 --- a/app/controllers/api/rest/admin/system/dtmf_send_modes_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::System::DtmfSendModesController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/system/network_types_controller.rb b/app/controllers/api/rest/admin/system/network_types_controller.rb deleted file mode 100644 index a17a4312b..000000000 --- a/app/controllers/api/rest/admin/system/network_types_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::System::NetworkTypesController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/system/networks_controller.rb b/app/controllers/api/rest/admin/system/networks_controller.rb deleted file mode 100644 index fed74925f..000000000 --- a/app/controllers/api/rest/admin/system/networks_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::System::NetworksController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/system/sensor_levels_controller.rb b/app/controllers/api/rest/admin/system/sensor_levels_controller.rb deleted file mode 100644 index 2284be27c..000000000 --- a/app/controllers/api/rest/admin/system/sensor_levels_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::System::SensorLevelsController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/system/sensors_controller.rb b/app/controllers/api/rest/admin/system/sensors_controller.rb deleted file mode 100644 index 1a3ae06e4..000000000 --- a/app/controllers/api/rest/admin/system/sensors_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::System::SensorsController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/system/smtp_connections_controller.rb b/app/controllers/api/rest/admin/system/smtp_connections_controller.rb deleted file mode 100644 index 8fe0004b4..000000000 --- a/app/controllers/api/rest/admin/system/smtp_connections_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::System::SmtpConnectionsController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/system/timezones_controller.rb b/app/controllers/api/rest/admin/system/timezones_controller.rb deleted file mode 100644 index fbd5032b2..000000000 --- a/app/controllers/api/rest/admin/system/timezones_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class Api::Rest::Admin::System::TimezonesController < Api::Rest::Admin::BaseController -end diff --git a/app/controllers/api/rest/admin/tag_actions_controller.rb b/app/controllers/api/rest/admin/tag_actions_controller.rb new file mode 100644 index 000000000..14385b47f --- /dev/null +++ b/app/controllers/api/rest/admin/tag_actions_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::TagActionsController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/timezones_controller.rb b/app/controllers/api/rest/admin/timezones_controller.rb new file mode 100644 index 000000000..00c89a8a0 --- /dev/null +++ b/app/controllers/api/rest/admin/timezones_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::TimezonesController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/transactions_controller.rb b/app/controllers/api/rest/admin/transactions_controller.rb new file mode 100644 index 000000000..81c5c80f8 --- /dev/null +++ b/app/controllers/api/rest/admin/transactions_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::TransactionsController < Api::Rest::Admin::BaseController +end diff --git a/app/controllers/api/rest/admin/transport_protocols_controller.rb b/app/controllers/api/rest/admin/transport_protocols_controller.rb new file mode 100644 index 000000000..bc2307a09 --- /dev/null +++ b/app/controllers/api/rest/admin/transport_protocols_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Api::Rest::Admin::TransportProtocolsController < Api::Rest::Admin::BaseController +end diff --git a/app/forms/batch_update_form/base.rb b/app/forms/batch_update_form/base.rb index cd7a36254..36bdbd984 100644 --- a/app/forms/batch_update_form/base.rb +++ b/app/forms/batch_update_form/base.rb @@ -26,7 +26,7 @@ class BatchUpdateForm::Base # end # end # - # # app/admin/billing/contacts.rb + # # app/admin/contacts.rb # ActiveAdmin.register Billing::Contact do # acts_as_async_update BatchUpdateForm::Contact # # ... diff --git a/app/resources/api/rest/admin/account_resource.rb b/app/resources/api/rest/admin/account_resource.rb index 7b6b2cda8..d10c8ec55 100644 --- a/app/resources/api/rest/admin/account_resource.rb +++ b/app/resources/api/rest/admin/account_resource.rb @@ -13,8 +13,8 @@ class Api::Rest::Admin::AccountResource < BaseResource :send_invoices_to, :invoice_period has_one :contractor, always_include_linkage_data: true - has_one :timezone, class_name: 'System::Timezone', always_include_linkage_data: true - has_one :invoice_template, class_name: 'Billing::InvoiceTemplate', always_include_linkage_data: true + has_one :timezone, class_name: 'Timezone', always_include_linkage_data: true + has_one :invoice_template, class_name: 'InvoiceTemplate', always_include_linkage_data: true filter :name diff --git a/app/resources/api/rest/admin/equipment/radius/accounting_profile_resource.rb b/app/resources/api/rest/admin/accounting_profile_resource.rb similarity index 78% rename from app/resources/api/rest/admin/equipment/radius/accounting_profile_resource.rb rename to app/resources/api/rest/admin/accounting_profile_resource.rb index b34119daa..21208b35f 100644 --- a/app/resources/api/rest/admin/equipment/radius/accounting_profile_resource.rb +++ b/app/resources/api/rest/admin/accounting_profile_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Equipment::Radius::AccountingProfileResource < ::BaseResource +class Api::Rest::Admin::AccountingProfileResource < ::BaseResource model_name 'Equipment::Radius::AccountingProfile' attributes :name, :server, :port, :secret, :timeout, :attempts, :enable_start_accounting, diff --git a/app/resources/api/rest/admin/active_call_resource.rb b/app/resources/api/rest/admin/active_call_resource.rb index 911fa35a2..0e8c674c8 100644 --- a/app/resources/api/rest/admin/active_call_resource.rb +++ b/app/resources/api/rest/admin/active_call_resource.rb @@ -61,12 +61,12 @@ class Api::Rest::Admin::ActiveCallResource < ::BaseResource has_one :customer_acc, class_name: 'Account' has_one :vendor_acc, class_name: 'Account' has_one :customer_auth, class_name: 'CustomersAuth' - has_one :destination, class_name: 'Routing::Destination' + has_one :destination, class_name: 'Destination' has_one :dialpeer, class_name: 'Dialpeer' has_one :orig_gw, class_name: 'Gateway' has_one :term_gw, class_name: 'Gateway' - has_one :routing_group, class_name: 'Routing::RoutingGroup' - has_one :rateplan, class_name: 'Routing::Rateplan' + has_one :routing_group, class_name: 'RoutingGroup' + has_one :rateplan, class_name: 'Rateplan' has_one :node, class_name: 'Node', foreign_key: :node_id filter :node_id_eq diff --git a/app/resources/api/rest/admin/routing/area_prefix_resource.rb b/app/resources/api/rest/admin/area_prefix_resource.rb similarity index 73% rename from app/resources/api/rest/admin/routing/area_prefix_resource.rb rename to app/resources/api/rest/admin/area_prefix_resource.rb index fafe4dd77..4ba1f5155 100644 --- a/app/resources/api/rest/admin/routing/area_prefix_resource.rb +++ b/app/resources/api/rest/admin/area_prefix_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Routing::AreaPrefixResource < ::BaseResource +class Api::Rest::Admin::AreaPrefixResource < ::BaseResource model_name 'Routing::AreaPrefix' attributes :prefix diff --git a/app/resources/api/rest/admin/routing/area_resource.rb b/app/resources/api/rest/admin/area_resource.rb similarity index 69% rename from app/resources/api/rest/admin/routing/area_resource.rb rename to app/resources/api/rest/admin/area_resource.rb index d652516f9..ed4761c62 100644 --- a/app/resources/api/rest/admin/routing/area_resource.rb +++ b/app/resources/api/rest/admin/area_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Routing::AreaResource < ::BaseResource +class Api::Rest::Admin::AreaResource < ::BaseResource model_name 'Routing::Area' attributes :name diff --git a/app/resources/api/rest/admin/cdr/auth_log_resource.rb b/app/resources/api/rest/admin/auth_log_resource.rb similarity index 73% rename from app/resources/api/rest/admin/cdr/auth_log_resource.rb rename to app/resources/api/rest/admin/auth_log_resource.rb index 535c8809d..faa90b5b1 100644 --- a/app/resources/api/rest/admin/cdr/auth_log_resource.rb +++ b/app/resources/api/rest/admin/auth_log_resource.rb @@ -1,19 +1,10 @@ # frozen_string_literal: true -class Api::Rest::Admin::Cdr::AuthLogResource < BaseResource +class Api::Rest::Admin::AuthLogResource < BaseResource immutable model_name 'Cdr::AuthLog' paginator :paged - module CONST - ROOT_NAMESPACE_RELATIONS = %w[ - Gateway Pop Node - ].freeze - EQUIPMENT_NAMESPACE_RELATIONS = %w[TransportProtocol].freeze - - freeze - end - def self.default_sort [{ field: 'request_time', direction: :desc }] end @@ -35,11 +26,11 @@ def self.default_sort :x_yeti_auth, :diversion, :pai, :ppi, :privacy, :rpid, :rpid_privacy - has_one :gateway, class_name: 'Gateway', force_routed: true, always_include_linkage_data: true - has_one :pop, class_name: 'Pop', force_routed: true, always_include_linkage_data: true - has_one :node, class_name: 'Node', force_routed: true, always_include_linkage_data: true - has_one :origination_protocol, class_name: 'TransportProtocol', foreign_key: :origination_proto_id, force_routed: true - has_one :transport_protocol, class_name: 'TransportProtocol', foreign_key: :transport_proto_id, force_routed: true + has_one :gateway, class_name: 'Gateway', always_include_linkage_data: true + has_one :pop, class_name: 'Pop', always_include_linkage_data: true + has_one :node, class_name: 'Node', always_include_linkage_data: true + has_one :origination_protocol, class_name: 'TransportProtocol', foreign_key: :origination_proto_id + has_one :transport_protocol, class_name: 'TransportProtocol', foreign_key: :transport_proto_id filter :request_time_gteq, apply: lambda { |records, values, _options| records.where('request_time >= ?', values[0]) @@ -80,14 +71,4 @@ def self.default_sort ransack_filter :privacy, type: :string ransack_filter :rpid, type: :string ransack_filter :rpid_privacy, type: :string - - def self.resource_for(type) - if type.in?(CONST::ROOT_NAMESPACE_RELATIONS) - "Api::Rest::Admin::#{type}Resource".safe_constantize - elsif type.in?(CONST::EQUIPMENT_NAMESPACE_RELATIONS) - "Api::Rest::Admin::Equipment::#{type}Resource".safe_constantize - else - super - end - end end diff --git a/app/resources/api/rest/admin/equipment/radius/auth_profile_resource.rb b/app/resources/api/rest/admin/auth_profile_resource.rb similarity index 71% rename from app/resources/api/rest/admin/equipment/radius/auth_profile_resource.rb rename to app/resources/api/rest/admin/auth_profile_resource.rb index 88a0565d6..f684b0957 100644 --- a/app/resources/api/rest/admin/equipment/radius/auth_profile_resource.rb +++ b/app/resources/api/rest/admin/auth_profile_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Equipment::Radius::AuthProfileResource < ::BaseResource +class Api::Rest::Admin::AuthProfileResource < ::BaseResource model_name 'Equipment::Radius::AuthProfile' attributes :name, :server, :port, :secret, :reject_on_error, :timeout, :attempts diff --git a/app/resources/api/rest/admin/cdr/cdr_export_resource.rb b/app/resources/api/rest/admin/cdr_export_resource.rb similarity index 95% rename from app/resources/api/rest/admin/cdr/cdr_export_resource.rb rename to app/resources/api/rest/admin/cdr_export_resource.rb index 555297ed4..0f920367d 100644 --- a/app/resources/api/rest/admin/cdr/cdr_export_resource.rb +++ b/app/resources/api/rest/admin/cdr_export_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Cdr::CdrExportResource < BaseResource +class Api::Rest::Admin::CdrExportResource < BaseResource model_name 'CdrExport' model_hint model: CdrExport::Base, resource: self paginator :paged diff --git a/app/resources/api/rest/admin/cdr/cdr_resource.rb b/app/resources/api/rest/admin/cdr_resource.rb similarity index 83% rename from app/resources/api/rest/admin/cdr/cdr_resource.rb rename to app/resources/api/rest/admin/cdr_resource.rb index a44787eb6..340dcab13 100644 --- a/app/resources/api/rest/admin/cdr/cdr_resource.rb +++ b/app/resources/api/rest/admin/cdr_resource.rb @@ -1,18 +1,9 @@ # frozen_string_literal: true -class Api::Rest::Admin::Cdr::CdrResource < BaseResource +class Api::Rest::Admin::CdrResource < BaseResource model_name 'Cdr::Cdr' paginator :paged - module CONST - ROOT_NAMESPACE_RELATIONS = %w[ - Dialpeer Pop CustomersAuth Contractor Account Gateway RoutingPlan - ].freeze - SYSTEM_NAMESPACE_RELATIONS = %w[Country Network].freeze - ROUTING_NAMESPACE_RELATIONS = %w[Destination Rateplan RoutingGroup].freeze - freeze - end - def self.default_sort [{ field: 'time_start', direction: :desc }] end @@ -128,24 +119,24 @@ def self.updatable_fields(_context) :destination_rate_policy_id, :metadata - has_one :rateplan, class_name: 'Rateplan', force_routed: true, always_include_linkage_data: true - has_one :dialpeer, force_routed: true, always_include_linkage_data: true - has_one :pop, force_routed: true, always_include_linkage_data: true - has_one :node, force_routed: true, always_include_linkage_data: true - has_one :routing_group, class_name: 'RoutingGroup', force_routed: true, always_include_linkage_data: true - has_one :routing_plan, class_name: 'RoutingPlan', force_routed: true, always_include_linkage_data: true - has_one :destination, class_name: 'Destination', force_routed: true, always_include_linkage_data: true - has_one :customer_auth, force_routed: true, always_include_linkage_data: true - has_one :vendor, class_name: 'Contractor', force_routed: true, always_include_linkage_data: true - has_one :customer, class_name: 'Contractor', force_routed: true, always_include_linkage_data: true - has_one :customer_acc, class_name: 'Account', force_routed: true, always_include_linkage_data: true - has_one :vendor_acc, class_name: 'Account', force_routed: true, always_include_linkage_data: true - has_one :orig_gw, class_name: 'Gateway', force_routed: true, always_include_linkage_data: true - has_one :term_gw, class_name: 'Gateway', force_routed: true, always_include_linkage_data: true - has_one :dst_country, class_name: 'Country', force_routed: true, always_include_linkage_data: true - has_one :dst_network, class_name: 'Network', force_routed: true, always_include_linkage_data: true - has_one :src_country, class_name: 'Country', force_routed: true, always_include_linkage_data: true - has_one :src_network, class_name: 'Network', force_routed: true, always_include_linkage_data: true + has_one :rateplan, class_name: 'Rateplan', always_include_linkage_data: true + has_one :dialpeer, always_include_linkage_data: true + has_one :pop, always_include_linkage_data: true + has_one :node, always_include_linkage_data: true + has_one :routing_group, class_name: 'RoutingGroup', always_include_linkage_data: true + has_one :routing_plan, class_name: 'RoutingPlan', always_include_linkage_data: true + has_one :destination, class_name: 'Destination', always_include_linkage_data: true + has_one :customer_auth, always_include_linkage_data: true + has_one :vendor, class_name: 'Contractor', always_include_linkage_data: true + has_one :customer, class_name: 'Contractor', always_include_linkage_data: true + has_one :customer_acc, class_name: 'Account', always_include_linkage_data: true + has_one :vendor_acc, class_name: 'Account', always_include_linkage_data: true + has_one :orig_gw, class_name: 'Gateway', always_include_linkage_data: true + has_one :term_gw, class_name: 'Gateway', always_include_linkage_data: true + has_one :dst_country, class_name: 'Country', always_include_linkage_data: true + has_one :dst_network, class_name: 'Network', always_include_linkage_data: true + has_one :src_country, class_name: 'Country', always_include_linkage_data: true + has_one :src_network, class_name: 'Network', always_include_linkage_data: true filter :customer_auth_external_id_eq, apply: lambda { |records, values, _options| records.where(customer_auth_external_id: values) @@ -355,17 +346,4 @@ def self.updatable_fields(_context) ransack_filter :vendor_duration, type: :number ransack_filter :destination_rate_policy_id, type: :number ransack_filter :audio_recorded, type: :boolean - - # add supporting associations from non cdr namespaces - def self.resource_for(type) - if type.in?(CONST::ROOT_NAMESPACE_RELATIONS) - "Api::Rest::Admin::#{type}Resource".safe_constantize - elsif type.in?(CONST::SYSTEM_NAMESPACE_RELATIONS) - "Api::Rest::Admin::System::#{type}Resource".safe_constantize - elsif type.in?(CONST::ROUTING_NAMESPACE_RELATIONS) - "Api::Rest::Admin::Routing::#{type}Resource".safe_constantize - else - super - end - end end diff --git a/app/resources/api/rest/admin/contractor_resource.rb b/app/resources/api/rest/admin/contractor_resource.rb index d9cc5ea74..945b8cbd7 100644 --- a/app/resources/api/rest/admin/contractor_resource.rb +++ b/app/resources/api/rest/admin/contractor_resource.rb @@ -5,7 +5,7 @@ class Api::Rest::Admin::ContractorResource < BaseResource paginator :paged - has_one :smtp_connection, class_name: 'System::SmtpConnection', always_include_linkage_data: true + has_one :smtp_connection, class_name: 'SmtpConnection', always_include_linkage_data: true filter :name diff --git a/app/resources/api/rest/admin/system/country_resource.rb b/app/resources/api/rest/admin/country_resource.rb similarity index 68% rename from app/resources/api/rest/admin/system/country_resource.rb rename to app/resources/api/rest/admin/country_resource.rb index d880c1855..e5cfe936d 100644 --- a/app/resources/api/rest/admin/system/country_resource.rb +++ b/app/resources/api/rest/admin/country_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::System::CountryResource < ::BaseResource +class Api::Rest::Admin::CountryResource < ::BaseResource model_name 'System::Country' attributes :name, :iso2 paginator :paged diff --git a/app/resources/api/rest/admin/customers_auth_resource.rb b/app/resources/api/rest/admin/customers_auth_resource.rb index 595e11a73..2ce793e0f 100644 --- a/app/resources/api/rest/admin/customers_auth_resource.rb +++ b/app/resources/api/rest/admin/customers_auth_resource.rb @@ -14,18 +14,18 @@ class Api::Rest::Admin::CustomersAuthResource < BaseResource paginator :paged has_one :customer, always_include_linkage_data: true - has_one :rateplan, class_name: 'Routing::Rateplan', always_include_linkage_data: true + has_one :rateplan, class_name: 'Rateplan', always_include_linkage_data: true has_one :routing_plan, class_name: 'RoutingPlan', always_include_linkage_data: true has_one :gateway, always_include_linkage_data: true has_one :account, always_include_linkage_data: true has_one :diversion_policy, always_include_linkage_data: true has_one :pop, always_include_linkage_data: true - has_one :dst_numberlist, class_name: 'Routing::Numberlist', always_include_linkage_data: true - has_one :src_numberlist, class_name: 'Routing::Numberlist', always_include_linkage_data: true - has_one :tag_action, class_name: 'Routing::TagAction', always_include_linkage_data: true - has_one :radius_auth_profile, class_name: 'Equipment::Radius::AuthProfile', always_include_linkage_data: true - has_one :radius_accounting_profile, class_name: 'Equipment::Radius::AccountingProfile', always_include_linkage_data: true - has_one :transport_protocol, class_name: 'Equipment::TransportProtocol', always_include_linkage_data: true + has_one :dst_numberlist, class_name: 'Numberlist', always_include_linkage_data: true + has_one :src_numberlist, class_name: 'Numberlist', always_include_linkage_data: true + has_one :tag_action, class_name: 'TagAction', always_include_linkage_data: true + has_one :radius_auth_profile, class_name: 'AuthProfile', always_include_linkage_data: true + has_one :radius_accounting_profile, class_name: 'AccountingProfile', always_include_linkage_data: true + has_one :transport_protocol, class_name: 'TransportProtocol', always_include_linkage_data: true filter :name diff --git a/app/resources/api/rest/admin/routing/destination_next_rate_resource.rb b/app/resources/api/rest/admin/destination_next_rate_resource.rb similarity index 92% rename from app/resources/api/rest/admin/routing/destination_next_rate_resource.rb rename to app/resources/api/rest/admin/destination_next_rate_resource.rb index 1a54a426c..2ff4203b6 100644 --- a/app/resources/api/rest/admin/routing/destination_next_rate_resource.rb +++ b/app/resources/api/rest/admin/destination_next_rate_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Routing::DestinationNextRateResource < ::BaseResource +class Api::Rest::Admin::DestinationNextRateResource < ::BaseResource model_name 'Routing::DestinationNextRate' attributes :next_rate, :initial_rate, :initial_interval, :next_interval, :connect_fee, :apply_time, :applied, :external_id diff --git a/app/resources/api/rest/admin/routing/destination_resource.rb b/app/resources/api/rest/admin/destination_resource.rb similarity index 87% rename from app/resources/api/rest/admin/routing/destination_resource.rb rename to app/resources/api/rest/admin/destination_resource.rb index 62781daa8..159e53db6 100644 --- a/app/resources/api/rest/admin/routing/destination_resource.rb +++ b/app/resources/api/rest/admin/destination_resource.rb @@ -1,12 +1,8 @@ # frozen_string_literal: true -class Api::Rest::Admin::Routing::DestinationResource < ::BaseResource +class Api::Rest::Admin::DestinationResource < ::BaseResource model_name 'Routing::Destination' - module CONST - SYSTEM_NAMESPACE_RELATIONS = %w[Country Network].freeze - end.freeze - attributes :enabled, :next_rate, :connect_fee, :initial_interval, :next_interval, :dp_margin_fixed, :dp_margin_percent, :initial_rate, :asr_limit, :acd_limit, :short_calls_limit, :prefix, :reject_calls, :use_dp_intervals, :valid_from, :valid_till, :external_id, @@ -17,8 +13,8 @@ module CONST has_one :rate_group, class_name: 'RateGroup' has_one :routing_tag_mode, class_name: 'RoutingTagMode' - has_one :country, class_name: 'Country', force_routed: true, foreign_key_on: :related - has_one :network, class_name: 'Network', force_routed: true, foreign_key_on: :related + has_one :country, class_name: 'Country', foreign_key_on: :related + has_one :network, class_name: 'Network', foreign_key_on: :related has_many :destination_next_rates, class_name: 'DestinationNextRate' filters :external_id, :prefix, :rate_group_id @@ -92,14 +88,6 @@ def self.sortable_fields(_context = nil) super + %i[country.name network.name] end - def self.resource_for(type) - if type.in?(CONST::SYSTEM_NAMESPACE_RELATIONS) - "Api::Rest::Admin::System::#{type}Resource".safe_constantize - else - super - end - end - # related to issue https://github.com/cerebris/jsonapi-resources/issues/1409 def self.sort_records(records, order_options, context = {}) local_records = records diff --git a/app/resources/api/rest/admin/dialpeer_resource.rb b/app/resources/api/rest/admin/dialpeer_resource.rb index 57b86f4c1..ea40fe8a8 100644 --- a/app/resources/api/rest/admin/dialpeer_resource.rb +++ b/app/resources/api/rest/admin/dialpeer_resource.rb @@ -12,11 +12,11 @@ class Api::Rest::Admin::DialpeerResource < BaseResource has_one :gateway, always_include_linkage_data: true has_one :gateway_group, always_include_linkage_data: true - has_one :routing_group, class_name: 'Routing::RoutingGroup', always_include_linkage_data: true + has_one :routing_group, class_name: 'RoutingGroup', always_include_linkage_data: true has_one :vendor, class_name: 'Contractor', always_include_linkage_data: true has_one :account, always_include_linkage_data: true - has_one :routing_tag_mode, class_name: 'Routing::RoutingTagMode', always_include_linkage_data: true - has_one :routeset_discriminator, class_name: 'Routing::RoutesetDiscriminator', always_include_linkage_data: true + has_one :routing_tag_mode, class_name: 'RoutingTagMode', always_include_linkage_data: true + has_one :routeset_discriminator, class_name: 'RoutesetDiscriminator', always_include_linkage_data: true has_many :dialpeer_next_rates diff --git a/app/resources/api/rest/admin/system/dtmf_receive_mode_resource.rb b/app/resources/api/rest/admin/dtmf_receive_mode_resource.rb similarity index 65% rename from app/resources/api/rest/admin/system/dtmf_receive_mode_resource.rb rename to app/resources/api/rest/admin/dtmf_receive_mode_resource.rb index a16a1042f..4031602ee 100644 --- a/app/resources/api/rest/admin/system/dtmf_receive_mode_resource.rb +++ b/app/resources/api/rest/admin/dtmf_receive_mode_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::System::DtmfReceiveModeResource < ::BaseResource +class Api::Rest::Admin::DtmfReceiveModeResource < ::BaseResource model_name 'System::DtmfReceiveMode' immutable attributes :name diff --git a/app/resources/api/rest/admin/system/dtmf_send_mode_resource.rb b/app/resources/api/rest/admin/dtmf_send_mode_resource.rb similarity index 66% rename from app/resources/api/rest/admin/system/dtmf_send_mode_resource.rb rename to app/resources/api/rest/admin/dtmf_send_mode_resource.rb index f46e057fa..bf8cd00d4 100644 --- a/app/resources/api/rest/admin/system/dtmf_send_mode_resource.rb +++ b/app/resources/api/rest/admin/dtmf_send_mode_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::System::DtmfSendModeResource < ::BaseResource +class Api::Rest::Admin::DtmfSendModeResource < ::BaseResource model_name 'System::DtmfSendMode' immutable attributes :name diff --git a/app/resources/api/rest/admin/equipment/gateway_diversion_send_mode_resource.rb b/app/resources/api/rest/admin/gateway_diversion_send_mode_resource.rb similarity index 63% rename from app/resources/api/rest/admin/equipment/gateway_diversion_send_mode_resource.rb rename to app/resources/api/rest/admin/gateway_diversion_send_mode_resource.rb index 9a4e71174..358d87f85 100644 --- a/app/resources/api/rest/admin/equipment/gateway_diversion_send_mode_resource.rb +++ b/app/resources/api/rest/admin/gateway_diversion_send_mode_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Equipment::GatewayDiversionSendModeResource < ::BaseResource +class Api::Rest::Admin::GatewayDiversionSendModeResource < ::BaseResource model_name 'Equipment::GatewayDiversionSendMode' immutable attributes :name diff --git a/app/resources/api/rest/admin/equipment/gateway_inband_dtmf_filtering_mode_resource.rb b/app/resources/api/rest/admin/gateway_inband_dtmf_filtering_mode_resource.rb similarity index 63% rename from app/resources/api/rest/admin/equipment/gateway_inband_dtmf_filtering_mode_resource.rb rename to app/resources/api/rest/admin/gateway_inband_dtmf_filtering_mode_resource.rb index eef22199c..0f61bb2ec 100644 --- a/app/resources/api/rest/admin/equipment/gateway_inband_dtmf_filtering_mode_resource.rb +++ b/app/resources/api/rest/admin/gateway_inband_dtmf_filtering_mode_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Equipment::GatewayInbandDtmfFilteringModeResource < ::BaseResource +class Api::Rest::Admin::GatewayInbandDtmfFilteringModeResource < ::BaseResource model_name 'Equipment::GatewayInbandDtmfFilteringMode' immutable attributes :name diff --git a/app/resources/api/rest/admin/equipment/gateway_media_encryption_mode_resource.rb b/app/resources/api/rest/admin/gateway_media_encryption_mode_resource.rb similarity index 64% rename from app/resources/api/rest/admin/equipment/gateway_media_encryption_mode_resource.rb rename to app/resources/api/rest/admin/gateway_media_encryption_mode_resource.rb index 41ad58d97..6d534ae78 100644 --- a/app/resources/api/rest/admin/equipment/gateway_media_encryption_mode_resource.rb +++ b/app/resources/api/rest/admin/gateway_media_encryption_mode_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Equipment::GatewayMediaEncryptionModeResource < BaseResource +class Api::Rest::Admin::GatewayMediaEncryptionModeResource < BaseResource model_name 'Equipment::GatewayMediaEncryptionMode' immutable attributes :name diff --git a/app/resources/api/rest/admin/equipment/gateway_network_protocol_priority_resource.rb b/app/resources/api/rest/admin/gateway_network_protocol_priority_resource.rb similarity index 63% rename from app/resources/api/rest/admin/equipment/gateway_network_protocol_priority_resource.rb rename to app/resources/api/rest/admin/gateway_network_protocol_priority_resource.rb index 07e59c0da..ad1b02f48 100644 --- a/app/resources/api/rest/admin/equipment/gateway_network_protocol_priority_resource.rb +++ b/app/resources/api/rest/admin/gateway_network_protocol_priority_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Equipment::GatewayNetworkProtocolPriorityResource < BaseResource +class Api::Rest::Admin::GatewayNetworkProtocolPriorityResource < BaseResource model_name 'Equipment::GatewayNetworkProtocolPriority' immutable attributes :name diff --git a/app/resources/api/rest/admin/equipment/gateway_rel100_mode_resource.rb b/app/resources/api/rest/admin/gateway_rel100_mode_resource.rb similarity index 64% rename from app/resources/api/rest/admin/equipment/gateway_rel100_mode_resource.rb rename to app/resources/api/rest/admin/gateway_rel100_mode_resource.rb index 61e0deeec..752191334 100644 --- a/app/resources/api/rest/admin/equipment/gateway_rel100_mode_resource.rb +++ b/app/resources/api/rest/admin/gateway_rel100_mode_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Equipment::GatewayRel100ModeResource < ::BaseResource +class Api::Rest::Admin::GatewayRel100ModeResource < ::BaseResource model_name 'Equipment::GatewayRel100Mode' immutable attributes :name diff --git a/app/resources/api/rest/admin/gateway_resource.rb b/app/resources/api/rest/admin/gateway_resource.rb index dea2df1ce..3373d3674 100644 --- a/app/resources/api/rest/admin/gateway_resource.rb +++ b/app/resources/api/rest/admin/gateway_resource.rb @@ -27,22 +27,22 @@ class Api::Rest::Admin::GatewayResource < ::BaseResource has_one :term_disconnect_policy, class_name: 'DisconnectPolicy', always_include_linkage_data: true has_one :orig_disconnect_policy, class_name: 'DisconnectPolicy', always_include_linkage_data: true has_one :gateway_group, always_include_linkage_data: true - has_one :diversion_send_mode, class_name: 'Equipment::GatewayDiversionSendMode', always_include_linkage_data: true + has_one :diversion_send_mode, class_name: 'GatewayDiversionSendMode', always_include_linkage_data: true has_one :pop, always_include_linkage_data: true has_one :codec_group, always_include_linkage_data: true has_one :sdp_c_location, class_name: 'SdpCLocation', always_include_linkage_data: true - has_one :sensor, class_name: 'System::Sensor', always_include_linkage_data: true - has_one :sensor_level, class_name: 'System::SensorLevel', always_include_linkage_data: true - has_one :dtmf_receive_mode, class_name: 'System::DtmfReceiveMode', always_include_linkage_data: true - has_one :dtmf_send_mode, class_name: 'System::DtmfSendMode', always_include_linkage_data: true - has_one :transport_protocol, class_name: 'Equipment::TransportProtocol', always_include_linkage_data: true - has_one :term_proxy_transport_protocol, class_name: 'Equipment::TransportProtocol', always_include_linkage_data: true - has_one :orig_proxy_transport_protocol, class_name: 'Equipment::TransportProtocol', always_include_linkage_data: true - has_one :rel100_mode, class_name: 'Equipment::GatewayRel100Mode', always_include_linkage_data: true - has_one :rx_inband_dtmf_filtering_mode, class_name: 'Equipment::GatewayInbandDtmfFilteringMode', always_include_linkage_data: true - has_one :tx_inband_dtmf_filtering_mode, class_name: 'Equipment::GatewayInbandDtmfFilteringMode', always_include_linkage_data: true - has_one :network_protocol_priority, class_name: 'Equipment::GatewayNetworkProtocolPriority', always_include_linkage_data: true - has_one :media_encryption_mode, class_name: 'Equipment::GatewayMediaEncryptionMode', always_include_linkage_data: true + has_one :sensor, class_name: 'Sensor', always_include_linkage_data: true + has_one :sensor_level, class_name: 'SensorLevel', always_include_linkage_data: true + has_one :dtmf_receive_mode, class_name: 'DtmfReceiveMode', always_include_linkage_data: true + has_one :dtmf_send_mode, class_name: 'DtmfSendMode', always_include_linkage_data: true + has_one :transport_protocol, class_name: 'TransportProtocol', always_include_linkage_data: true + has_one :term_proxy_transport_protocol, class_name: 'TransportProtocol', always_include_linkage_data: true + has_one :orig_proxy_transport_protocol, class_name: 'TransportProtocol', always_include_linkage_data: true + has_one :rel100_mode, class_name: 'GatewayRel100Mode', always_include_linkage_data: true + has_one :rx_inband_dtmf_filtering_mode, class_name: 'GatewayInbandDtmfFilteringMode', always_include_linkage_data: true + has_one :tx_inband_dtmf_filtering_mode, class_name: 'GatewayInbandDtmfFilteringMode', always_include_linkage_data: true + has_one :network_protocol_priority, class_name: 'GatewayNetworkProtocolPriority', always_include_linkage_data: true + has_one :media_encryption_mode, class_name: 'GatewayMediaEncryptionMode', always_include_linkage_data: true filter :name # DEPRECATED diff --git a/app/resources/api/rest/admin/billing/invoice_originated_destination_resource.rb b/app/resources/api/rest/admin/invoice_originated_destination_resource.rb similarity index 94% rename from app/resources/api/rest/admin/billing/invoice_originated_destination_resource.rb rename to app/resources/api/rest/admin/invoice_originated_destination_resource.rb index a98f351a3..1aea75fe2 100644 --- a/app/resources/api/rest/admin/billing/invoice_originated_destination_resource.rb +++ b/app/resources/api/rest/admin/invoice_originated_destination_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Billing::InvoiceOriginatedDestinationResource < ::BaseResource +class Api::Rest::Admin::InvoiceOriginatedDestinationResource < ::BaseResource model_name 'Billing::InvoiceOriginatedDestination' paginator :paged diff --git a/app/resources/api/rest/admin/billing/invoice_originated_network_resource.rb b/app/resources/api/rest/admin/invoice_originated_network_resource.rb similarity index 94% rename from app/resources/api/rest/admin/billing/invoice_originated_network_resource.rb rename to app/resources/api/rest/admin/invoice_originated_network_resource.rb index c2853d921..71043695e 100644 --- a/app/resources/api/rest/admin/billing/invoice_originated_network_resource.rb +++ b/app/resources/api/rest/admin/invoice_originated_network_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Billing::InvoiceOriginatedNetworkResource < ::BaseResource +class Api::Rest::Admin::InvoiceOriginatedNetworkResource < ::BaseResource model_name 'Billing::InvoiceOriginatedNetwork' paginator :paged diff --git a/app/resources/api/rest/admin/billing/invoice_resource.rb b/app/resources/api/rest/admin/invoice_resource.rb similarity index 98% rename from app/resources/api/rest/admin/billing/invoice_resource.rb rename to app/resources/api/rest/admin/invoice_resource.rb index 10687f164..13852e0e5 100644 --- a/app/resources/api/rest/admin/billing/invoice_resource.rb +++ b/app/resources/api/rest/admin/invoice_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Billing::InvoiceResource < ::BaseResource +class Api::Rest::Admin::InvoiceResource < ::BaseResource model_name 'Billing::Invoice' create_form 'ManualInvoiceForm' paginator :paged diff --git a/app/resources/api/rest/admin/billing/invoice_service_datum_resource.rb b/app/resources/api/rest/admin/invoice_service_datum_resource.rb similarity index 91% rename from app/resources/api/rest/admin/billing/invoice_service_datum_resource.rb rename to app/resources/api/rest/admin/invoice_service_datum_resource.rb index 82787026c..fabb8f1d5 100644 --- a/app/resources/api/rest/admin/billing/invoice_service_datum_resource.rb +++ b/app/resources/api/rest/admin/invoice_service_datum_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Billing::InvoiceServiceDatumResource < ::BaseResource +class Api::Rest::Admin::InvoiceServiceDatumResource < ::BaseResource model_name 'Billing::InvoiceServiceData' paginator :paged diff --git a/app/resources/api/rest/admin/billing/invoice_template_resource.rb b/app/resources/api/rest/admin/invoice_template_resource.rb similarity index 73% rename from app/resources/api/rest/admin/billing/invoice_template_resource.rb rename to app/resources/api/rest/admin/invoice_template_resource.rb index 2f833c45a..1d9d4cddc 100644 --- a/app/resources/api/rest/admin/billing/invoice_template_resource.rb +++ b/app/resources/api/rest/admin/invoice_template_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Billing::InvoiceTemplateResource < ::BaseResource +class Api::Rest::Admin::InvoiceTemplateResource < ::BaseResource model_name 'Billing::InvoiceTemplate' attributes :name, :filename diff --git a/app/resources/api/rest/admin/billing/invoice_terminated_destination_resource.rb b/app/resources/api/rest/admin/invoice_terminated_destination_resource.rb similarity index 94% rename from app/resources/api/rest/admin/billing/invoice_terminated_destination_resource.rb rename to app/resources/api/rest/admin/invoice_terminated_destination_resource.rb index 33bf6a003..ac9920ee0 100644 --- a/app/resources/api/rest/admin/billing/invoice_terminated_destination_resource.rb +++ b/app/resources/api/rest/admin/invoice_terminated_destination_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Billing::InvoiceTerminatedDestinationResource < ::BaseResource +class Api::Rest::Admin::InvoiceTerminatedDestinationResource < ::BaseResource model_name 'Billing::InvoiceTerminatedDestination' paginator :paged diff --git a/app/resources/api/rest/admin/billing/invoice_terminated_network_resource.rb b/app/resources/api/rest/admin/invoice_terminated_network_resource.rb similarity index 94% rename from app/resources/api/rest/admin/billing/invoice_terminated_network_resource.rb rename to app/resources/api/rest/admin/invoice_terminated_network_resource.rb index 791b35d0c..431c7a69f 100644 --- a/app/resources/api/rest/admin/billing/invoice_terminated_network_resource.rb +++ b/app/resources/api/rest/admin/invoice_terminated_network_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Billing::InvoiceTerminatedNetworkResource < ::BaseResource +class Api::Rest::Admin::InvoiceTerminatedNetworkResource < ::BaseResource model_name 'Billing::InvoiceTerminatedNetwork' paginator :paged diff --git a/app/resources/api/rest/admin/system/network_resource.rb b/app/resources/api/rest/admin/network_resource.rb similarity index 74% rename from app/resources/api/rest/admin/system/network_resource.rb rename to app/resources/api/rest/admin/network_resource.rb index 453fcedb4..f14ca1b1e 100644 --- a/app/resources/api/rest/admin/system/network_resource.rb +++ b/app/resources/api/rest/admin/network_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::System::NetworkResource < ::BaseResource +class Api::Rest::Admin::NetworkResource < ::BaseResource model_name 'System::Network' attributes :name paginator :paged diff --git a/app/resources/api/rest/admin/system/network_type_resource.rb b/app/resources/api/rest/admin/network_type_resource.rb similarity index 81% rename from app/resources/api/rest/admin/system/network_type_resource.rb rename to app/resources/api/rest/admin/network_type_resource.rb index 2e10d21d1..669dc188e 100644 --- a/app/resources/api/rest/admin/system/network_type_resource.rb +++ b/app/resources/api/rest/admin/network_type_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::System::NetworkTypeResource < ::BaseResource +class Api::Rest::Admin::NetworkTypeResource < ::BaseResource model_name 'System::NetworkType' attributes :name paginator :paged diff --git a/app/resources/api/rest/admin/routing/numberlist_item_resource.rb b/app/resources/api/rest/admin/numberlist_item_resource.rb similarity index 93% rename from app/resources/api/rest/admin/routing/numberlist_item_resource.rb rename to app/resources/api/rest/admin/numberlist_item_resource.rb index 746cb9e73..d1fee8355 100644 --- a/app/resources/api/rest/admin/routing/numberlist_item_resource.rb +++ b/app/resources/api/rest/admin/numberlist_item_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Routing::NumberlistItemResource < ::BaseResource +class Api::Rest::Admin::NumberlistItemResource < ::BaseResource model_name 'Routing::NumberlistItem' attributes :key, :number_min_length, :number_max_length, diff --git a/app/resources/api/rest/admin/routing/numberlist_resource.rb b/app/resources/api/rest/admin/numberlist_resource.rb similarity index 95% rename from app/resources/api/rest/admin/routing/numberlist_resource.rb rename to app/resources/api/rest/admin/numberlist_resource.rb index 393bf38da..b32bf9c5d 100644 --- a/app/resources/api/rest/admin/routing/numberlist_resource.rb +++ b/app/resources/api/rest/admin/numberlist_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Routing::NumberlistResource < ::BaseResource +class Api::Rest::Admin::NumberlistResource < ::BaseResource model_name 'Routing::Numberlist' attributes :name, :default_action_id, :mode_id, diff --git a/app/resources/api/rest/admin/routing/rate_group_resource.rb b/app/resources/api/rest/admin/rate_group_resource.rb similarity index 82% rename from app/resources/api/rest/admin/routing/rate_group_resource.rb rename to app/resources/api/rest/admin/rate_group_resource.rb index aa4b0a9be..49b5e7a1a 100644 --- a/app/resources/api/rest/admin/routing/rate_group_resource.rb +++ b/app/resources/api/rest/admin/rate_group_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Routing::RateGroupResource < BaseResource +class Api::Rest::Admin::RateGroupResource < BaseResource model_name 'Routing::RateGroup' attributes :name, :external_id diff --git a/app/resources/api/rest/admin/routing/rateplan_resource.rb b/app/resources/api/rest/admin/rateplan_resource.rb similarity index 86% rename from app/resources/api/rest/admin/routing/rateplan_resource.rb rename to app/resources/api/rest/admin/rateplan_resource.rb index b5e81f515..c47d4f745 100644 --- a/app/resources/api/rest/admin/routing/rateplan_resource.rb +++ b/app/resources/api/rest/admin/rateplan_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Routing::RateplanResource < BaseResource +class Api::Rest::Admin::RateplanResource < BaseResource model_name 'Routing::Rateplan' attributes :name, :profit_control_mode_id diff --git a/app/resources/api/rest/admin/equipment/registration_resource.rb b/app/resources/api/rest/admin/registration_resource.rb similarity index 90% rename from app/resources/api/rest/admin/equipment/registration_resource.rb rename to app/resources/api/rest/admin/registration_resource.rb index a7e5af43e..08870d420 100644 --- a/app/resources/api/rest/admin/equipment/registration_resource.rb +++ b/app/resources/api/rest/admin/registration_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Equipment::RegistrationResource < ::BaseResource +class Api::Rest::Admin::RegistrationResource < ::BaseResource model_name 'Equipment::Registration' paginator :paged diff --git a/app/resources/api/rest/admin/routing/routeset_discriminator_resource.rb b/app/resources/api/rest/admin/routeset_discriminator_resource.rb similarity index 79% rename from app/resources/api/rest/admin/routing/routeset_discriminator_resource.rb rename to app/resources/api/rest/admin/routeset_discriminator_resource.rb index 455e3fccb..a996e3ea4 100644 --- a/app/resources/api/rest/admin/routing/routeset_discriminator_resource.rb +++ b/app/resources/api/rest/admin/routeset_discriminator_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Routing::RoutesetDiscriminatorResource < ::BaseResource +class Api::Rest::Admin::RoutesetDiscriminatorResource < ::BaseResource model_name 'Routing::RoutesetDiscriminator' attributes :name diff --git a/app/resources/api/rest/admin/routing/routing_group_resource.rb b/app/resources/api/rest/admin/routing_group_resource.rb similarity index 81% rename from app/resources/api/rest/admin/routing/routing_group_resource.rb rename to app/resources/api/rest/admin/routing_group_resource.rb index e605e5dac..e896efb41 100644 --- a/app/resources/api/rest/admin/routing/routing_group_resource.rb +++ b/app/resources/api/rest/admin/routing_group_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Routing::RoutingGroupResource < ::BaseResource +class Api::Rest::Admin::RoutingGroupResource < ::BaseResource model_name 'Routing::RoutingGroup' attributes :name diff --git a/app/resources/api/rest/admin/routing/routing_tag_detection_rule_resource.rb b/app/resources/api/rest/admin/routing_tag_detection_rule_resource.rb similarity index 85% rename from app/resources/api/rest/admin/routing/routing_tag_detection_rule_resource.rb rename to app/resources/api/rest/admin/routing_tag_detection_rule_resource.rb index 6cc1363ac..588a1fd0a 100644 --- a/app/resources/api/rest/admin/routing/routing_tag_detection_rule_resource.rb +++ b/app/resources/api/rest/admin/routing_tag_detection_rule_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Routing::RoutingTagDetectionRuleResource < ::BaseResource +class Api::Rest::Admin::RoutingTagDetectionRuleResource < ::BaseResource model_name 'Routing::RoutingTagDetectionRule' attributes :src_prefix, :dst_prefix, :tag_action_value, :routing_tag_ids diff --git a/app/resources/api/rest/admin/routing/routing_tag_mode_resource.rb b/app/resources/api/rest/admin/routing_tag_mode_resource.rb similarity index 70% rename from app/resources/api/rest/admin/routing/routing_tag_mode_resource.rb rename to app/resources/api/rest/admin/routing_tag_mode_resource.rb index ed61304cf..8ee0e4937 100644 --- a/app/resources/api/rest/admin/routing/routing_tag_mode_resource.rb +++ b/app/resources/api/rest/admin/routing_tag_mode_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Routing::RoutingTagModeResource < ::BaseResource +class Api::Rest::Admin::RoutingTagModeResource < ::BaseResource model_name 'Routing::RoutingTagMode' immutable attributes :name diff --git a/app/resources/api/rest/admin/routing/routing_tag_resource.rb b/app/resources/api/rest/admin/routing_tag_resource.rb similarity index 68% rename from app/resources/api/rest/admin/routing/routing_tag_resource.rb rename to app/resources/api/rest/admin/routing_tag_resource.rb index 1d94a5438..901d06048 100644 --- a/app/resources/api/rest/admin/routing/routing_tag_resource.rb +++ b/app/resources/api/rest/admin/routing_tag_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Routing::RoutingTagResource < ::BaseResource +class Api::Rest::Admin::RoutingTagResource < ::BaseResource model_name 'Routing::RoutingTag' attributes :name diff --git a/app/resources/api/rest/admin/system/sensor_level_resource.rb b/app/resources/api/rest/admin/sensor_level_resource.rb similarity index 66% rename from app/resources/api/rest/admin/system/sensor_level_resource.rb rename to app/resources/api/rest/admin/sensor_level_resource.rb index 2df317cdb..7bdeb6419 100644 --- a/app/resources/api/rest/admin/system/sensor_level_resource.rb +++ b/app/resources/api/rest/admin/sensor_level_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::System::SensorLevelResource < ::BaseResource +class Api::Rest::Admin::SensorLevelResource < ::BaseResource model_name 'System::SensorLevel' immutable attributes :name diff --git a/app/resources/api/rest/admin/system/sensor_resource.rb b/app/resources/api/rest/admin/sensor_resource.rb similarity index 75% rename from app/resources/api/rest/admin/system/sensor_resource.rb rename to app/resources/api/rest/admin/sensor_resource.rb index 5b319e976..291674ede 100644 --- a/app/resources/api/rest/admin/system/sensor_resource.rb +++ b/app/resources/api/rest/admin/sensor_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::System::SensorResource < ::BaseResource +class Api::Rest::Admin::SensorResource < ::BaseResource model_name 'System::Sensor' attributes :name, :mode_id, :source_interface, :target_mac, :use_routing, :target_ip, :source_ip diff --git a/app/resources/api/rest/admin/billing/service_resource.rb b/app/resources/api/rest/admin/service_resource.rb similarity index 95% rename from app/resources/api/rest/admin/billing/service_resource.rb rename to app/resources/api/rest/admin/service_resource.rb index 20d7450fb..7d3b97cd8 100644 --- a/app/resources/api/rest/admin/billing/service_resource.rb +++ b/app/resources/api/rest/admin/service_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Billing::ServiceResource < ::BaseResource +class Api::Rest::Admin::ServiceResource < ::BaseResource model_name 'Billing::Service' paginator :paged diff --git a/app/resources/api/rest/admin/billing/service_type_resource.rb b/app/resources/api/rest/admin/service_type_resource.rb similarity index 89% rename from app/resources/api/rest/admin/billing/service_type_resource.rb rename to app/resources/api/rest/admin/service_type_resource.rb index 9ebd1286c..99f9e366b 100644 --- a/app/resources/api/rest/admin/billing/service_type_resource.rb +++ b/app/resources/api/rest/admin/service_type_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Billing::ServiceTypeResource < ::BaseResource +class Api::Rest::Admin::ServiceTypeResource < ::BaseResource model_name 'Billing::ServiceType' paginator :paged diff --git a/app/resources/api/rest/admin/equipment/sip_options_prober_resource.rb b/app/resources/api/rest/admin/sip_options_prober_resource.rb similarity index 90% rename from app/resources/api/rest/admin/equipment/sip_options_prober_resource.rb rename to app/resources/api/rest/admin/sip_options_prober_resource.rb index 82a562532..837a047eb 100644 --- a/app/resources/api/rest/admin/equipment/sip_options_prober_resource.rb +++ b/app/resources/api/rest/admin/sip_options_prober_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Equipment::SipOptionsProberResource < ::BaseResource +class Api::Rest::Admin::SipOptionsProberResource < ::BaseResource model_name 'Equipment::SipOptionsProber' paginator :paged diff --git a/app/resources/api/rest/admin/system/smtp_connection_resource.rb b/app/resources/api/rest/admin/smtp_connection_resource.rb similarity index 73% rename from app/resources/api/rest/admin/system/smtp_connection_resource.rb rename to app/resources/api/rest/admin/smtp_connection_resource.rb index 00364c633..9a42ac775 100644 --- a/app/resources/api/rest/admin/system/smtp_connection_resource.rb +++ b/app/resources/api/rest/admin/smtp_connection_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::System::SmtpConnectionResource < ::BaseResource +class Api::Rest::Admin::SmtpConnectionResource < ::BaseResource model_name 'System::SmtpConnection' attributes :name, :host, :port, :from_address, :auth_user, :auth_password, :global diff --git a/app/resources/api/rest/admin/routing/tag_action_resource.rb b/app/resources/api/rest/admin/tag_action_resource.rb similarity index 70% rename from app/resources/api/rest/admin/routing/tag_action_resource.rb rename to app/resources/api/rest/admin/tag_action_resource.rb index 8f5a5489f..a72179a55 100644 --- a/app/resources/api/rest/admin/routing/tag_action_resource.rb +++ b/app/resources/api/rest/admin/tag_action_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Routing::TagActionResource < ::BaseResource +class Api::Rest::Admin::TagActionResource < ::BaseResource model_name 'Routing::TagAction' immutable diff --git a/app/resources/api/rest/admin/system/timezone_resource.rb b/app/resources/api/rest/admin/timezone_resource.rb similarity index 71% rename from app/resources/api/rest/admin/system/timezone_resource.rb rename to app/resources/api/rest/admin/timezone_resource.rb index eb1e448e4..276df4eeb 100644 --- a/app/resources/api/rest/admin/system/timezone_resource.rb +++ b/app/resources/api/rest/admin/timezone_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::System::TimezoneResource < ::BaseResource +class Api::Rest::Admin::TimezoneResource < ::BaseResource model_name 'System::Timezone' immutable attributes :name, :abbrev, :utc_offset, :is_dst diff --git a/app/resources/api/rest/admin/billing/transaction_resource.rb b/app/resources/api/rest/admin/transaction_resource.rb similarity index 91% rename from app/resources/api/rest/admin/billing/transaction_resource.rb rename to app/resources/api/rest/admin/transaction_resource.rb index 840dd3588..23fd2145f 100644 --- a/app/resources/api/rest/admin/billing/transaction_resource.rb +++ b/app/resources/api/rest/admin/transaction_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Billing::TransactionResource < ::BaseResource +class Api::Rest::Admin::TransactionResource < ::BaseResource model_name 'Billing::Transaction' paginator :paged immutable diff --git a/app/resources/api/rest/admin/equipment/transport_protocol_resource.rb b/app/resources/api/rest/admin/transport_protocol_resource.rb similarity index 64% rename from app/resources/api/rest/admin/equipment/transport_protocol_resource.rb rename to app/resources/api/rest/admin/transport_protocol_resource.rb index 6dcc59092..c90b1a571 100644 --- a/app/resources/api/rest/admin/equipment/transport_protocol_resource.rb +++ b/app/resources/api/rest/admin/transport_protocol_resource.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Api::Rest::Admin::Equipment::TransportProtocolResource < ::BaseResource +class Api::Rest::Admin::TransportProtocolResource < ::BaseResource model_name 'Equipment::TransportProtocol' immutable attributes :name diff --git a/config/initializers/jsonapi_resources.rb b/config/initializers/jsonapi_resources.rb index 0060cb4ab..bca8614df 100644 --- a/config/initializers/jsonapi_resources.rb +++ b/config/initializers/jsonapi_resources.rb @@ -14,93 +14,3 @@ config.top_level_meta_include_record_count = true config.top_level_meta_record_count_key = :total_count end - -module JsonapiResourceClassPatch - # @example - # JSONAPI::Resource.register_resource_override 'api/rest/admin', 'Pop', 'Api::Rest::Admin::Pop' - def register_resource_override(prefix, name, result) - JSONAPI::Resource.resource_overrides.push( - prefix: "#{prefix.underscore.chomp('/')}/", - name: name.underscore.singularize, - result: result.underscore - ) - end - - def resource_overrides - @resource_overrides ||= [] - - # { - # 'api/rest/admin/equipment/sip_schemas' => 'api/rest/admin/system/sip_schemas', - # 'api/rest/admin/equipment/pops' => 'api/rest/admin/pops', - # 'pop' => 'api/rest/admin/pops', - # 'api/rest/admin/equipment/nodes' => 'api/rest/admin/nodes', - # 'node' => 'api/rest/admin/nodes' - # } - end - - def find_resource_override(type) - type = type.underscore - type = "#{module_path}#{type}" unless type.include?('/') - singular_name = type.split('/').last.singularize - found = JSONAPI::Resource.resource_overrides.detect do |opts| - type.start_with?(opts[:prefix]) && singular_name == opts[:name] - end - found&.fetch(:result) - end - - def resource_for(type) - override = find_resource_override(type) - unless override.nil? - resource_name = _resource_name_from_type(override) - return resource_name.constantize - end - - super - rescue StandardError => e - Rails.logger.error { "Failed to detect #{name}.resource_for(#{type.inspect}) #{type.underscore}" } - raise e - end -end - -ActionDispatch::Routing::Mapper::Resources.class_eval do - def patched_jsonapi_relationships(options = {}) - overrides = options.delete(:overrides) || {} - res = JSONAPI::Resource.resource_for(resource_type_with_module_prefix(@resource_type)) - res._relationships.each do |relationship_name, relationship| - related_resource = JSONAPI::Resource.resource_for(resource_type_with_module_prefix(relationship.class_name.underscore)) - opts = options.merge( - overrides[relationship_name] || { - controller: "/#{related_resource.to_s.sub(/Resource\z/, '').underscore.pluralize}" - } - ) - if relationship.is_a?(JSONAPI::Relationship::ToMany) - jsonapi_links(relationship_name, opts) - jsonapi_related_resources(relationship_name, opts) - else - jsonapi_link(relationship_name, opts) - jsonapi_related_resource(relationship_name, opts) - end - end - end -end - -JSONAPI::Resource.singleton_class.prepend(JsonapiResourceClassPatch) - -JSONAPI::Resource.register_resource_override 'api/rest/admin', 'Pop', 'Api::Rest::Admin::Pop' -JSONAPI::Resource.register_resource_override 'api/rest/admin', 'Node', 'Api::Rest::Admin::Node' -JSONAPI::Resource.register_resource_override 'api/rest/admin/billing', 'Account', 'Api::Rest::Admin::Account' -JSONAPI::Resource.register_resource_override 'api/rest/admin/billing', 'Country', 'Api::Rest::Admin::System::Country' -JSONAPI::Resource.register_resource_override 'api/rest/admin/billing', 'Network', 'Api::Rest::Admin::System::Network' - -JSONAPI::Resource.register_resource_override 'api/rest/admin/cdr', 'Dialpeer', 'Api::Rest::Admin::Dialpeer' -JSONAPI::Resource.register_resource_override 'api/rest/admin/cdr', 'Pop', 'Api::Rest::Admin::Pop' -JSONAPI::Resource.register_resource_override 'api/rest/admin/cdr', 'CustomersAuth', 'Api::Rest::Admin::CustomersAuth' -JSONAPI::Resource.register_resource_override 'api/rest/admin/cdr', 'Contractor', 'Api::Rest::Admin::Contractor' -JSONAPI::Resource.register_resource_override 'api/rest/admin/cdr', 'Account', 'Api::Rest::Admin::Account' -JSONAPI::Resource.register_resource_override 'api/rest/admin/cdr', 'Gateway', 'Api::Rest::Admin::Gateway' -JSONAPI::Resource.register_resource_override 'api/rest/admin/cdr', 'RoutingPlan', 'Api::Rest::Admin::RoutingPlan' -JSONAPI::Resource.register_resource_override 'api/rest/admin/cdr', 'Country', 'Api::Rest::Admin::System::Country' -JSONAPI::Resource.register_resource_override 'api/rest/admin/cdr', 'Network', 'Api::Rest::Admin::System::Network' -JSONAPI::Resource.register_resource_override 'api/rest/admin/cdr', 'Rateplan', 'Api::Rest::Admin::Routing::Rateplan' -JSONAPI::Resource.register_resource_override 'api/rest/admin/cdr', 'RoutingGroup', 'Api::Rest::Admin::Routing::RoutingGroup' -JSONAPI::Resource.register_resource_override 'api/rest/admin/cdr', 'Destination', 'Api::Rest::Admin::Routing::Destination' diff --git a/config/routes.rb b/config/routes.rb index a51b2278d..e2bbb9ada 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -94,83 +94,69 @@ def dasherized_resources(name, options = {}, &block) jsonapi_resources :active_calls, only: %i[index show destroy] jsonapi_resources :incoming_registrations, only: %i[index] - namespace :cdr do - jsonapi_resources :cdrs, only: %i[index show update] do - member { get :recording } - # jsonapi_relationships - patched_jsonapi_relationships - end - jsonapi_resources :auth_logs, only: %i[index show] do - end - jsonapi_resources :cdr_exports, only: %i[index show create destroy] do - jsonapi_relationships - member { get :download } - end - end - - namespace :billing do - jsonapi_resources :invoice_template - jsonapi_resources :invoices, only: %i[index show create destroy] do - jsonapi_relationships - member do - get :pdf - get :odt - end - end - jsonapi_resources :invoice_originated_destinations, only: %i[index show] - jsonapi_resources :invoice_originated_networks, only: %i[index show] - jsonapi_resources :invoice_terminated_destinations, only: %i[index show] - jsonapi_resources :invoice_terminated_networks, only: %i[index show] - jsonapi_resources :invoice_service_data, only: %i[index show] - jsonapi_resources :service_types - jsonapi_resources :services, only: %i[index show create update] - jsonapi_resources :transactions, only: %i[index show] + jsonapi_resources :cdrs, only: %i[index show update] do + jsonapi_relationships + member { get :recording } end - - namespace :system do - jsonapi_resources :timezones - jsonapi_resources :dtmf_receive_modes - jsonapi_resources :dtmf_send_modes - jsonapi_resources :sensor_levels - jsonapi_resources :sensors - jsonapi_resources :smtp_connections - jsonapi_resources :countries - jsonapi_resources :networks - jsonapi_resources :network_types + jsonapi_resources :auth_logs, only: %i[index show] do end - - namespace :equipment do - jsonapi_resources :gateway_rel100_modes - jsonapi_resources :gateway_inband_dtmf_filtering_modes - jsonapi_resources :gateway_diversion_send_modes - jsonapi_resources :gateway_network_protocol_priorities - jsonapi_resources :gateway_media_encryption_modes - jsonapi_resources :transport_protocols - jsonapi_resources :registrations - jsonapi_resources :sip_options_probers - namespace :radius do - jsonapi_resources :accounting_profiles - jsonapi_resources :auth_profiles - end + jsonapi_resources :cdr_exports, only: %i[index show create destroy] do + jsonapi_relationships + member { get :download } end - namespace :routing do - jsonapi_resources :areas - jsonapi_resources :area_prefixes - jsonapi_resources :numberlists - jsonapi_resources :numberlist_items - jsonapi_resources :routing_tag_detection_rules - jsonapi_resources :tag_actions - jsonapi_resources :rateplans - jsonapi_resources :routing_groups - jsonapi_resources :routing_tags - jsonapi_resources :routing_tag_modes - jsonapi_resources :routeset_discriminators - jsonapi_resources :destinations do - # remove relationships endpoints because they fail work with cross namespace relationships. + jsonapi_resources :invoice_template + jsonapi_resources :invoices, only: %i[index show create destroy] do + jsonapi_relationships + member do + get :pdf + get :odt end - jsonapi_resources :destination_next_rates end + jsonapi_resources :invoice_originated_destinations, only: %i[index show] + jsonapi_resources :invoice_originated_networks, only: %i[index show] + jsonapi_resources :invoice_terminated_destinations, only: %i[index show] + jsonapi_resources :invoice_terminated_networks, only: %i[index show] + jsonapi_resources :invoice_service_data, only: %i[index show] + jsonapi_resources :service_types + jsonapi_resources :services, only: %i[index show create update] + jsonapi_resources :transactions, only: %i[index show] + + jsonapi_resources :timezones + jsonapi_resources :dtmf_receive_modes + jsonapi_resources :dtmf_send_modes + jsonapi_resources :sensor_levels + jsonapi_resources :sensors + jsonapi_resources :smtp_connections + jsonapi_resources :countries + jsonapi_resources :networks + jsonapi_resources :network_types + + jsonapi_resources :gateway_rel100_modes + jsonapi_resources :gateway_inband_dtmf_filtering_modes + jsonapi_resources :gateway_diversion_send_modes + jsonapi_resources :gateway_network_protocol_priorities + jsonapi_resources :gateway_media_encryption_modes + jsonapi_resources :transport_protocols + jsonapi_resources :registrations + jsonapi_resources :sip_options_probers + + jsonapi_resources :accounting_profiles + jsonapi_resources :auth_profiles + + jsonapi_resources :areas + jsonapi_resources :area_prefixes + jsonapi_resources :numberlists + jsonapi_resources :numberlist_items + jsonapi_resources :routing_tag_detection_rules + jsonapi_resources :tag_actions + jsonapi_resources :rateplans + jsonapi_resources :routing_groups + jsonapi_resources :routing_tags + jsonapi_resources :routing_tag_modes + jsonapi_resources :routeset_discriminators + jsonapi_resources :destinations + jsonapi_resources :destination_next_rates end namespace :customer do diff --git a/spec/acceptance/rest/admin/api/equipment/radius/accounting_profiles_spec.rb b/spec/acceptance/rest/admin/api/accounting_profiles_spec.rb similarity index 80% rename from spec/acceptance/rest/admin/api/equipment/radius/accounting_profiles_spec.rb rename to spec/acceptance/rest/admin/api/accounting_profiles_spec.rb index 4dc523756..4fe915310 100644 --- a/spec/acceptance/rest/admin/api/equipment/radius/accounting_profiles_spec.rb +++ b/spec/acceptance/rest/admin/api/accounting_profiles_spec.rb @@ -14,8 +14,8 @@ required_params = %i[name server port secret timeout attempts] optional_params = %i[enable-start-accounting enable-interim-accounting interim-accounting-interval enable-stop-accounting] - get '/api/rest/admin/equipment/radius/accounting-profiles' do - jsonapi_filters Api::Rest::Admin::Equipment::Radius::AccountingProfileResource._allowed_filters + get '/api/rest/admin/accounting-profiles' do + jsonapi_filters Api::Rest::Admin::AccountingProfileResource._allowed_filters before { create_list(:accounting_profile, 2) } @@ -24,7 +24,7 @@ end end - get '/api/rest/admin/equipment/radius/accounting-profiles/:id' do + get '/api/rest/admin/accounting-profiles/:id' do let(:id) { create(:accounting_profile).id } example_request 'get specific entry' do @@ -32,7 +32,7 @@ end end - post '/api/rest/admin/equipment/radius/accounting-profiles' do + post '/api/rest/admin/accounting-profiles' do parameter :type, 'Resource type (accounting_profiles)', scope: :data, required: true jsonapi_attributes(required_params, optional_params) @@ -49,7 +49,7 @@ end end - put '/api/rest/admin/equipment/radius/accounting-profiles/:id' do + put '/api/rest/admin/accounting-profiles/:id' do parameter :type, 'Resource type (accounting_profiles)', scope: :data, required: true parameter :id, 'Accounting profile ID', scope: :data, required: true @@ -63,7 +63,7 @@ end end - delete '/api/rest/admin/equipment/radius/accounting-profiles/:id' do + delete '/api/rest/admin/accounting-profiles/:id' do let(:id) { create(:accounting_profile).id } example_request 'delete entry' do diff --git a/spec/acceptance/rest/admin/api/routing/area_prefixes_spec.rb b/spec/acceptance/rest/admin/api/area_prefixes_spec.rb similarity index 82% rename from spec/acceptance/rest/admin/api/routing/area_prefixes_spec.rb rename to spec/acceptance/rest/admin/api/area_prefixes_spec.rb index dbbda6bc7..c235da01f 100644 --- a/spec/acceptance/rest/admin/api/routing/area_prefixes_spec.rb +++ b/spec/acceptance/rest/admin/api/area_prefixes_spec.rb @@ -14,10 +14,10 @@ required_relationships = %i[area] optional_relationships = %i[] - include_context :acceptance_index_show, namespace: 'routing', type: 'area-prefixes' - include_context :acceptance_delete, namespace: 'routing', type: 'area-prefixes' + include_context :acceptance_index_show, type: 'area-prefixes' + include_context :acceptance_delete, type: 'area-prefixes' - post '/api/rest/admin/routing/area-prefixes' do + post '/api/rest/admin/area-prefixes' do parameter :type, 'Resource type (area-prefixes)', scope: :data, required: true jsonapi_attributes(required_params, optional_params) @@ -31,7 +31,7 @@ end end - put '/api/rest/admin/routing/area-prefixes/:id' do + put '/api/rest/admin/area-prefixes/:id' do parameter :type, 'Resource type (area-prefixes)', scope: :data, required: true parameter :id, 'AreaPrefix ID', scope: :data, required: true diff --git a/spec/acceptance/rest/admin/api/routing/area_spec.rb b/spec/acceptance/rest/admin/api/area_spec.rb similarity index 74% rename from spec/acceptance/rest/admin/api/routing/area_spec.rb rename to spec/acceptance/rest/admin/api/area_spec.rb index 67a3f4ab9..a3fb56ad1 100644 --- a/spec/acceptance/rest/admin/api/routing/area_spec.rb +++ b/spec/acceptance/rest/admin/api/area_spec.rb @@ -8,5 +8,5 @@ let(:collection) { create_list(:area, 2) } let(:record) { collection.first } - include_context :acceptance_index_show, namespace: 'routing', type: 'areas' + include_context :acceptance_index_show, type: 'areas' end diff --git a/spec/acceptance/rest/admin/api/equipment/radius/auth_profiles_spec.rb b/spec/acceptance/rest/admin/api/auth_profiles_spec.rb similarity index 81% rename from spec/acceptance/rest/admin/api/equipment/radius/auth_profiles_spec.rb rename to spec/acceptance/rest/admin/api/auth_profiles_spec.rb index dcf051c48..1b1c1f81c 100644 --- a/spec/acceptance/rest/admin/api/equipment/radius/auth_profiles_spec.rb +++ b/spec/acceptance/rest/admin/api/auth_profiles_spec.rb @@ -14,8 +14,8 @@ required_params = %i[name server port secret timeout attempts] optional_params = %i[enable-start-accounting enable-interim-accounting interim-accounting-interval enable-stop-accounting] - get '/api/rest/admin/equipment/radius/auth-profiles' do - jsonapi_filters Api::Rest::Admin::Equipment::Radius::AuthProfileResource._allowed_filters + get '/api/rest/admin/auth-profiles' do + jsonapi_filters Api::Rest::Admin::AuthProfileResource._allowed_filters before { create_list(:auth_profile, 2) } @@ -24,7 +24,7 @@ end end - get '/api/rest/admin/equipment/radius/auth-profiles/:id' do + get '/api/rest/admin/auth-profiles/:id' do let(:id) { create(:auth_profile).id } example_request 'get specific entry' do @@ -32,7 +32,7 @@ end end - post '/api/rest/admin/equipment/radius/auth-profiles' do + post '/api/rest/admin/auth-profiles' do parameter :type, 'Resource type (auth-profiles)', scope: :data, required: true jsonapi_attributes(required_params, optional_params) @@ -49,7 +49,7 @@ end end - put '/api/rest/admin/equipment/radius/auth-profiles/:id' do + put '/api/rest/admin/auth-profiles/:id' do parameter :type, 'Resource type (auth-profiles)', scope: :data, required: true parameter :id, 'Auth profile ID', scope: :data, required: true @@ -63,7 +63,7 @@ end end - delete '/api/rest/admin/equipment/radius/auth-profiles/:id' do + delete '/api/rest/admin/auth-profiles/:id' do let(:id) { create(:auth_profile).id } example_request 'delete entry' do diff --git a/spec/acceptance/rest/admin/api/cdr/cdr_exports_spec.rb b/spec/acceptance/rest/admin/api/cdr_exports_spec.rb similarity index 97% rename from spec/acceptance/rest/admin/api/cdr/cdr_exports_spec.rb rename to spec/acceptance/rest/admin/api/cdr_exports_spec.rb index dc55ce66b..d81c744cc 100644 --- a/spec/acceptance/rest/admin/api/cdr/cdr_exports_spec.rb +++ b/spec/acceptance/rest/admin/api/cdr_exports_spec.rb @@ -16,7 +16,7 @@ optional_params = %i[callback-url export-type] - post '/api/rest/admin/cdr/cdr-exports' do + post '/api/rest/admin/cdr-exports' do parameter :type, 'Resource type (cdr-exports)', scope: :data, required: true jsonapi_attributes(required_params, optional_params) @@ -86,7 +86,7 @@ end end - delete '/api/rest/admin/cdr/cdr-exports/:id' do + delete '/api/rest/admin/cdr-exports/:id' do let(:id) { create(:cdr_export).id } example_request 'delete entry' do diff --git a/spec/acceptance/rest/admin/api/cdr/cdrs_spec.rb b/spec/acceptance/rest/admin/api/cdrs_spec.rb similarity index 86% rename from spec/acceptance/rest/admin/api/cdr/cdrs_spec.rb rename to spec/acceptance/rest/admin/api/cdrs_spec.rb index 70fbd8a0e..9db89052f 100644 --- a/spec/acceptance/rest/admin/api/cdr/cdrs_spec.rb +++ b/spec/acceptance/rest/admin/api/cdrs_spec.rb @@ -11,8 +11,8 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'cdrs' } - get '/api/rest/admin/cdr/cdrs' do - jsonapi_filters Api::Rest::Admin::Cdr::CdrResource._allowed_filters + get '/api/rest/admin/cdrs' do + jsonapi_filters Api::Rest::Admin::CdrResource._allowed_filters before do create_list(:cdr, 2) @@ -23,7 +23,7 @@ end end - get '/api/rest/admin/cdr/cdrs/:id' do + get '/api/rest/admin/cdrs/:id' do let(:id) { create(:cdr).id } example_request 'get specific entry' do @@ -31,7 +31,7 @@ end end - get '/api/rest/admin/cdr/cdrs/:id/recording' do + get '/api/rest/admin/cdrs/:id/recording' do let(:id) { create(:cdr, audio_recorded: true).id } example_request 'get recording' do @@ -39,7 +39,7 @@ end end - patch '/api/rest/admin/cdr/cdrs/:id' do + patch '/api/rest/admin/cdrs/:id' do with_options scope: :data, with_example: true do parameter :type, 'Resource type (cdrs)', required: true parameter :id, 'CDR ID', required: true diff --git a/spec/acceptance/rest/admin/api/routing/destination_next_rates_spec.rb b/spec/acceptance/rest/admin/api/destination_next_rates_spec.rb similarity index 84% rename from spec/acceptance/rest/admin/api/routing/destination_next_rates_spec.rb rename to spec/acceptance/rest/admin/api/destination_next_rates_spec.rb index 0714b0d60..68379d3d8 100644 --- a/spec/acceptance/rest/admin/api/routing/destination_next_rates_spec.rb +++ b/spec/acceptance/rest/admin/api/destination_next_rates_spec.rb @@ -19,8 +19,8 @@ optional_params = %i[external-id] required_relationships = %i[destination] - get '/api/rest/admin/routing/destination-next-rates' do - jsonapi_filters Api::Rest::Admin::Routing::DestinationNextRateResource._allowed_filters + get '/api/rest/admin/destination-next-rates' do + jsonapi_filters Api::Rest::Admin::DestinationNextRateResource._allowed_filters before { create_list(:destination_next_rate, 2, destination: destination) } @@ -29,7 +29,7 @@ end end - get '/api/rest/admin/routing/destination-next-rates/:id' do + get '/api/rest/admin/destination-next-rates/:id' do let(:id) { create(:destination_next_rate, destination: destination).id } example_request 'get specific entry' do @@ -37,7 +37,7 @@ end end - post '/api/rest/admin/routing/destination-next-rates' do + post '/api/rest/admin/destination-next-rates' do parameter :type, 'Resource type (destinations-next-rates)', scope: :data, required: true jsonapi_attributes(required_params, optional_params) @@ -57,7 +57,7 @@ end end - put '/api/rest/admin/routing/destination-next-rates/:id' do + put '/api/rest/admin/destination-next-rates/:id' do parameter :type, 'Resource type (destinations-next-rates)', scope: :data, required: true parameter :id, 'Destination next rate ID', scope: :data, required: true @@ -71,7 +71,7 @@ end end - delete '/api/rest/admin/routing/destination-next-rates/:id' do + delete '/api/rest/admin/destination-next-rates/:id' do let(:id) { create(:destination_next_rate).id } example_request 'delete entry' do diff --git a/spec/acceptance/rest/admin/api/routing/destinations_spec.rb b/spec/acceptance/rest/admin/api/destinations_spec.rb similarity index 88% rename from spec/acceptance/rest/admin/api/routing/destinations_spec.rb rename to spec/acceptance/rest/admin/api/destinations_spec.rb index 2a9781587..2e661ada4 100644 --- a/spec/acceptance/rest/admin/api/routing/destinations_spec.rb +++ b/spec/acceptance/rest/admin/api/destinations_spec.rb @@ -23,8 +23,8 @@ required_relationships = %i[rate-group] optional_relationships = %i[routing-tag-modes] - get '/api/rest/admin/routing/destinations' do - jsonapi_filters Api::Rest::Admin::Routing::DestinationResource._allowed_filters + get '/api/rest/admin/destinations' do + jsonapi_filters Api::Rest::Admin::DestinationResource._allowed_filters before { create_list(:destination, 2) } @@ -33,7 +33,7 @@ end end - get '/api/rest/admin/routing/destinations/:id' do + get '/api/rest/admin/destinations/:id' do let(:id) { create(:destination).id } example_request 'get specific entry' do @@ -41,7 +41,7 @@ end end - post '/api/rest/admin/routing/destinations' do + post '/api/rest/admin/destinations' do parameter :type, 'Resource type (destinations)', scope: :data, required: true jsonapi_attributes(required_params, optional_params) @@ -68,7 +68,7 @@ end end - put '/api/rest/admin/routing/destinations/:id' do + put '/api/rest/admin/destinations/:id' do parameter :type, 'Resource type (destinations)', scope: :data, required: true parameter :id, 'Destination ID', scope: :data, required: true @@ -82,7 +82,7 @@ end end - delete '/api/rest/admin/routing/destinations/:id' do + delete '/api/rest/admin/destinations/:id' do let(:id) { create(:destination).id } example_request 'delete entry' do diff --git a/spec/acceptance/rest/admin/api/system/dtmf_receive_modes_spec.rb b/spec/acceptance/rest/admin/api/dtmf_receive_modes_spec.rb similarity index 76% rename from spec/acceptance/rest/admin/api/system/dtmf_receive_modes_spec.rb rename to spec/acceptance/rest/admin/api/dtmf_receive_modes_spec.rb index a83b4cdb9..0c70351b9 100644 --- a/spec/acceptance/rest/admin/api/system/dtmf_receive_modes_spec.rb +++ b/spec/acceptance/rest/admin/api/dtmf_receive_modes_spec.rb @@ -11,15 +11,15 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'dtmf-receive-modes' } - get '/api/rest/admin/system/dtmf-receive-modes' do - jsonapi_filters Api::Rest::Admin::System::DtmfReceiveModeResource._allowed_filters + get '/api/rest/admin/dtmf-receive-modes' do + jsonapi_filters Api::Rest::Admin::DtmfReceiveModeResource._allowed_filters example_request 'get listing' do expect(status).to eq(200) end end - get '/api/rest/admin/system/dtmf-receive-modes/:id' do + get '/api/rest/admin/dtmf-receive-modes/:id' do let(:id) { System::DtmfReceiveMode.first.id } example_request 'get specific entry' do diff --git a/spec/acceptance/rest/admin/api/system/dtmf_send_modes_spec.rb b/spec/acceptance/rest/admin/api/dtmf_send_modes_spec.rb similarity index 76% rename from spec/acceptance/rest/admin/api/system/dtmf_send_modes_spec.rb rename to spec/acceptance/rest/admin/api/dtmf_send_modes_spec.rb index 7ed8171d1..2d8bf5f6f 100644 --- a/spec/acceptance/rest/admin/api/system/dtmf_send_modes_spec.rb +++ b/spec/acceptance/rest/admin/api/dtmf_send_modes_spec.rb @@ -11,15 +11,15 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'dtmf-send-modes' } - get '/api/rest/admin/system/dtmf-send-modes' do - jsonapi_filters Api::Rest::Admin::System::DtmfSendModeResource._allowed_filters + get '/api/rest/admin/dtmf-send-modes' do + jsonapi_filters Api::Rest::Admin::DtmfSendModeResource._allowed_filters example_request 'get listing' do expect(status).to eq(200) end end - get '/api/rest/admin/system/dtmf-send-modes/:id' do + get '/api/rest/admin/dtmf-send-modes/:id' do let(:id) { System::DtmfSendMode.first.id } example_request 'get specific entry' do diff --git a/spec/acceptance/rest/admin/api/equipment/gateway_inband_dtmf_filtering_modes_spec.rb b/spec/acceptance/rest/admin/api/gateway_inband_dtmf_filtering_modes_spec.rb similarity index 72% rename from spec/acceptance/rest/admin/api/equipment/gateway_inband_dtmf_filtering_modes_spec.rb rename to spec/acceptance/rest/admin/api/gateway_inband_dtmf_filtering_modes_spec.rb index 0dc7c3437..ccfba42bb 100644 --- a/spec/acceptance/rest/admin/api/equipment/gateway_inband_dtmf_filtering_modes_spec.rb +++ b/spec/acceptance/rest/admin/api/gateway_inband_dtmf_filtering_modes_spec.rb @@ -11,15 +11,15 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'gateway-inband-dtmf-filtering-modes' } - get '/api/rest/admin/equipment/gateway-inband-dtmf-filtering-modes' do - jsonapi_filters Api::Rest::Admin::Equipment::GatewayInbandDtmfFilteringModeResource._allowed_filters + get '/api/rest/admin/gateway-inband-dtmf-filtering-modes' do + jsonapi_filters Api::Rest::Admin::GatewayInbandDtmfFilteringModeResource._allowed_filters example_request 'get listing' do expect(status).to eq(200) end end - get '/api/rest/admin/equipment/gateway-inband-dtmf-filtering-modes/:id' do + get '/api/rest/admin/gateway-inband-dtmf-filtering-modes/:id' do let(:id) { Equipment::GatewayInbandDtmfFilteringMode.first.id } example_request 'get specific entry' do diff --git a/spec/acceptance/rest/admin/api/equipment/gateway_media_encryption_modes_spec.rb b/spec/acceptance/rest/admin/api/gateway_media_encryption_modes_spec.rb similarity index 73% rename from spec/acceptance/rest/admin/api/equipment/gateway_media_encryption_modes_spec.rb rename to spec/acceptance/rest/admin/api/gateway_media_encryption_modes_spec.rb index 305e88378..57c0c5702 100644 --- a/spec/acceptance/rest/admin/api/equipment/gateway_media_encryption_modes_spec.rb +++ b/spec/acceptance/rest/admin/api/gateway_media_encryption_modes_spec.rb @@ -11,15 +11,15 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'gateway-media-encryption-modes' } - get '/api/rest/admin/equipment/gateway-media-encryption-modes' do - jsonapi_filters Api::Rest::Admin::Equipment::GatewayMediaEncryptionModeResource._allowed_filters + get '/api/rest/admin/gateway-media-encryption-modes' do + jsonapi_filters Api::Rest::Admin::GatewayMediaEncryptionModeResource._allowed_filters example_request 'get listing' do expect(status).to eq(200) end end - get '/api/rest/admin/equipment/gateway-media-encryption-modes/:id' do + get '/api/rest/admin/gateway-media-encryption-modes/:id' do let(:id) { Equipment::GatewayMediaEncryptionMode.first.id } example_request 'get specific entry' do diff --git a/spec/acceptance/rest/admin/api/equipment/gateway_network_protocol_priorities_spec.rb b/spec/acceptance/rest/admin/api/gateway_network_protocol_priorities_spec.rb similarity index 72% rename from spec/acceptance/rest/admin/api/equipment/gateway_network_protocol_priorities_spec.rb rename to spec/acceptance/rest/admin/api/gateway_network_protocol_priorities_spec.rb index a262a9c55..caed96ae1 100644 --- a/spec/acceptance/rest/admin/api/equipment/gateway_network_protocol_priorities_spec.rb +++ b/spec/acceptance/rest/admin/api/gateway_network_protocol_priorities_spec.rb @@ -11,15 +11,15 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'gateway-network-protocol-priorities' } - get '/api/rest/admin/equipment/gateway-network-protocol-priorities' do - jsonapi_filters Api::Rest::Admin::Equipment::GatewayNetworkProtocolPriorityResource._allowed_filters + get '/api/rest/admin/gateway-network-protocol-priorities' do + jsonapi_filters Api::Rest::Admin::GatewayNetworkProtocolPriorityResource._allowed_filters example_request 'get listing' do expect(status).to eq(200) end end - get '/api/rest/admin/equipment/gateway-network-protocol-priorities/:id' do + get '/api/rest/admin/gateway-network-protocol-priorities/:id' do let(:id) { Equipment::GatewayNetworkProtocolPriority.first.id } example_request 'get specific entry' do diff --git a/spec/acceptance/rest/admin/api/equipment/gateway_rel100_modes_spec.rb b/spec/acceptance/rest/admin/api/gateway_rel100_modes_spec.rb similarity index 75% rename from spec/acceptance/rest/admin/api/equipment/gateway_rel100_modes_spec.rb rename to spec/acceptance/rest/admin/api/gateway_rel100_modes_spec.rb index 51ffcbfc9..325377ff9 100644 --- a/spec/acceptance/rest/admin/api/equipment/gateway_rel100_modes_spec.rb +++ b/spec/acceptance/rest/admin/api/gateway_rel100_modes_spec.rb @@ -11,15 +11,15 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'gateway-rel100-modes' } - get '/api/rest/admin/equipment/gateway-rel100-modes' do - jsonapi_filters Api::Rest::Admin::Equipment::GatewayRel100ModeResource._allowed_filters + get '/api/rest/admin/gateway-rel100-modes' do + jsonapi_filters Api::Rest::Admin::GatewayRel100ModeResource._allowed_filters example_request 'get listing' do expect(status).to eq(200) end end - get '/api/rest/admin/equipment/gateway-rel100-modes/:id' do + get '/api/rest/admin/gateway-rel100-modes/:id' do let(:id) { Equipment::GatewayRel100Mode.first.id } example_request 'get specific entry' do diff --git a/spec/acceptance/rest/admin/api/billing/invoice_originated_destinations_spec.rb b/spec/acceptance/rest/admin/api/invoice_originated_destinations_spec.rb similarity index 75% rename from spec/acceptance/rest/admin/api/billing/invoice_originated_destinations_spec.rb rename to spec/acceptance/rest/admin/api/invoice_originated_destinations_spec.rb index a1f7690ba..906a19f80 100644 --- a/spec/acceptance/rest/admin/api/billing/invoice_originated_destinations_spec.rb +++ b/spec/acceptance/rest/admin/api/invoice_originated_destinations_spec.rb @@ -11,8 +11,8 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'invoice-originated-destinations' } - get '/api/rest/admin/billing/invoice-originated-destinations' do - jsonapi_filters Api::Rest::Admin::Billing::InvoiceOriginatedDestinationResource._allowed_filters + get '/api/rest/admin/invoice-originated-destinations' do + jsonapi_filters Api::Rest::Admin::InvoiceOriginatedDestinationResource._allowed_filters before { create_list(:invoice_originated_destination, 2, :filled) } @@ -21,7 +21,7 @@ end end - get '/api/rest/admin/billing/invoice-originated-destinations/:id' do + get '/api/rest/admin/invoice-originated-destinations/:id' do let(:id) { create(:invoice_originated_destination, :filled).id } example_request 'get specific entry' do diff --git a/spec/acceptance/rest/admin/api/billing/invoice_originated_networks_spec.rb b/spec/acceptance/rest/admin/api/invoice_originated_networks_spec.rb similarity index 76% rename from spec/acceptance/rest/admin/api/billing/invoice_originated_networks_spec.rb rename to spec/acceptance/rest/admin/api/invoice_originated_networks_spec.rb index 5b03ceeda..e42d0f06a 100644 --- a/spec/acceptance/rest/admin/api/billing/invoice_originated_networks_spec.rb +++ b/spec/acceptance/rest/admin/api/invoice_originated_networks_spec.rb @@ -11,8 +11,8 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'invoice-originated-networks' } - get '/api/rest/admin/billing/invoice-originated-networks' do - jsonapi_filters Api::Rest::Admin::Billing::InvoiceOriginatedNetworkResource._allowed_filters + get '/api/rest/admin/invoice-originated-networks' do + jsonapi_filters Api::Rest::Admin::InvoiceOriginatedNetworkResource._allowed_filters before { create_list(:invoice_originated_network, 2, :filled) } @@ -21,7 +21,7 @@ end end - get '/api/rest/admin/billing/invoice-originated-networks/:id' do + get '/api/rest/admin/invoice-originated-networks/:id' do let(:id) { create(:invoice_originated_network, :filled).id } example_request 'get specific entry' do diff --git a/spec/acceptance/rest/admin/api/billing/invoice_service_data_spec.rb b/spec/acceptance/rest/admin/api/invoice_service_data_spec.rb similarity index 77% rename from spec/acceptance/rest/admin/api/billing/invoice_service_data_spec.rb rename to spec/acceptance/rest/admin/api/invoice_service_data_spec.rb index 2f6562ae8..fe15b5348 100644 --- a/spec/acceptance/rest/admin/api/billing/invoice_service_data_spec.rb +++ b/spec/acceptance/rest/admin/api/invoice_service_data_spec.rb @@ -11,8 +11,8 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'invoice-service-data' } - get '/api/rest/admin/billing/invoice-service-data' do - jsonapi_filters Api::Rest::Admin::Billing::InvoiceServiceDatumResource._allowed_filters + get '/api/rest/admin/invoice-service-data' do + jsonapi_filters Api::Rest::Admin::InvoiceServiceDatumResource._allowed_filters before { create_list(:invoice_service_data, 2, :filled) } @@ -21,7 +21,7 @@ end end - get '/api/rest/admin/billing/invoice-service-data/:id' do + get '/api/rest/admin/invoice-service-data/:id' do let(:id) { create(:invoice_service_data, :filled).id } example_request 'get specific entry' do diff --git a/spec/acceptance/rest/admin/api/billing/invoice_template_spec.rb b/spec/acceptance/rest/admin/api/invoice_template_spec.rb similarity index 79% rename from spec/acceptance/rest/admin/api/billing/invoice_template_spec.rb rename to spec/acceptance/rest/admin/api/invoice_template_spec.rb index 569482db3..b4820ca0c 100644 --- a/spec/acceptance/rest/admin/api/billing/invoice_template_spec.rb +++ b/spec/acceptance/rest/admin/api/invoice_template_spec.rb @@ -11,8 +11,8 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'invoice-templates' } - get '/api/rest/admin/billing/invoice-template' do - jsonapi_filters Api::Rest::Admin::Billing::InvoiceTemplateResource._allowed_filters + get '/api/rest/admin/invoice-template' do + jsonapi_filters Api::Rest::Admin::InvoiceTemplateResource._allowed_filters before { create_list(:invoice_template, 2) } @@ -21,7 +21,7 @@ end end - get '/api/rest/admin/billing/invoice-template/:id' do + get '/api/rest/admin/invoice-template/:id' do let(:id) { create(:invoice_template).id } example_request 'get specific entry' do @@ -29,7 +29,7 @@ end end - post '/api/rest/admin/billing/invoice-template' do + post '/api/rest/admin/invoice-template' do parameter :type, 'Resource type (invoice-templates)', scope: :data, required: true jsonapi_attributes(%i[name filename], []) @@ -42,7 +42,7 @@ end end - put '/api/rest/admin/billing/invoice-template/:id' do + put '/api/rest/admin/invoice-template/:id' do parameter :type, 'Resource type (invoice-templates)', scope: :data, required: true parameter :id, 'Invoice template ID', scope: :data, required: true @@ -56,7 +56,7 @@ end end - delete '/api/rest/admin/billing/invoice-template/:id' do + delete '/api/rest/admin/invoice-template/:id' do let(:id) { create(:invoice_template).id } example_request 'delete entry' do diff --git a/spec/acceptance/rest/admin/api/billing/invoice_terminated_destinations_spec.rb b/spec/acceptance/rest/admin/api/invoice_terminated_destinations_spec.rb similarity index 75% rename from spec/acceptance/rest/admin/api/billing/invoice_terminated_destinations_spec.rb rename to spec/acceptance/rest/admin/api/invoice_terminated_destinations_spec.rb index 92ca4a8b7..11bd2df68 100644 --- a/spec/acceptance/rest/admin/api/billing/invoice_terminated_destinations_spec.rb +++ b/spec/acceptance/rest/admin/api/invoice_terminated_destinations_spec.rb @@ -11,8 +11,8 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'invoice-terminated-destinations' } - get '/api/rest/admin/billing/invoice-terminated-destinations' do - jsonapi_filters Api::Rest::Admin::Billing::InvoiceTerminatedDestinationResource._allowed_filters + get '/api/rest/admin/invoice-terminated-destinations' do + jsonapi_filters Api::Rest::Admin::InvoiceTerminatedDestinationResource._allowed_filters before { create_list(:invoice_terminated_destination, 2, :filled) } @@ -21,7 +21,7 @@ end end - get '/api/rest/admin/billing/invoice-terminated-destinations/:id' do + get '/api/rest/admin/invoice-terminated-destinations/:id' do let(:id) { create(:invoice_terminated_destination, :filled).id } example_request 'get specific entry' do diff --git a/spec/acceptance/rest/admin/api/billing/invoice_terminated_networks_spec.rb b/spec/acceptance/rest/admin/api/invoice_terminated_networks_spec.rb similarity index 76% rename from spec/acceptance/rest/admin/api/billing/invoice_terminated_networks_spec.rb rename to spec/acceptance/rest/admin/api/invoice_terminated_networks_spec.rb index 35ca67cf9..2116dcc4a 100644 --- a/spec/acceptance/rest/admin/api/billing/invoice_terminated_networks_spec.rb +++ b/spec/acceptance/rest/admin/api/invoice_terminated_networks_spec.rb @@ -11,8 +11,8 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'invoice-terminated-networks' } - get '/api/rest/admin/billing/invoice-terminated-networks' do - jsonapi_filters Api::Rest::Admin::Billing::InvoiceTerminatedNetworkResource._allowed_filters + get '/api/rest/admin/invoice-terminated-networks' do + jsonapi_filters Api::Rest::Admin::InvoiceTerminatedNetworkResource._allowed_filters before { create_list(:invoice_terminated_network, 2, :filled) } @@ -21,7 +21,7 @@ end end - get '/api/rest/admin/billing/invoice-terminated-networks/:id' do + get '/api/rest/admin/invoice-terminated-networks/:id' do let(:id) { create(:invoice_terminated_network, :filled).id } example_request 'get specific entry' do diff --git a/spec/acceptance/rest/admin/api/billing/invoices_spec.rb b/spec/acceptance/rest/admin/api/invoices_spec.rb similarity index 83% rename from spec/acceptance/rest/admin/api/billing/invoices_spec.rb rename to spec/acceptance/rest/admin/api/invoices_spec.rb index e6f5059d8..691b45697 100644 --- a/spec/acceptance/rest/admin/api/billing/invoices_spec.rb +++ b/spec/acceptance/rest/admin/api/invoices_spec.rb @@ -11,8 +11,8 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'invoices' } - get '/api/rest/admin/billing/invoices' do - jsonapi_filters Api::Rest::Admin::Billing::InvoiceResource._allowed_filters + get '/api/rest/admin/invoices' do + jsonapi_filters Api::Rest::Admin::InvoiceResource._allowed_filters before do create_list(:invoice, 2, :approved, :auto_full, :with_vendor_account) @@ -23,7 +23,7 @@ end end - get '/api/rest/admin/billing/invoices/:id' do + get '/api/rest/admin/invoices/:id' do let(:id) { create(:invoice, :approved, :auto_full, :with_vendor_account).id } example_request 'get specific entry' do @@ -31,7 +31,7 @@ end end - post '/api/rest/admin/billing/invoices' do + post '/api/rest/admin/invoices' do parameter :type, 'Resource type (invoices)', scope: :data, required: true jsonapi_attributes(%i[start-date end-date], []) @@ -47,7 +47,7 @@ end end - delete '/api/rest/admin/billing/invoices/:id' do + delete '/api/rest/admin/invoices/:id' do let(:id) { create(:invoice, :approved, :auto_full, :with_vendor_account).id } example_request 'delete entry' do diff --git a/spec/acceptance/rest/admin/api/system/network_types_spec.rb b/spec/acceptance/rest/admin/api/network_types_spec.rb similarity index 82% rename from spec/acceptance/rest/admin/api/system/network_types_spec.rb rename to spec/acceptance/rest/admin/api/network_types_spec.rb index f20d70246..5a347de92 100644 --- a/spec/acceptance/rest/admin/api/system/network_types_spec.rb +++ b/spec/acceptance/rest/admin/api/network_types_spec.rb @@ -13,8 +13,8 @@ required_params = %i[name] - get '/api/rest/admin/system/network-types' do - jsonapi_filters Api::Rest::Admin::System::NetworkTypeResource._allowed_filters + get '/api/rest/admin/network-types' do + jsonapi_filters Api::Rest::Admin::NetworkTypeResource._allowed_filters before do FactoryBot.create_list(:network_type, 2) @@ -25,7 +25,7 @@ end end - get '/api/rest/admin/system/network-types/:id' do + get '/api/rest/admin/network-types/:id' do let(:id) { FactoryBot.create(:network_type).id } example_request 'get specific entry' do @@ -33,7 +33,7 @@ end end - post '/api/rest/admin/system/network-types' do + post '/api/rest/admin/network-types' do parameter :type, 'Resource type (network-types)', scope: :data, required: true jsonapi_attributes(required_params, []) @@ -47,7 +47,7 @@ end end - put '/api/rest/admin/system/network-types/:id' do + put '/api/rest/admin/network-types/:id' do parameter :type, 'Resource type (network-types)', scope: :data, required: true parameter :id, 'Network Type ID', scope: :data, required: true @@ -62,7 +62,7 @@ end end - delete '/api/rest/admin/system/network-types/:id' do + delete '/api/rest/admin/network-types/:id' do let(:id) { FactoryBot.create(:network_type).id } example_request 'delete entry' do diff --git a/spec/acceptance/rest/admin/api/system/networks_spec.rb b/spec/acceptance/rest/admin/api/networks_spec.rb similarity index 86% rename from spec/acceptance/rest/admin/api/system/networks_spec.rb rename to spec/acceptance/rest/admin/api/networks_spec.rb index b21c1dc47..d52659f31 100644 --- a/spec/acceptance/rest/admin/api/system/networks_spec.rb +++ b/spec/acceptance/rest/admin/api/networks_spec.rb @@ -14,8 +14,8 @@ required_params = %i[name] required_relationships = %i[network-type] - get '/api/rest/admin/system/networks' do - jsonapi_filters Api::Rest::Admin::System::NetworkResource._allowed_filters + get '/api/rest/admin/networks' do + jsonapi_filters Api::Rest::Admin::NetworkResource._allowed_filters before do System::NetworkPrefix.delete_all @@ -28,7 +28,7 @@ end end - get '/api/rest/admin/system/networks/:id' do + get '/api/rest/admin/networks/:id' do let!(:network) { create(:network) } let(:id) { network.id } @@ -37,7 +37,7 @@ end end - post '/api/rest/admin/system/networks' do + post '/api/rest/admin/networks' do parameter :type, 'Resource type (networks)', scope: :data, required: true jsonapi_attributes(required_params, []) @@ -53,7 +53,7 @@ end end - put '/api/rest/admin/system/networks/:id' do + put '/api/rest/admin/networks/:id' do parameter :type, 'Resource type (networks)', scope: :data, required: true parameter :id, 'Network ID', scope: :data, required: true @@ -71,7 +71,7 @@ end end - delete '/api/rest/admin/system/networks/:id' do + delete '/api/rest/admin/networks/:id' do let(:id) { create(:network).id } example_request 'delete entry' do diff --git a/spec/acceptance/rest/admin/api/routing/numberlist_items_spec.rb b/spec/acceptance/rest/admin/api/numberlist_items_spec.rb similarity index 80% rename from spec/acceptance/rest/admin/api/routing/numberlist_items_spec.rb rename to spec/acceptance/rest/admin/api/numberlist_items_spec.rb index 2cbb8084f..bb40f6e7e 100644 --- a/spec/acceptance/rest/admin/api/routing/numberlist_items_spec.rb +++ b/spec/acceptance/rest/admin/api/numberlist_items_spec.rb @@ -23,8 +23,8 @@ tag-action ] - get '/api/rest/admin/routing/numberlist-items' do - jsonapi_filters Api::Rest::Admin::Routing::NumberlistItemResource._allowed_filters + get '/api/rest/admin/numberlist-items' do + jsonapi_filters Api::Rest::Admin::NumberlistItemResource._allowed_filters let(:collection) { create_list(:numberlist_item, 2) } @@ -33,7 +33,7 @@ end end - get '/api/rest/admin/routing/numberlist-items/:id' do + get '/api/rest/admin/numberlist-items/:id' do let(:id) { record.id } example_request 'get specific entry' do @@ -41,9 +41,9 @@ end end - include_context :acceptance_delete, namespace: 'routing', type: 'numberlist-items' + include_context :acceptance_delete, type: 'numberlist-items' - post '/api/rest/admin/routing/numberlist-items' do + post '/api/rest/admin/numberlist-items' do parameter :type, 'Resource type (numberlist-items)', scope: :data, required: true jsonapi_attributes(required_params, optional_params) @@ -57,7 +57,7 @@ end end - put '/api/rest/admin/routing/numberlist-items/:id' do + put '/api/rest/admin/numberlist-items/:id' do parameter :type, 'Resource type (numberlist-items)', scope: :data, required: true parameter :id, 'Numberlist Item ID', scope: :data, required: true diff --git a/spec/acceptance/rest/admin/api/routing/numberlists_spec.rb b/spec/acceptance/rest/admin/api/numberlists_spec.rb similarity index 84% rename from spec/acceptance/rest/admin/api/routing/numberlists_spec.rb rename to spec/acceptance/rest/admin/api/numberlists_spec.rb index 0118d7950..b76837689 100644 --- a/spec/acceptance/rest/admin/api/routing/numberlists_spec.rb +++ b/spec/acceptance/rest/admin/api/numberlists_spec.rb @@ -30,10 +30,10 @@ tag-action ] - include_context :acceptance_index_show, namespace: 'routing', type: 'numberlists' - include_context :acceptance_delete, namespace: 'routing', type: 'numberlists' + include_context :acceptance_index_show, type: 'numberlists' + include_context :acceptance_delete, type: 'numberlists' - post '/api/rest/admin/routing/numberlists' do + post '/api/rest/admin/numberlists' do parameter :type, 'Resource type (numberlist)', scope: :data, required: true jsonapi_attributes(required_params, optional_params) @@ -46,7 +46,7 @@ end end - put '/api/rest/admin/routing/numberlists/:id' do + put '/api/rest/admin/numberlists/:id' do parameter :type, 'Resource type (numberlist)', scope: :data, required: true parameter :id, 'Customer Auth ID', scope: :data, required: true diff --git a/spec/acceptance/rest/admin/api/routing/rateplans_spec.rb b/spec/acceptance/rest/admin/api/rateplans_spec.rb similarity index 83% rename from spec/acceptance/rest/admin/api/routing/rateplans_spec.rb rename to spec/acceptance/rest/admin/api/rateplans_spec.rb index 2d2006ac5..c72337f4e 100644 --- a/spec/acceptance/rest/admin/api/routing/rateplans_spec.rb +++ b/spec/acceptance/rest/admin/api/rateplans_spec.rb @@ -11,8 +11,8 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'rateplans' } - get '/api/rest/admin/routing/rateplans' do - jsonapi_filters Api::Rest::Admin::Routing::RateplanResource._allowed_filters + get '/api/rest/admin/rateplans' do + jsonapi_filters Api::Rest::Admin::RateplanResource._allowed_filters before { create_list(:rateplan, 2) } @@ -21,7 +21,7 @@ end end - get '/api/rest/admin/routing/rateplans/:id' do + get '/api/rest/admin/rateplans/:id' do let(:id) { create(:rateplan).id } example_request 'get specific entry' do @@ -29,7 +29,7 @@ end end - post '/api/rest/admin/routing/rateplans' do + post '/api/rest/admin/rateplans' do parameter :type, 'Resource type (rateplans)', scope: :data, required: true jsonapi_attributes([:name], [:'profit-control-mode-id']) @@ -43,7 +43,7 @@ end end - put '/api/rest/admin/routing/rateplans/:id' do + put '/api/rest/admin/rateplans/:id' do parameter :type, 'Resource type (rateplans)', scope: :data, required: true parameter :id, 'Rateplan ID', scope: :data, required: true @@ -59,7 +59,7 @@ end end - delete '/api/rest/admin/routing/rateplans/:id' do + delete '/api/rest/admin/rateplans/:id' do let(:id) { create(:rateplan).id } example_request 'delete entry' do diff --git a/spec/acceptance/rest/admin/api/routing/routeset_discriminators_spec.rb b/spec/acceptance/rest/admin/api/routeset_discriminators_spec.rb similarity index 78% rename from spec/acceptance/rest/admin/api/routing/routeset_discriminators_spec.rb rename to spec/acceptance/rest/admin/api/routeset_discriminators_spec.rb index 8ff82ea4d..27ddffbfa 100644 --- a/spec/acceptance/rest/admin/api/routing/routeset_discriminators_spec.rb +++ b/spec/acceptance/rest/admin/api/routeset_discriminators_spec.rb @@ -11,8 +11,8 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'routeset-discriminators' } - get '/api/rest/admin/routing/routeset-discriminators' do - jsonapi_filters Api::Rest::Admin::Routing::RoutesetDiscriminatorResource._allowed_filters + get '/api/rest/admin/routeset-discriminators' do + jsonapi_filters Api::Rest::Admin::RoutesetDiscriminatorResource._allowed_filters before { create_list(:routeset_discriminator, 2) } @@ -21,7 +21,7 @@ end end - get '/api/rest/admin/routing/routeset-discriminators/:id' do + get '/api/rest/admin/routeset-discriminators/:id' do let(:id) { create(:routeset_discriminator).id } example_request 'get specific entry' do @@ -29,7 +29,7 @@ end end - post '/api/rest/admin/routing/routeset-discriminators' do + post '/api/rest/admin/routeset-discriminators' do parameter :type, 'Resource type (routeset-discriminators)', scope: :data, required: true jsonapi_attributes([:name], []) @@ -41,7 +41,7 @@ end end - put '/api/rest/admin/routing/routeset-discriminators/:id' do + put '/api/rest/admin/routeset-discriminators/:id' do parameter :type, 'Resource type (routeset-discriminators)', scope: :data, required: true parameter :id, 'Routing group ID', scope: :data, required: true @@ -55,7 +55,7 @@ end end - delete '/api/rest/admin/routing/routeset-discriminators/:id' do + delete '/api/rest/admin/routeset-discriminators/:id' do let(:id) { create(:routeset_discriminator).id } example_request 'delete entry' do diff --git a/spec/acceptance/rest/admin/api/routing/routing_groups_spec.rb b/spec/acceptance/rest/admin/api/routing_groups_spec.rb similarity index 79% rename from spec/acceptance/rest/admin/api/routing/routing_groups_spec.rb rename to spec/acceptance/rest/admin/api/routing_groups_spec.rb index c86bfdb7c..5d1ab46f2 100644 --- a/spec/acceptance/rest/admin/api/routing/routing_groups_spec.rb +++ b/spec/acceptance/rest/admin/api/routing_groups_spec.rb @@ -11,8 +11,8 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'routing-groups' } - get '/api/rest/admin/routing/routing-groups' do - jsonapi_filters Api::Rest::Admin::Routing::RoutingGroupResource._allowed_filters + get '/api/rest/admin/routing-groups' do + jsonapi_filters Api::Rest::Admin::RoutingGroupResource._allowed_filters before { create_list(:routing_group, 2) } @@ -21,7 +21,7 @@ end end - get '/api/rest/admin/routing/routing-groups/:id' do + get '/api/rest/admin/routing-groups/:id' do let(:id) { create(:routing_group).id } example_request 'get specific entry' do @@ -29,7 +29,7 @@ end end - post '/api/rest/admin/routing/routing-groups' do + post '/api/rest/admin/routing-groups' do parameter :type, 'Resource type (routing-groups)', scope: :data, required: true jsonapi_attributes([:name], []) @@ -41,7 +41,7 @@ end end - put '/api/rest/admin/routing/routing-groups/:id' do + put '/api/rest/admin/routing-groups/:id' do parameter :type, 'Resource type (routing-groups)', scope: :data, required: true parameter :id, 'Routing group ID', scope: :data, required: true @@ -55,7 +55,7 @@ end end - delete '/api/rest/admin/routing/routing-groups/:id' do + delete '/api/rest/admin/routing-groups/:id' do let(:id) { create(:routing_group).id } example_request 'delete entry' do diff --git a/spec/acceptance/rest/admin/api/routing/routing_tag_detection_rules_spec.rb b/spec/acceptance/rest/admin/api/routing_tag_detection_rules_spec.rb similarity index 80% rename from spec/acceptance/rest/admin/api/routing/routing_tag_detection_rules_spec.rb rename to spec/acceptance/rest/admin/api/routing_tag_detection_rules_spec.rb index 8694e1576..592c00246 100644 --- a/spec/acceptance/rest/admin/api/routing/routing_tag_detection_rules_spec.rb +++ b/spec/acceptance/rest/admin/api/routing_tag_detection_rules_spec.rb @@ -22,10 +22,10 @@ required_relationships = %i[] optional_relationships = %i[src-area dst-area tag-action routing-tag-modes] - include_context :acceptance_index_show, namespace: 'routing', type: 'routing-tag-detection-rules' - include_context :acceptance_delete, namespace: 'routing', type: 'routing-tag-detection-rules' + include_context :acceptance_index_show, type: 'routing-tag-detection-rules' + include_context :acceptance_delete, type: 'routing-tag-detection-rules' - post '/api/rest/admin/routing/routing-tag-detection-rules' do + post '/api/rest/admin/routing-tag-detection-rules' do parameter :type, 'Resource type (routing-tag-detection-rules)', scope: :data, required: true jsonapi_attributes(required_params, optional_params) @@ -36,7 +36,7 @@ end end - put '/api/rest/admin/routing/routing-tag-detection-rules/:id' do + put '/api/rest/admin/routing-tag-detection-rules/:id' do parameter :type, 'Resource type (routing-tag-detection-rules)', scope: :data, required: true parameter :id, 'ID', scope: :data, required: true diff --git a/spec/acceptance/rest/admin/api/routing/routing_tag_modes_spec.rb b/spec/acceptance/rest/admin/api/routing_tag_modes_spec.rb similarity index 74% rename from spec/acceptance/rest/admin/api/routing/routing_tag_modes_spec.rb rename to spec/acceptance/rest/admin/api/routing_tag_modes_spec.rb index e7f057931..6189ec175 100644 --- a/spec/acceptance/rest/admin/api/routing/routing_tag_modes_spec.rb +++ b/spec/acceptance/rest/admin/api/routing_tag_modes_spec.rb @@ -8,5 +8,5 @@ let(:collection) { Routing::RoutingTagMode.all } let(:record) { Routing::RoutingTagMode.take } - include_context :acceptance_index_show, namespace: 'routing', type: 'routing-tag-modes' + include_context :acceptance_index_show, type: 'routing-tag-modes' end diff --git a/spec/acceptance/rest/admin/api/routing/routing_tags_spec.rb b/spec/acceptance/rest/admin/api/routing_tags_spec.rb similarity index 81% rename from spec/acceptance/rest/admin/api/routing/routing_tags_spec.rb rename to spec/acceptance/rest/admin/api/routing_tags_spec.rb index ca7956241..8c2141d0e 100644 --- a/spec/acceptance/rest/admin/api/routing/routing_tags_spec.rb +++ b/spec/acceptance/rest/admin/api/routing_tags_spec.rb @@ -18,10 +18,10 @@ optional_relationships = %i[] - include_context :acceptance_index_show, namespace: 'routing', type: 'routing-tags' - include_context :acceptance_delete, namespace: 'routing', type: 'routing-tags' + include_context :acceptance_index_show, type: 'routing-tags' + include_context :acceptance_delete, type: 'routing-tags' - post '/api/rest/admin/routing/routing-tags' do + post '/api/rest/admin/routing-tags' do parameter :type, 'Resource type (routing-tags)', scope: :data, required: true jsonapi_attributes(required_params, optional_params) @@ -34,7 +34,7 @@ end end - put '/api/rest/admin/routing/routing-tags/:id' do + put '/api/rest/admin/routing-tags/:id' do parameter :type, 'Resource type (routing-tags)', scope: :data, required: true parameter :id, 'Customer Auth ID', scope: :data, required: true diff --git a/spec/acceptance/rest/admin/api/system/sensor_levels_spec.rb b/spec/acceptance/rest/admin/api/sensor_levels_spec.rb similarity index 77% rename from spec/acceptance/rest/admin/api/system/sensor_levels_spec.rb rename to spec/acceptance/rest/admin/api/sensor_levels_spec.rb index 47c6990e8..41e2113b7 100644 --- a/spec/acceptance/rest/admin/api/system/sensor_levels_spec.rb +++ b/spec/acceptance/rest/admin/api/sensor_levels_spec.rb @@ -11,15 +11,15 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'sensor-levels' } - get '/api/rest/admin/system/sensor-levels' do - jsonapi_filters Api::Rest::Admin::System::SensorLevelResource._allowed_filters + get '/api/rest/admin/sensor-levels' do + jsonapi_filters Api::Rest::Admin::SensorLevelResource._allowed_filters example_request 'get listing' do expect(status).to eq(200) end end - get '/api/rest/admin/system/sensor-levels/:id' do + get '/api/rest/admin/sensor-levels/:id' do let(:id) { System::SensorLevel.first.id } example_request 'get specific entry' do diff --git a/spec/acceptance/rest/admin/api/system/sensors_spec.rb b/spec/acceptance/rest/admin/api/sensors_spec.rb similarity index 83% rename from spec/acceptance/rest/admin/api/system/sensors_spec.rb rename to spec/acceptance/rest/admin/api/sensors_spec.rb index 7b34cae86..3c52c1750 100644 --- a/spec/acceptance/rest/admin/api/system/sensors_spec.rb +++ b/spec/acceptance/rest/admin/api/sensors_spec.rb @@ -14,8 +14,8 @@ required_params = %i[name mode-id target-ip source-ip] optional_params = %i[source-interface target-mac use-routing] - get '/api/rest/admin/system/sensors' do - jsonapi_filters Api::Rest::Admin::System::SensorResource._allowed_filters + get '/api/rest/admin/sensors' do + jsonapi_filters Api::Rest::Admin::SensorResource._allowed_filters before { create_list(:sensor, 2) } @@ -24,7 +24,7 @@ end end - get '/api/rest/admin/system/sensors/:id' do + get '/api/rest/admin/sensors/:id' do let(:id) { create(:sensor).id } example_request 'get specific entry' do @@ -32,7 +32,7 @@ end end - post '/api/rest/admin/system/sensors' do + post '/api/rest/admin/sensors' do parameter :type, 'Resource type (sensors)', scope: :data, required: true jsonapi_attributes(required_params, optional_params) @@ -47,7 +47,7 @@ end end - put '/api/rest/admin/system/sensors/:id' do + put '/api/rest/admin/sensors/:id' do parameter :type, 'Resource type (sensors)', scope: :data, required: true parameter :id, 'Sensor ID', scope: :data, required: true @@ -61,7 +61,7 @@ end end - delete '/api/rest/admin/system/sensors/:id' do + delete '/api/rest/admin/sensors/:id' do let(:id) { create(:sensor).id } example_request 'delete entry' do diff --git a/spec/acceptance/rest/admin/api/billing/service_types_spec.rb b/spec/acceptance/rest/admin/api/service_types_spec.rb similarity index 82% rename from spec/acceptance/rest/admin/api/billing/service_types_spec.rb rename to spec/acceptance/rest/admin/api/service_types_spec.rb index 4ce5d505b..dc1255e4e 100644 --- a/spec/acceptance/rest/admin/api/billing/service_types_spec.rb +++ b/spec/acceptance/rest/admin/api/service_types_spec.rb @@ -11,8 +11,8 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'service-types' } - get '/api/rest/admin/billing/service-types' do - jsonapi_filters Api::Rest::Admin::Billing::ServiceTypeResource._allowed_filters + get '/api/rest/admin/service-types' do + jsonapi_filters Api::Rest::Admin::ServiceTypeResource._allowed_filters before do create_list(:service_type, 2) @@ -23,7 +23,7 @@ end end - get '/api/rest/admin/billing/service-types/:id' do + get '/api/rest/admin/service-types/:id' do let(:id) { create(:service_type).id } example_request 'get specific entry' do @@ -31,7 +31,7 @@ end end - post '/api/rest/admin/billing/service-types' do + post '/api/rest/admin/service-types' do parameter :type, 'Resource type (service-types)', scope: :data, required: true jsonapi_attributes(%i[name provisioning-class], %i[force-renew variables]) @@ -44,7 +44,7 @@ end end - put '/api/rest/admin/billing/service-types/:id' do + put '/api/rest/admin/service-types/:id' do parameter :type, 'Resource type (service-types)', scope: :data, required: true parameter :id, 'Service type ID', scope: :data, required: true @@ -59,7 +59,7 @@ end end - delete '/api/rest/admin/billing/service-types/:id' do + delete '/api/rest/admin/service-types/:id' do let(:id) { create(:service_type).id } example_request 'delete entry' do diff --git a/spec/acceptance/rest/admin/api/billing/services_spec.rb b/spec/acceptance/rest/admin/api/services_spec.rb similarity index 86% rename from spec/acceptance/rest/admin/api/billing/services_spec.rb rename to spec/acceptance/rest/admin/api/services_spec.rb index a65312a4c..4c30d2273 100644 --- a/spec/acceptance/rest/admin/api/billing/services_spec.rb +++ b/spec/acceptance/rest/admin/api/services_spec.rb @@ -11,8 +11,8 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'services' } - get '/api/rest/admin/billing/services' do - jsonapi_filters Api::Rest::Admin::Billing::ServiceResource._allowed_filters + get '/api/rest/admin/services' do + jsonapi_filters Api::Rest::Admin::ServiceResource._allowed_filters before do create_list(:service, 2) @@ -23,7 +23,7 @@ end end - get '/api/rest/admin/billing/services/:id' do + get '/api/rest/admin/services/:id' do let(:id) { create(:service).id } example_request 'get specific entry' do @@ -31,7 +31,7 @@ end end - post '/api/rest/admin/billing/services' do + post '/api/rest/admin/services' do parameter :type, 'Resource type (services)', scope: :data, required: true jsonapi_attributes(%i[name initial-price renew-price], %i[renew-at renew-period variables]) @@ -50,7 +50,7 @@ end end - put '/api/rest/admin/billing/services/:id' do + put '/api/rest/admin/services/:id' do parameter :type, 'Resource type (services)', scope: :data, required: true parameter :id, 'Service type ID', scope: :data, required: true diff --git a/spec/acceptance/rest/admin/api/equipment/sip_options_probers_spec.rb b/spec/acceptance/rest/admin/api/sip_options_probers_spec.rb similarity index 85% rename from spec/acceptance/rest/admin/api/equipment/sip_options_probers_spec.rb rename to spec/acceptance/rest/admin/api/sip_options_probers_spec.rb index 81790cfe9..6f626a958 100644 --- a/spec/acceptance/rest/admin/api/equipment/sip_options_probers_spec.rb +++ b/spec/acceptance/rest/admin/api/sip_options_probers_spec.rb @@ -32,8 +32,8 @@ required_relationships = %i[transport-protocol proxy-transport-protocol] optional_relationships = %i[node pop] - get '/api/rest/admin/equipment/sip-options-probers' do - jsonapi_filters Api::Rest::Admin::Equipment::SipOptionsProberResource._allowed_filters + get '/api/rest/admin/sip-options-probers' do + jsonapi_filters Api::Rest::Admin::SipOptionsProberResource._allowed_filters let!(:sip_options_probers) { create_list(:sip_options_prober, 2) } @@ -42,7 +42,7 @@ end end - get '/api/rest/admin/equipment/sip-options-probers/:id' do + get '/api/rest/admin/sip-options-probers/:id' do let(:id) { create(:sip_options_prober).id } example_request 'get specific entry', timezone: Time.zone do @@ -50,7 +50,7 @@ end end - post '/api/rest/admin/equipment/sip-options-probers' do + post '/api/rest/admin/sip-options-probers' do parameter :type, 'Resource type (sip-options-probers)', scope: :data, required: true jsonapi_attributes(required_params, optional_params) @@ -69,7 +69,7 @@ end end - put '/api/rest/admin/equipment/sip-options-probers/:id' do + put '/api/rest/admin/sip-options-probers/:id' do parameter :type, 'Resource type (sip-options-probers)', scope: :data, required: true parameter :id, 'Sip Options Prober ID', scope: :data, required: true @@ -84,7 +84,7 @@ end end - delete '/api/rest/admin/equipment/sip-options-probers/:id' do + delete '/api/rest/admin/sip-options-probers/:id' do let(:id) { create(:sip_options_prober).id } example_request 'delete entry' do diff --git a/spec/acceptance/rest/admin/api/system/smtp_connections_spec.rb b/spec/acceptance/rest/admin/api/smtp_connections_spec.rb similarity index 81% rename from spec/acceptance/rest/admin/api/system/smtp_connections_spec.rb rename to spec/acceptance/rest/admin/api/smtp_connections_spec.rb index a16342b8f..3efa3c999 100644 --- a/spec/acceptance/rest/admin/api/system/smtp_connections_spec.rb +++ b/spec/acceptance/rest/admin/api/smtp_connections_spec.rb @@ -14,8 +14,8 @@ required_params = %i[name host port from-address] optional_params = %i[auth-user auth-password global] - get '/api/rest/admin/system/smtp-connections' do - jsonapi_filters Api::Rest::Admin::System::SmtpConnectionResource._allowed_filters + get '/api/rest/admin/smtp-connections' do + jsonapi_filters Api::Rest::Admin::SmtpConnectionResource._allowed_filters before { create_list(:smtp_connection, 2) } @@ -24,7 +24,7 @@ end end - get '/api/rest/admin/system/smtp-connections/:id' do + get '/api/rest/admin/smtp-connections/:id' do let(:id) { create(:smtp_connection).id } example_request 'get specific entry' do @@ -32,7 +32,7 @@ end end - post '/api/rest/admin/system/smtp-connections' do + post '/api/rest/admin/smtp-connections' do parameter :type, 'Resource type (smtp-connections)', scope: :data, required: true jsonapi_attributes(required_params, optional_params) @@ -47,7 +47,7 @@ end end - put '/api/rest/admin/system/smtp-connections/:id' do + put '/api/rest/admin/smtp-connections/:id' do parameter :type, 'Resource type (smtp-connections)', scope: :data, required: true parameter :id, 'Smtp connection ID', scope: :data, required: true @@ -61,7 +61,7 @@ end end - delete '/api/rest/admin/system/smtp-connections/:id' do + delete '/api/rest/admin/smtp-connections/:id' do let(:id) { create(:smtp_connection).id } example_request 'delete entry' do diff --git a/spec/acceptance/rest/admin/api/routing/tag_actions_spec.rb b/spec/acceptance/rest/admin/api/tag_actions_spec.rb similarity index 74% rename from spec/acceptance/rest/admin/api/routing/tag_actions_spec.rb rename to spec/acceptance/rest/admin/api/tag_actions_spec.rb index 25bf9c515..602d0758d 100644 --- a/spec/acceptance/rest/admin/api/routing/tag_actions_spec.rb +++ b/spec/acceptance/rest/admin/api/tag_actions_spec.rb @@ -8,5 +8,5 @@ let(:collection) { Routing::TagAction.all } let(:record) { Routing::TagAction.take } - include_context :acceptance_index_show, namespace: 'routing', type: 'tag-actions' + include_context :acceptance_index_show, type: 'tag-actions' end diff --git a/spec/acceptance/rest/admin/api/system/timezones_spec.rb b/spec/acceptance/rest/admin/api/timezones_spec.rb similarity index 77% rename from spec/acceptance/rest/admin/api/system/timezones_spec.rb rename to spec/acceptance/rest/admin/api/timezones_spec.rb index 373f1cbba..21d5eee6c 100644 --- a/spec/acceptance/rest/admin/api/system/timezones_spec.rb +++ b/spec/acceptance/rest/admin/api/timezones_spec.rb @@ -11,15 +11,15 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'timezones' } - get '/api/rest/admin/system/timezones' do - jsonapi_filters Api::Rest::Admin::System::TimezoneResource._allowed_filters + get '/api/rest/admin/timezones' do + jsonapi_filters Api::Rest::Admin::TimezoneResource._allowed_filters example_request 'get listing' do expect(status).to eq(200) end end - get '/api/rest/admin/system/timezones/:id' do + get '/api/rest/admin/timezones/:id' do let(:id) { System::Timezone.first.id } example_request 'get specific entry' do diff --git a/spec/acceptance/rest/admin/api/equipment/transport_protocols_spec.rb b/spec/acceptance/rest/admin/api/transport_protocols_spec.rb similarity index 75% rename from spec/acceptance/rest/admin/api/equipment/transport_protocols_spec.rb rename to spec/acceptance/rest/admin/api/transport_protocols_spec.rb index ed9ab86d7..82ef808a6 100644 --- a/spec/acceptance/rest/admin/api/equipment/transport_protocols_spec.rb +++ b/spec/acceptance/rest/admin/api/transport_protocols_spec.rb @@ -11,15 +11,15 @@ let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } let(:type) { 'transport-protocols' } - get '/api/rest/admin/equipment/transport-protocols' do - jsonapi_filters Api::Rest::Admin::Equipment::TransportProtocolResource._allowed_filters + get '/api/rest/admin/transport-protocols' do + jsonapi_filters Api::Rest::Admin::TransportProtocolResource._allowed_filters example_request 'get listing' do expect(status).to eq(200) end end - get '/api/rest/admin/equipment/transport-protocols/:id' do + get '/api/rest/admin/transport-protocols/:id' do let(:id) { Equipment::TransportProtocol.first.id } example_request 'get specific entry' do diff --git a/spec/controllers/api/rest/admin/routing/area_prefixes_controller.rb b/spec/controllers/api/rest/admin/area_prefixes_controller.rb similarity index 96% rename from spec/controllers/api/rest/admin/routing/area_prefixes_controller.rb rename to spec/controllers/api/rest/admin/area_prefixes_controller.rb index 479a49d3a..690cee617 100644 --- a/spec/controllers/api/rest/admin/routing/area_prefixes_controller.rb +++ b/spec/controllers/api/rest/admin/area_prefixes_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::AreaPrefixesController, type: :controller do +RSpec.describe Api::Rest::Admin::AreaPrefixesController, type: :controller do include_context :jsonapi_admin_headers let(:resource_type) { 'area-prefixes' } diff --git a/spec/controllers/api/rest/admin/routing/areas_controller_spec.rb b/spec/controllers/api/rest/admin/areas_controller_spec.rb similarity index 96% rename from spec/controllers/api/rest/admin/routing/areas_controller_spec.rb rename to spec/controllers/api/rest/admin/areas_controller_spec.rb index 87242969e..e4991a88e 100644 --- a/spec/controllers/api/rest/admin/routing/areas_controller_spec.rb +++ b/spec/controllers/api/rest/admin/areas_controller_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::AreasController, type: :controller do +RSpec.describe Api::Rest::Admin::AreasController, type: :controller do include_context :jsonapi_admin_headers let(:resource_type) { 'areas' } diff --git a/spec/controllers/api/rest/admin/cdr/auth_logs_controller_spec.rb b/spec/controllers/api/rest/admin/auth_logs_controller_spec.rb similarity index 96% rename from spec/controllers/api/rest/admin/cdr/auth_logs_controller_spec.rb rename to spec/controllers/api/rest/admin/auth_logs_controller_spec.rb index 83dd7e8a7..44d453b8f 100644 --- a/spec/controllers/api/rest/admin/cdr/auth_logs_controller_spec.rb +++ b/spec/controllers/api/rest/admin/auth_logs_controller_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Cdr::AuthLogsController, type: :controller do +RSpec.describe Api::Rest::Admin::AuthLogsController, type: :controller do include_context :jsonapi_admin_headers after { Cdr::AuthLog.destroy_all } @@ -226,19 +226,19 @@ describe 'POST create' do it 'POST should not be routable', type: :routing do - expect(post: '/api/rest/admin/cdr/auth_logs').to_not be_routable + expect(post: '/api/rest/admin/auth_logs').to_not be_routable end end describe 'PATCH create' do it 'PATCH should not be routable', type: :routing do - expect(patch: '/api/rest/admin/cdr/auth_logs/123').to_not be_routable + expect(patch: '/api/rest/admin/auth_logs/123').to_not be_routable end end describe 'DELETE create' do it 'DELETE should not be routable', type: :routing do - expect(delete: '/api/rest/admin/cdr/auth_logs/123').to_not be_routable + expect(delete: '/api/rest/admin/auth_logs/123').to_not be_routable end end end diff --git a/spec/controllers/api/rest/admin/cdr/cdrs_controller_spec.rb b/spec/controllers/api/rest/admin/cdrs_controller_spec.rb similarity index 98% rename from spec/controllers/api/rest/admin/cdr/cdrs_controller_spec.rb rename to spec/controllers/api/rest/admin/cdrs_controller_spec.rb index 2765a1fac..f65412cb7 100644 --- a/spec/controllers/api/rest/admin/cdr/cdrs_controller_spec.rb +++ b/spec/controllers/api/rest/admin/cdrs_controller_spec.rb @@ -1,14 +1,7 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Cdr::CdrsController, type: :controller do - let(:admin_user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: admin_user.id }).token } - - before do - request.accept = 'application/vnd.api+json' - request.headers['Content-Type'] = 'application/vnd.api+json' - request.headers['Authorization'] = auth_token - end +RSpec.describe Api::Rest::Admin::CdrsController, type: :controller do + include_context :jsonapi_admin_headers describe 'GET index' do let!(:cdrs) do @@ -760,19 +753,19 @@ describe 'POST create' do it 'POST should not be routable', type: :routing do - expect(post: '/api/rest/admin/cdr/cdrs').to_not be_routable + expect(post: '/api/rest/admin/cdrs').to_not be_routable end end describe 'PATCH update' do it 'PATCH should be routable', type: :routing do - expect(patch: '/api/rest/admin/cdr/cdrs/123').to be_routable + expect(patch: '/api/rest/admin/cdrs/123').to be_routable end end describe 'DELETE destroy' do it 'DELETE should not be routable', type: :routing do - expect(delete: '/api/rest/admin/cdr/cdrs/123').to_not be_routable + expect(delete: '/api/rest/admin/cdrs/123').to_not be_routable end end end diff --git a/spec/controllers/api/rest/admin/system/countries_controller_spec.rb b/spec/controllers/api/rest/admin/countries_controller_spec.rb similarity index 89% rename from spec/controllers/api/rest/admin/system/countries_controller_spec.rb rename to spec/controllers/api/rest/admin/countries_controller_spec.rb index 818a42299..819263d27 100644 --- a/spec/controllers/api/rest/admin/system/countries_controller_spec.rb +++ b/spec/controllers/api/rest/admin/countries_controller_spec.rb @@ -1,14 +1,7 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::System::CountriesController, type: :controller do - let(:admin_user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: admin_user.id }).token } - - before do - request.accept = 'application/vnd.api+json' - request.headers['Content-Type'] = 'application/vnd.api+json' - request.headers['Authorization'] = auth_token - end +RSpec.describe Api::Rest::Admin::CountriesController, type: :controller do + include_context :jsonapi_admin_headers describe 'GET index' do let!(:countries) do diff --git a/spec/controllers/api/rest/admin/routing/destination_next_rates_spec.rb b/spec/controllers/api/rest/admin/destination_next_rates_spec.rb similarity index 91% rename from spec/controllers/api/rest/admin/routing/destination_next_rates_spec.rb rename to spec/controllers/api/rest/admin/destination_next_rates_spec.rb index 21de42598..cfb72fc12 100644 --- a/spec/controllers/api/rest/admin/routing/destination_next_rates_spec.rb +++ b/spec/controllers/api/rest/admin/destination_next_rates_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::DestinationNextRatesController, type: :controller do +RSpec.describe Api::Rest::Admin::DestinationNextRatesController, type: :controller do include_context :jsonapi_admin_headers describe 'GET index with ransack filters' do diff --git a/spec/controllers/api/rest/admin/routing/destinations_controller_spec.rb b/spec/controllers/api/rest/admin/destinations_controller_spec.rb similarity index 99% rename from spec/controllers/api/rest/admin/routing/destinations_controller_spec.rb rename to spec/controllers/api/rest/admin/destinations_controller_spec.rb index 3d0671d68..e95af49f6 100755 --- a/spec/controllers/api/rest/admin/routing/destinations_controller_spec.rb +++ b/spec/controllers/api/rest/admin/destinations_controller_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::DestinationsController, type: :controller do +RSpec.describe Api::Rest::Admin::DestinationsController, type: :controller do let(:rate_group) { create :rate_group } include_context :jsonapi_admin_headers diff --git a/spec/controllers/api/rest/admin/routing/dialpeer_next_rates_controller_spec.rb b/spec/controllers/api/rest/admin/dialpeer_next_rates_controller_spec.rb similarity index 76% rename from spec/controllers/api/rest/admin/routing/dialpeer_next_rates_controller_spec.rb rename to spec/controllers/api/rest/admin/dialpeer_next_rates_controller_spec.rb index 79671f9c1..de2963c9e 100644 --- a/spec/controllers/api/rest/admin/routing/dialpeer_next_rates_controller_spec.rb +++ b/spec/controllers/api/rest/admin/dialpeer_next_rates_controller_spec.rb @@ -1,14 +1,7 @@ # frozen_string_literal: true RSpec.describe Api::Rest::Admin::DialpeerNextRatesController do - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } - - before do - request.accept = 'application/vnd.api+json' - request.headers['Content-Type'] = 'application/vnd.api+json' - request.headers['Authorization'] = auth_token - end + include_context :jsonapi_admin_headers describe 'GET index' do subject { get :index, params: { dialpeer_id: 1, format: :json } } diff --git a/spec/controllers/api/rest/admin/system/network_types_controller_spec.rb b/spec/controllers/api/rest/admin/network_types_controller_spec.rb similarity index 88% rename from spec/controllers/api/rest/admin/system/network_types_controller_spec.rb rename to spec/controllers/api/rest/admin/network_types_controller_spec.rb index 71b40b54b..16a38ae61 100644 --- a/spec/controllers/api/rest/admin/system/network_types_controller_spec.rb +++ b/spec/controllers/api/rest/admin/network_types_controller_spec.rb @@ -1,14 +1,7 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::System::NetworkTypesController, type: :controller do - let(:admin_user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: admin_user.id }).token } - - before do - request.accept = 'application/vnd.api+json' - request.headers['Content-Type'] = 'application/vnd.api+json' - request.headers['Authorization'] = auth_token - end +RSpec.describe Api::Rest::Admin::NetworkTypesController, type: :controller do + include_context :jsonapi_admin_headers describe 'GET index' do before do diff --git a/spec/controllers/api/rest/admin/system/networks_controller_spec.rb b/spec/controllers/api/rest/admin/networks_controller_spec.rb similarity index 91% rename from spec/controllers/api/rest/admin/system/networks_controller_spec.rb rename to spec/controllers/api/rest/admin/networks_controller_spec.rb index 575980585..a5641709e 100644 --- a/spec/controllers/api/rest/admin/system/networks_controller_spec.rb +++ b/spec/controllers/api/rest/admin/networks_controller_spec.rb @@ -1,14 +1,7 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::System::NetworksController, type: :controller do - let(:admin_user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: admin_user.id }).token } - - before do - request.accept = 'application/vnd.api+json' - request.headers['Content-Type'] = 'application/vnd.api+json' - request.headers['Authorization'] = auth_token - end +RSpec.describe Api::Rest::Admin::NetworksController, type: :controller do + include_context :jsonapi_admin_headers describe 'GET index' do let!(:networks) do diff --git a/spec/controllers/api/rest/admin/routing/numberlist_items_controller_spec.rb b/spec/controllers/api/rest/admin/numberlist_items_controller_spec.rb similarity index 97% rename from spec/controllers/api/rest/admin/routing/numberlist_items_controller_spec.rb rename to spec/controllers/api/rest/admin/numberlist_items_controller_spec.rb index e2f8c94e6..620d4e9a6 100644 --- a/spec/controllers/api/rest/admin/routing/numberlist_items_controller_spec.rb +++ b/spec/controllers/api/rest/admin/numberlist_items_controller_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::NumberlistItemsController, type: :controller do +RSpec.describe Api::Rest::Admin::NumberlistItemsController, type: :controller do include_context :jsonapi_admin_headers let(:resource_type) { 'numberlist-items' } diff --git a/spec/controllers/api/rest/admin/routing/numberlists_controller_spec.rb b/spec/controllers/api/rest/admin/numberlists_controller_spec.rb similarity index 97% rename from spec/controllers/api/rest/admin/routing/numberlists_controller_spec.rb rename to spec/controllers/api/rest/admin/numberlists_controller_spec.rb index b95912699..8031c533b 100644 --- a/spec/controllers/api/rest/admin/routing/numberlists_controller_spec.rb +++ b/spec/controllers/api/rest/admin/numberlists_controller_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::NumberlistsController, type: :controller do +RSpec.describe Api::Rest::Admin::NumberlistsController, type: :controller do include_context :jsonapi_admin_headers describe 'GET index with ransack filters' do diff --git a/spec/controllers/api/rest/admin/routing/rateplans_controller_spec.rb b/spec/controllers/api/rest/admin/rateplans_controller_spec.rb similarity index 89% rename from spec/controllers/api/rest/admin/routing/rateplans_controller_spec.rb rename to spec/controllers/api/rest/admin/rateplans_controller_spec.rb index f10b07acd..bf6d08602 100755 --- a/spec/controllers/api/rest/admin/routing/rateplans_controller_spec.rb +++ b/spec/controllers/api/rest/admin/rateplans_controller_spec.rb @@ -1,14 +1,7 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::RateplansController, type: :controller do - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } - - before do - request.accept = 'application/vnd.api+json' - request.headers['Content-Type'] = 'application/vnd.api+json' - request.headers['Authorization'] = auth_token - end +RSpec.describe Api::Rest::Admin::RateplansController, type: :controller do + include_context :jsonapi_admin_headers describe 'GET index' do let!(:rateplans) { create_list :rateplan, 2 } diff --git a/spec/controllers/api/rest/admin/routing/routing_groups_controller_spec.rb b/spec/controllers/api/rest/admin/routing_groups_controller_spec.rb similarity index 88% rename from spec/controllers/api/rest/admin/routing/routing_groups_controller_spec.rb rename to spec/controllers/api/rest/admin/routing_groups_controller_spec.rb index b7ba91f18..046c5a2e0 100755 --- a/spec/controllers/api/rest/admin/routing/routing_groups_controller_spec.rb +++ b/spec/controllers/api/rest/admin/routing_groups_controller_spec.rb @@ -1,14 +1,7 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::RoutingGroupsController, type: :controller do - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } - - before do - request.accept = 'application/vnd.api+json' - request.headers['Content-Type'] = 'application/vnd.api+json' - request.headers['Authorization'] = auth_token - end +RSpec.describe Api::Rest::Admin::RoutingGroupsController, type: :controller do + include_context :jsonapi_admin_headers describe 'GET index' do let!(:routing_groups) { Routing::RoutingGroup.all.to_a } diff --git a/spec/controllers/api/rest/admin/routing/routing_tag_detection_rules_controller_spec.rb b/spec/controllers/api/rest/admin/routing_tag_detection_rules_controller_spec.rb similarity index 97% rename from spec/controllers/api/rest/admin/routing/routing_tag_detection_rules_controller_spec.rb rename to spec/controllers/api/rest/admin/routing_tag_detection_rules_controller_spec.rb index 5bc44bd00..34322320c 100644 --- a/spec/controllers/api/rest/admin/routing/routing_tag_detection_rules_controller_spec.rb +++ b/spec/controllers/api/rest/admin/routing_tag_detection_rules_controller_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::RoutingTagDetectionRulesController, type: :controller do +RSpec.describe Api::Rest::Admin::RoutingTagDetectionRulesController, type: :controller do include_context :jsonapi_admin_headers let(:resource_type) { 'routing-tag-detection-rules' } diff --git a/spec/controllers/api/rest/admin/routing/routing_tag_modes_controller_spec.rb b/spec/controllers/api/rest/admin/routing_tag_modes_controller_spec.rb similarity index 94% rename from spec/controllers/api/rest/admin/routing/routing_tag_modes_controller_spec.rb rename to spec/controllers/api/rest/admin/routing_tag_modes_controller_spec.rb index dda058736..81b9612f8 100644 --- a/spec/controllers/api/rest/admin/routing/routing_tag_modes_controller_spec.rb +++ b/spec/controllers/api/rest/admin/routing_tag_modes_controller_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::RoutingTagModesController, type: :controller do +RSpec.describe Api::Rest::Admin::RoutingTagModesController, type: :controller do include_context :jsonapi_admin_headers let(:resource_type) { 'routing-tag-modes' } diff --git a/spec/controllers/api/rest/admin/routing/routing_tags_controller_spec.rb b/spec/controllers/api/rest/admin/routing_tags_controller_spec.rb similarity index 95% rename from spec/controllers/api/rest/admin/routing/routing_tags_controller_spec.rb rename to spec/controllers/api/rest/admin/routing_tags_controller_spec.rb index 65bdc6720..b71180d48 100644 --- a/spec/controllers/api/rest/admin/routing/routing_tags_controller_spec.rb +++ b/spec/controllers/api/rest/admin/routing_tags_controller_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::RoutingTagsController, type: :controller do +RSpec.describe Api::Rest::Admin::RoutingTagsController, type: :controller do include_context :jsonapi_admin_headers describe 'GET index' do diff --git a/spec/controllers/api/rest/admin/routing/tag_actions_controller_spec.rb b/spec/controllers/api/rest/admin/tag_actions_controller_spec.rb similarity index 94% rename from spec/controllers/api/rest/admin/routing/tag_actions_controller_spec.rb rename to spec/controllers/api/rest/admin/tag_actions_controller_spec.rb index 11dc59d28..cd181171a 100644 --- a/spec/controllers/api/rest/admin/routing/tag_actions_controller_spec.rb +++ b/spec/controllers/api/rest/admin/tag_actions_controller_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::TagActionsController, type: :controller do +RSpec.describe Api::Rest::Admin::TagActionsController, type: :controller do include_context :jsonapi_admin_headers describe 'GET index' do diff --git a/spec/requests/api/rest/admin/equipment/radius/accounting_profiles_spec.rb b/spec/requests/api/rest/admin/accounting_profiles_spec.rb similarity index 73% rename from spec/requests/api/rest/admin/equipment/radius/accounting_profiles_spec.rb rename to spec/requests/api/rest/admin/accounting_profiles_spec.rb index 983c52eb0..fe8c6cc4d 100644 --- a/spec/requests/api/rest/admin/equipment/radius/accounting_profiles_spec.rb +++ b/spec/requests/api/rest/admin/accounting_profiles_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Equipment::Radius::AccountingProfilesController, type: :request do - include_context :json_api_admin_helpers, type: :'accounting-profiles', prefix: 'equipment/radius' +RSpec.describe Api::Rest::Admin::AccountingProfilesController, type: :request do + include_context :json_api_admin_helpers, type: :'accounting-profiles' - describe 'GET /api/rest/admin/equipment/radius/accounting-profiles' do + describe 'GET /api/rest/admin/accounting-profiles' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/routing/area_prefixes_spec.rb b/spec/requests/api/rest/admin/area_prefixes_spec.rb similarity index 93% rename from spec/requests/api/rest/admin/routing/area_prefixes_spec.rb rename to spec/requests/api/rest/admin/area_prefixes_spec.rb index 0ba2f3507..d0974bc38 100644 --- a/spec/requests/api/rest/admin/routing/area_prefixes_spec.rb +++ b/spec/requests/api/rest/admin/area_prefixes_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::AreaPrefixesController, type: :request do - include_context :json_api_admin_helpers, type: :'area-prefixes', prefix: 'routing' +RSpec.describe Api::Rest::Admin::AreaPrefixesController, type: :request do + include_context :json_api_admin_helpers, type: :'area-prefixes' - describe 'GET /api/rest/admin/routing/area-prefixes' do + describe 'GET /api/rest/admin/area-prefixes' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/routing/areas_spec.rb b/spec/requests/api/rest/admin/areas_spec.rb similarity index 70% rename from spec/requests/api/rest/admin/routing/areas_spec.rb rename to spec/requests/api/rest/admin/areas_spec.rb index 427b8b3b6..b52d521d5 100644 --- a/spec/requests/api/rest/admin/routing/areas_spec.rb +++ b/spec/requests/api/rest/admin/areas_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::AreasController, type: :request do - include_context :json_api_admin_helpers, type: :areas, prefix: 'routing' +RSpec.describe Api::Rest::Admin::AreasController, type: :request do + include_context :json_api_admin_helpers, type: :areas - describe 'GET /api/rest/admin/routing/areas' do + describe 'GET /api/rest/admin/areas' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/cdr/auth_logs_spec.rb b/spec/requests/api/rest/admin/auth_logs_spec.rb similarity index 72% rename from spec/requests/api/rest/admin/cdr/auth_logs_spec.rb rename to spec/requests/api/rest/admin/auth_logs_spec.rb index 0a01debc9..b4a49dd1d 100644 --- a/spec/requests/api/rest/admin/cdr/auth_logs_spec.rb +++ b/spec/requests/api/rest/admin/auth_logs_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Cdr::AuthLogsController, type: :request do - include_context :json_api_admin_helpers, type: :'auth-logs', prefix: 'cdr' +RSpec.describe Api::Rest::Admin::AuthLogsController, type: :request do + include_context :json_api_admin_helpers, type: :'auth-logs' - describe 'GET /api/rest/admin/cdr/auth-logs' do + describe 'GET /api/rest/admin/auth-logs' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/equipment/radius/auth_profile_spec.rb b/spec/requests/api/rest/admin/auth_profile_spec.rb similarity index 74% rename from spec/requests/api/rest/admin/equipment/radius/auth_profile_spec.rb rename to spec/requests/api/rest/admin/auth_profile_spec.rb index e1aa00daf..5ed2b6852 100644 --- a/spec/requests/api/rest/admin/equipment/radius/auth_profile_spec.rb +++ b/spec/requests/api/rest/admin/auth_profile_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Equipment::Radius::AuthProfilesController, type: :request do - include_context :json_api_admin_helpers, type: :'auth-profiles', prefix: 'equipment/radius' +RSpec.describe Api::Rest::Admin::AuthProfilesController, type: :request do + include_context :json_api_admin_helpers, type: :'auth-profiles' - describe 'GET /api/rest/admin/equipment/radius/auth-profiles' do + describe 'GET /api/rest/admin/auth-profiles' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/cdr/cdr_exports_spec.rb b/spec/requests/api/rest/admin/cdr_exports_spec.rb similarity index 96% rename from spec/requests/api/rest/admin/cdr/cdr_exports_spec.rb rename to spec/requests/api/rest/admin/cdr_exports_spec.rb index d6ab725cb..e265ad96a 100644 --- a/spec/requests/api/rest/admin/cdr/cdr_exports_spec.rb +++ b/spec/requests/api/rest/admin/cdr_exports_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Cdr::CdrExportsController, type: :request do - include_context :json_api_admin_helpers, prefix: 'cdr', type: 'cdr-exports' +RSpec.describe Api::Rest::Admin::CdrExportsController, type: :request do + include_context :json_api_admin_helpers, type: 'cdr-exports' - describe 'GET /api/rest/admin/cdr/cdr-exports' do + describe 'GET /api/rest/admin/cdr-exports' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end @@ -18,7 +18,7 @@ end end - describe 'GET /api/rest/admin/cdr/cdr-exports/:id' do + describe 'GET /api/rest/admin/cdr-exports/:id' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end @@ -43,7 +43,7 @@ end end - describe 'GET /api/rest/admin/cdr/cdr-exports/:id/download' do + describe 'GET /api/rest/admin/cdr-exports/:id/download' do subject do get json_api_request_path, params: nil, headers: { 'Authorization' => json_api_auth_token } end @@ -87,7 +87,7 @@ end end - describe 'POST /api/rest/admin/cdr/cdr-exports' do + describe 'POST /api/rest/admin/cdr-exports' do subject do post json_api_request_path, params: json_api_request_body.to_json, headers: json_api_request_headers end @@ -303,7 +303,7 @@ end end - describe 'DELETE /api/rest/admin/cdr/cdr-exports/:id' do + describe 'DELETE /api/rest/admin/cdr-exports/:id' do subject do delete json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/cdr/cdrs_spec.rb b/spec/requests/api/rest/admin/cdrs_spec.rb similarity index 93% rename from spec/requests/api/rest/admin/cdr/cdrs_spec.rb rename to spec/requests/api/rest/admin/cdrs_spec.rb index 5cf4f1cf3..8bffd1f35 100644 --- a/spec/requests/api/rest/admin/cdr/cdrs_spec.rb +++ b/spec/requests/api/rest/admin/cdrs_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Cdr::CdrsController, type: :request do - include_context :json_api_admin_helpers, type: :cdrs, prefix: 'cdr' +RSpec.describe Api::Rest::Admin::CdrsController, type: :request do + include_context :json_api_admin_helpers, type: :cdrs - describe 'GET /api/rest/admin/cdr/cdrs' do + describe 'GET /api/rest/admin/cdrs' do subject do get json_api_request_path, params: json_api_request_params, headers: json_api_request_headers end @@ -84,7 +84,7 @@ end end - describe 'GET /api/rest/admin/cdr/:id/recording' do + describe 'GET /api/rest/admin/:id/recording' do subject do get json_api_request_path, params: nil, headers: { 'Authorization' => json_api_auth_token } end @@ -115,7 +115,7 @@ end end - describe 'GET /api/rest/admin/cdr/cdrs/:id/vendor' do + describe 'GET /api/rest/admin/cdrs/:id/vendor' do subject do get json_api_request_path, params: json_api_request_params, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/system/country_spec.rb b/spec/requests/api/rest/admin/country_spec.rb similarity index 73% rename from spec/requests/api/rest/admin/system/country_spec.rb rename to spec/requests/api/rest/admin/country_spec.rb index a168d5f5a..c0bc007e5 100644 --- a/spec/requests/api/rest/admin/system/country_spec.rb +++ b/spec/requests/api/rest/admin/country_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::System::CountriesController, type: :request do - include_context :json_api_admin_helpers, type: :countries, prefix: 'system' +RSpec.describe Api::Rest::Admin::CountriesController, type: :request do + include_context :json_api_admin_helpers, type: :countries - describe 'GET /api/rest/admin/system/countries' do + describe 'GET /api/rest/admin/countries' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/routing/destination_next_rates_spec.rb b/spec/requests/api/rest/admin/destination_next_rates2_spec.rb similarity index 75% rename from spec/requests/api/rest/admin/routing/destination_next_rates_spec.rb rename to spec/requests/api/rest/admin/destination_next_rates2_spec.rb index 082b89c69..33f10ff72 100644 --- a/spec/requests/api/rest/admin/routing/destination_next_rates_spec.rb +++ b/spec/requests/api/rest/admin/destination_next_rates2_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::DestinationNextRatesController, type: :request do - include_context :json_api_admin_helpers, type: :'destination-next-rates', prefix: 'routing' +RSpec.describe Api::Rest::Admin::DestinationNextRatesController, type: :request do + include_context :json_api_admin_helpers, type: :'destination-next-rates' - describe 'GET /api/rest/admin/routing/destination-next-rates' do + describe 'GET /api/rest/admin/destination-next-rates' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/destination_next_rates_spec.rb b/spec/requests/api/rest/admin/destination_next_rates_spec.rb index 1a97b4420..2a11c46f1 100644 --- a/spec/requests/api/rest/admin/destination_next_rates_spec.rb +++ b/spec/requests/api/rest/admin/destination_next_rates_spec.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::DestinationNextRatesController, type: :request do +RSpec.describe Api::Rest::Admin::DestinationNextRatesController, type: :request do include_context :json_api_admin_helpers, type: :'destination-next-rates' let!(:rate_group) { FactoryBot.create(:rate_group) } let!(:destination) { FactoryBot.create(:destination, rate_group: rate_group) } - let(:json_api_request_path_prefix) { '/api/rest/admin/routing' } + let(:json_api_request_path_prefix) { '/api/rest/admin' } - describe 'GET /api/rest/admin/routing/destination-next-rates' do + describe 'GET /api/rest/admin/destination-next-rates' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end @@ -24,7 +24,7 @@ it_behaves_like :json_api_admin_check_authorization end - describe 'GET /api/rest/admin/routing/destination-next-rates/{id}' do + describe 'GET /api/rest/admin/destination-next-rates/{id}' do subject do get json_api_request_path, params: request_query, headers: json_api_request_headers end @@ -74,7 +74,7 @@ end end - describe 'POST /api/rest/admin/routing/destination-next-rates' do + describe 'POST /api/rest/admin/destination-next-rates' do subject do post json_api_request_path, params: json_api_request_body.to_json, headers: json_api_request_headers end @@ -126,7 +126,7 @@ it_behaves_like :json_api_admin_check_authorization, status: 201 end - describe 'PATCH /api/rest/admin/routing/destination-next-rates/{id}' do + describe 'PATCH /api/rest/admin/destination-next-rates/{id}' do subject do patch json_api_request_path, params: json_api_request_body.to_json, headers: json_api_request_headers end @@ -151,7 +151,7 @@ it_behaves_like :json_api_admin_check_authorization end - describe 'DELETE /api/rest/admin/routing/destination-next-rates/{id}' do + describe 'DELETE /api/rest/admin/destination-next-rates/{id}' do subject do delete json_api_request_path, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/destinations_spec.rb b/spec/requests/api/rest/admin/destinations_spec.rb new file mode 100644 index 000000000..768d34c95 --- /dev/null +++ b/spec/requests/api/rest/admin/destinations_spec.rb @@ -0,0 +1,187 @@ +# frozen_string_literal: true + +RSpec.describe Api::Rest::Admin::DestinationsController, type: :request do + include_context :json_api_admin_helpers, type: :destinations + + describe 'GET /api/rest/admin/destinations' do + subject do + get json_api_request_path, params: index_params, headers: json_api_request_headers + end + let(:index_params) { {} } + + let!(:destinations) do + [ + FactoryBot.create(:destination, prefix: '370614', rate_group:, routing_tag_ids: []), + FactoryBot.create(:destination, rate_group:, routing_tag_ids: [routing_tag.id, nil]) + ] + end + let!(:rate_group) { FactoryBot.create(:rate_group, rateplans:) } + let!(:rateplans) { FactoryBot.create_list(:rateplan, 2) } + let!(:routing_tag) { FactoryBot.create(:routing_tag) } + + include_examples :jsonapi_responds_with_pagination_links + include_examples :returns_json_api_collection do + let(:json_api_collection_ids) do + destinations.map { |r| r.id.to_s } + end + end + + it_behaves_like :json_api_admin_check_authorization + + context 'with included country, next_rate and network' do + let(:index_params) do + { + filter: { + rateplan_id_eq: rateplans[0].id + }, + include: 'destination-next-rates,country,network', + page: { + number: 1, + size: 1000 + } + } + end + let!(:next_rate) do + FactoryBot.create(:destination_next_rate, destination: destinations.first) + end + let(:network_prefix) { destinations[0].network_prefix } + + before do + # not affected destinations + another_plan = FactoryBot.create(:rateplan) + another_group = FactoryBot.create(:rate_group, rateplans: [rateplans[1], another_plan]) + FactoryBot.create_list(:destination, 2, rate_group: another_group) + end + + include_examples :jsonapi_responds_with_pagination_links + include_examples :responds_with_status, 200 + + context 'destinations[0]' do + include_examples :returns_json_api_record, type: 'destinations', relationships: %i[country network destination-next-rates rate-group routing-tag-mode] do + let(:json_api_record_data) { json_api_data_detect_by_id_type } + let(:json_api_record_id) { destinations[0].id.to_s } + let(:json_api_record_attributes) do + { + 'acd-limit': destinations[0].acd_limit, + 'asr-limit': destinations[0].asr_limit, + 'connect-fee': destinations[0].connect_fee.to_s, + 'dp-margin-fixed': destinations[0].dp_margin_fixed.to_s, + 'dp-margin-percent': destinations[0].dp_margin_percent.to_s, + 'dst-number-max-length': destinations[0].dst_number_max_length, + 'dst-number-min-length': destinations[0].dst_number_min_length, + enabled: destinations[0].enabled, + 'external-id': destinations[0].external_id, + 'initial-interval': destinations[0].initial_interval, + 'initial-rate': destinations[0].initial_rate.to_s, + 'next-interval': destinations[0].next_interval, + 'next-rate': destinations[0].next_rate.to_s, + prefix: destinations[0].prefix, + 'profit-control-mode-id': destinations[0].profit_control_mode_id, + 'rate-policy-id': destinations[0].rate_policy_id, + 'reject-calls': destinations[0].reject_calls, + 'reverse-billing': destinations[0].reverse_billing, + 'routing-tag-ids': destinations[0].routing_tag_ids, + 'short-calls-limit': destinations[0].short_calls_limit, + 'use-dp-intervals': destinations[0].use_dp_intervals, + 'valid-from': destinations[0].valid_from.iso8601(3), + 'valid-till': destinations[0].valid_till.iso8601(3) + } + end + end + it_behaves_like :returns_json_api_record_relationship, :'destination-next-rates' do + let(:json_api_record_data) { json_api_data_detect_by_id_type } + let(:json_api_relationship_data) { [id: next_rate.id.to_s, type: 'destination-next-rates'] } + end + it_behaves_like :returns_json_api_record_relationship, :country do + let(:json_api_record_data) { json_api_data_detect_by_id_type } + let(:json_api_relationship_data) { { id: network_prefix.country.id.to_s, type: 'countries' } } + end + it_behaves_like :returns_json_api_record_relationship, :network do + let(:json_api_record_data) { json_api_data_detect_by_id_type } + let(:json_api_relationship_data) { { id: network_prefix.network.id.to_s, type: 'networks' } } + end + end + + context 'destinations[1]' do + include_examples :returns_json_api_record, type: 'destinations', relationships: %i[country network destination-next-rates rate-group routing-tag-mode] do + let(:json_api_record_data) { json_api_data_detect_by_id_type } + let(:json_api_record_id) { destinations[1].id.to_s } + let(:json_api_record_attributes) do + { + 'acd-limit': destinations[1].acd_limit, + 'asr-limit': destinations[1].asr_limit, + 'connect-fee': destinations[1].connect_fee.to_s, + 'dp-margin-fixed': destinations[1].dp_margin_fixed.to_s, + 'dp-margin-percent': destinations[1].dp_margin_percent.to_s, + 'dst-number-max-length': destinations[1].dst_number_max_length, + 'dst-number-min-length': destinations[1].dst_number_min_length, + enabled: destinations[1].enabled, + 'external-id': destinations[1].external_id, + 'initial-interval': destinations[1].initial_interval, + 'initial-rate': destinations[1].initial_rate.to_s, + 'next-interval': destinations[1].next_interval, + 'next-rate': destinations[1].next_rate.to_s, + prefix: destinations[1].prefix, + 'profit-control-mode-id': destinations[1].profit_control_mode_id, + 'rate-policy-id': destinations[1].rate_policy_id, + 'reject-calls': destinations[1].reject_calls, + 'reverse-billing': destinations[1].reverse_billing, + 'routing-tag-ids': destinations[1].routing_tag_ids, + 'short-calls-limit': destinations[1].short_calls_limit, + 'use-dp-intervals': destinations[1].use_dp_intervals, + 'valid-from': destinations[1].valid_from.iso8601(3), + 'valid-till': destinations[1].valid_till.iso8601(3) + } + end + end + it_behaves_like :returns_json_api_record_relationship, :'destination-next-rates' do + let(:json_api_record_data) { json_api_data_detect_by_id_type } + let(:json_api_relationship_data) { [] } + end + it_behaves_like :returns_json_api_record_relationship, :country do + let(:json_api_record_data) { json_api_data_detect_by_id_type } + let(:json_api_relationship_data) { nil } + end + it_behaves_like :returns_json_api_record_relationship, :network do + let(:json_api_record_data) { json_api_data_detect_by_id_type } + let(:json_api_relationship_data) { nil } + end + end + + it_behaves_like :returns_json_api_record_include, type: :'destination-next-rates' do + let(:json_api_include_id) { next_rate.id.to_s } + let(:json_api_include_attributes) do + { + applied: next_rate.applied, + 'apply-time': next_rate.apply_time.iso8601(3), + 'connect-fee': next_rate.connect_fee.to_s, + 'external-id': next_rate.external_id, + 'initial-interval': next_rate.initial_interval, + 'initial-rate': next_rate.initial_rate.to_s, + 'next-interval': next_rate.next_interval, + 'next-rate': next_rate.next_rate.to_s + } + end + end + + it_behaves_like :returns_json_api_record_include, type: :countries do + let(:json_api_include_id) { network_prefix.country.id.to_s } + let(:json_api_include_attributes) do + { name: network_prefix.country.name, iso2: network_prefix.country.iso2 } + end + end + + it_behaves_like :returns_json_api_record_include, type: :networks do + let(:json_api_include_id) { network_prefix.network.id.to_s } + let(:json_api_include_attributes) { { name: network_prefix.network.name } } + end + + it 'should return correct response' do + subject + + expect(response_json[:meta]).to match('total-count': destinations.size) + expect(response_json[:included].size).to eq(3) + end + end + end +end diff --git a/spec/requests/api/rest/admin/system/dtmf_receive_modes_spec.rb b/spec/requests/api/rest/admin/dtmf_receive_modes_spec.rb similarity index 76% rename from spec/requests/api/rest/admin/system/dtmf_receive_modes_spec.rb rename to spec/requests/api/rest/admin/dtmf_receive_modes_spec.rb index 0027108dd..7f6cc54e3 100644 --- a/spec/requests/api/rest/admin/system/dtmf_receive_modes_spec.rb +++ b/spec/requests/api/rest/admin/dtmf_receive_modes_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::System::DtmfReceiveModesController, type: :request do - include_context :json_api_admin_helpers, type: :'dtmf-receive-modes', prefix: 'system' +RSpec.describe Api::Rest::Admin::DtmfReceiveModesController, type: :request do + include_context :json_api_admin_helpers, type: :'dtmf-receive-modes' - describe 'GET /api/rest/admin/system/dtmf-receive-modes' do + describe 'GET /api/rest/admin/dtmf-receive-modes' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/system/dtmf_send_modes_spec.rb b/spec/requests/api/rest/admin/dtmf_send_modes_spec.rb similarity index 77% rename from spec/requests/api/rest/admin/system/dtmf_send_modes_spec.rb rename to spec/requests/api/rest/admin/dtmf_send_modes_spec.rb index c4670fe8f..ca19f05da 100644 --- a/spec/requests/api/rest/admin/system/dtmf_send_modes_spec.rb +++ b/spec/requests/api/rest/admin/dtmf_send_modes_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::System::DtmfSendModesController, type: :request do - include_context :json_api_admin_helpers, type: :'dtmf-send-modes', prefix: 'system' +RSpec.describe Api::Rest::Admin::DtmfSendModesController, type: :request do + include_context :json_api_admin_helpers, type: :'dtmf-send-modes' - describe 'GET /api/rest/admin/system/dtmf-send-modes' do + describe 'GET /api/rest/admin/dtmf-send-modes' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/equipment/gateway_diversion_send_modes_spec.rb b/spec/requests/api/rest/admin/gateway_diversion_send_modes_spec.rb similarity index 73% rename from spec/requests/api/rest/admin/equipment/gateway_diversion_send_modes_spec.rb rename to spec/requests/api/rest/admin/gateway_diversion_send_modes_spec.rb index 9024d68c8..544c77b44 100644 --- a/spec/requests/api/rest/admin/equipment/gateway_diversion_send_modes_spec.rb +++ b/spec/requests/api/rest/admin/gateway_diversion_send_modes_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Equipment::GatewayDiversionSendModesController, type: :request do - include_context :json_api_admin_helpers, type: :'gateway-diversion-send-modes', prefix: 'equipment' +RSpec.describe Api::Rest::Admin::GatewayDiversionSendModesController, type: :request do + include_context :json_api_admin_helpers, type: :'gateway-diversion-send-modes' - describe 'GET /api/rest/admin/equipment/gateway-diversion-send-modes' do + describe 'GET /api/rest/admin/gateway-diversion-send-modes' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/equipment/gateway_inband_dtmf_filtering_modes_spec.rb b/spec/requests/api/rest/admin/gateway_inband_dtmf_filtering_modes_spec.rb similarity index 72% rename from spec/requests/api/rest/admin/equipment/gateway_inband_dtmf_filtering_modes_spec.rb rename to spec/requests/api/rest/admin/gateway_inband_dtmf_filtering_modes_spec.rb index df95550f9..dc1b862f8 100644 --- a/spec/requests/api/rest/admin/equipment/gateway_inband_dtmf_filtering_modes_spec.rb +++ b/spec/requests/api/rest/admin/gateway_inband_dtmf_filtering_modes_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Equipment::GatewayInbandDtmfFilteringModesController, type: :request do - include_context :json_api_admin_helpers, type: :'gateway-inband-dtmf-filtering-modes', prefix: 'equipment' +RSpec.describe Api::Rest::Admin::GatewayInbandDtmfFilteringModesController, type: :request do + include_context :json_api_admin_helpers, type: :'gateway-inband-dtmf-filtering-modes' - describe 'GET /api/rest/admin/equipment/gateway-inband-dtmf-filtering-modes' do + describe 'GET /api/rest/admin/gateway-inband-dtmf-filtering-modes' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/equipment/gateway_media_encryption_modes_spec.rb b/spec/requests/api/rest/admin/gateway_media_encryption_modes_spec.rb similarity index 73% rename from spec/requests/api/rest/admin/equipment/gateway_media_encryption_modes_spec.rb rename to spec/requests/api/rest/admin/gateway_media_encryption_modes_spec.rb index 7010bc05c..d6c9697e8 100644 --- a/spec/requests/api/rest/admin/equipment/gateway_media_encryption_modes_spec.rb +++ b/spec/requests/api/rest/admin/gateway_media_encryption_modes_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Equipment::GatewayMediaEncryptionModesController, type: :request do - include_context :json_api_admin_helpers, type: :'gateway-media-encryption-modes', prefix: 'equipment' +RSpec.describe Api::Rest::Admin::GatewayMediaEncryptionModesController, type: :request do + include_context :json_api_admin_helpers, type: :'gateway-media-encryption-modes' - describe 'GET /api/rest/admin/equipment/gateway-media-encryption-modes' do + describe 'GET /api/rest/admin/gateway-media-encryption-modes' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/equipment/gateway_network_protocol_priorities_spec.rb b/spec/requests/api/rest/admin/gateway_network_protocol_priorities_spec.rb similarity index 72% rename from spec/requests/api/rest/admin/equipment/gateway_network_protocol_priorities_spec.rb rename to spec/requests/api/rest/admin/gateway_network_protocol_priorities_spec.rb index 43c050d5c..d49d4ba7c 100644 --- a/spec/requests/api/rest/admin/equipment/gateway_network_protocol_priorities_spec.rb +++ b/spec/requests/api/rest/admin/gateway_network_protocol_priorities_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Equipment::GatewayNetworkProtocolPrioritiesController, type: :request do - include_context :json_api_admin_helpers, type: :'gateway-network-protocol-priorities', prefix: 'equipment' +RSpec.describe Api::Rest::Admin::GatewayNetworkProtocolPrioritiesController, type: :request do + include_context :json_api_admin_helpers, type: :'gateway-network-protocol-priorities' - describe 'GET /api/rest/admin/equipment/gateway-network-protocol-priorities' do + describe 'GET /api/rest/admin/gateway-network-protocol-priorities' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/equipment/gateway_rel100_modes_spec.rb b/spec/requests/api/rest/admin/gateway_rel100_modes_spec.rb similarity index 75% rename from spec/requests/api/rest/admin/equipment/gateway_rel100_modes_spec.rb rename to spec/requests/api/rest/admin/gateway_rel100_modes_spec.rb index afc3ecd7f..36b1cfc00 100644 --- a/spec/requests/api/rest/admin/equipment/gateway_rel100_modes_spec.rb +++ b/spec/requests/api/rest/admin/gateway_rel100_modes_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Equipment::GatewayRel100ModesController, type: :request do - include_context :json_api_admin_helpers, type: :'gateway-rel100-modes', prefix: 'equipment' +RSpec.describe Api::Rest::Admin::GatewayRel100ModesController, type: :request do + include_context :json_api_admin_helpers, type: :'gateway-rel100-modes' - describe 'GET /api/rest/admin/equipment/gateway-rel100-modes' do + describe 'GET /api/rest/admin/gateway-rel100-modes' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/billing/invoice_originated_destinations_spec.rb b/spec/requests/api/rest/admin/invoice_originated_destinations_spec.rb similarity index 97% rename from spec/requests/api/rest/admin/billing/invoice_originated_destinations_spec.rb rename to spec/requests/api/rest/admin/invoice_originated_destinations_spec.rb index 6b0116c39..bde28a810 100644 --- a/spec/requests/api/rest/admin/billing/invoice_originated_destinations_spec.rb +++ b/spec/requests/api/rest/admin/invoice_originated_destinations_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Billing::InvoiceOriginatedDestinationsController, type: :request, bullet: [:n] do - include_context :json_api_admin_helpers, type: :'invoice-originated-destinations', prefix: 'billing' +RSpec.describe Api::Rest::Admin::InvoiceOriginatedDestinationsController, type: :request, bullet: [:n] do + include_context :json_api_admin_helpers, type: :'invoice-originated-destinations' describe 'GET /api/rest/admin/invoice-originated-destinations' do subject do diff --git a/spec/requests/api/rest/admin/billing/invoice_originated_networks_spec.rb b/spec/requests/api/rest/admin/invoice_originated_networks_spec.rb similarity index 97% rename from spec/requests/api/rest/admin/billing/invoice_originated_networks_spec.rb rename to spec/requests/api/rest/admin/invoice_originated_networks_spec.rb index 65e2ff5d6..4664380c5 100644 --- a/spec/requests/api/rest/admin/billing/invoice_originated_networks_spec.rb +++ b/spec/requests/api/rest/admin/invoice_originated_networks_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Billing::InvoiceOriginatedNetworksController, type: :request, bullet: [:n] do - include_context :json_api_admin_helpers, type: :'invoice-originated-networks', prefix: 'billing' +RSpec.describe Api::Rest::Admin::InvoiceOriginatedNetworksController, type: :request, bullet: [:n] do + include_context :json_api_admin_helpers, type: :'invoice-originated-networks' describe 'GET /api/rest/admin/invoice-originated-networks' do subject do diff --git a/spec/requests/api/rest/admin/billing/invoice_service_data_spec.rb b/spec/requests/api/rest/admin/invoice_service_data_spec.rb similarity index 97% rename from spec/requests/api/rest/admin/billing/invoice_service_data_spec.rb rename to spec/requests/api/rest/admin/invoice_service_data_spec.rb index 775c498c1..0104251eb 100644 --- a/spec/requests/api/rest/admin/billing/invoice_service_data_spec.rb +++ b/spec/requests/api/rest/admin/invoice_service_data_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Billing::InvoiceServiceDataController, type: :request, bullet: [:n] do - include_context :json_api_admin_helpers, type: :'invoice-service-data', prefix: 'billing' +RSpec.describe Api::Rest::Admin::InvoiceServiceDataController, type: :request, bullet: [:n] do + include_context :json_api_admin_helpers, type: :'invoice-service-data' describe 'GET /api/rest/admin/invoice-service-data' do subject do diff --git a/spec/requests/api/rest/admin/billing/invoice_templates_spec.rb b/spec/requests/api/rest/admin/invoice_templates_spec.rb similarity index 79% rename from spec/requests/api/rest/admin/billing/invoice_templates_spec.rb rename to spec/requests/api/rest/admin/invoice_templates_spec.rb index a89bc2bf2..5d1ddeb65 100644 --- a/spec/requests/api/rest/admin/billing/invoice_templates_spec.rb +++ b/spec/requests/api/rest/admin/invoice_templates_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Billing::InvoiceTemplateController, type: :request do - include_context :json_api_admin_helpers, type: :'invoice-templates', prefix: 'billing' +RSpec.describe Api::Rest::Admin::InvoiceTemplateController, type: :request do + include_context :json_api_admin_helpers, type: :'invoice-templates' let(:json_api_request_path) { "#{json_api_request_path_prefix}/invoice-template" } - describe 'GET /api/rest/admin/billing/invoice-template' do + describe 'GET /api/rest/admin/invoice-template' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/billing/invoice_terminated_destinations_spec.rb b/spec/requests/api/rest/admin/invoice_terminated_destinations_spec.rb similarity index 97% rename from spec/requests/api/rest/admin/billing/invoice_terminated_destinations_spec.rb rename to spec/requests/api/rest/admin/invoice_terminated_destinations_spec.rb index 51e621902..dec638d77 100644 --- a/spec/requests/api/rest/admin/billing/invoice_terminated_destinations_spec.rb +++ b/spec/requests/api/rest/admin/invoice_terminated_destinations_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Billing::InvoiceTerminatedDestinationsController, type: :request, bullet: [:n] do - include_context :json_api_admin_helpers, type: :'invoice-terminated-destinations', prefix: 'billing' +RSpec.describe Api::Rest::Admin::InvoiceTerminatedDestinationsController, type: :request, bullet: [:n] do + include_context :json_api_admin_helpers, type: :'invoice-terminated-destinations' describe 'GET /api/rest/admin/invoice-terminated-destinations' do subject do diff --git a/spec/requests/api/rest/admin/billing/invoice_terminated_networks_spec.rb b/spec/requests/api/rest/admin/invoice_terminated_networks_spec.rb similarity index 97% rename from spec/requests/api/rest/admin/billing/invoice_terminated_networks_spec.rb rename to spec/requests/api/rest/admin/invoice_terminated_networks_spec.rb index 8f8218dc8..2f22d2193 100644 --- a/spec/requests/api/rest/admin/billing/invoice_terminated_networks_spec.rb +++ b/spec/requests/api/rest/admin/invoice_terminated_networks_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Billing::InvoiceTerminatedNetworksController, type: :request, bullet: [:n] do - include_context :json_api_admin_helpers, type: :'invoice-terminated-networks', prefix: 'billing' +RSpec.describe Api::Rest::Admin::InvoiceTerminatedNetworksController, type: :request, bullet: [:n] do + include_context :json_api_admin_helpers, type: :'invoice-terminated-networks' describe 'GET /api/rest/admin/invoice-terminated-networks' do subject do diff --git a/spec/requests/api/rest/admin/billing/invoices_spec.rb b/spec/requests/api/rest/admin/invoices_spec.rb similarity index 99% rename from spec/requests/api/rest/admin/billing/invoices_spec.rb rename to spec/requests/api/rest/admin/invoices_spec.rb index 7a3042b32..6032b0258 100644 --- a/spec/requests/api/rest/admin/billing/invoices_spec.rb +++ b/spec/requests/api/rest/admin/invoices_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Billing::InvoicesController, type: :request, bullet: [:n] do - include_context :json_api_admin_helpers, type: :invoices, prefix: 'billing' +RSpec.describe Api::Rest::Admin::InvoicesController, type: :request, bullet: [:n] do + include_context :json_api_admin_helpers, type: :invoices describe 'GET /api/rest/admin/invoices' do subject do diff --git a/spec/requests/api/rest/admin/system/network_types_spec.rb b/spec/requests/api/rest/admin/network_types_spec.rb similarity index 79% rename from spec/requests/api/rest/admin/system/network_types_spec.rb rename to spec/requests/api/rest/admin/network_types_spec.rb index 523ddb3c4..2ddf1c93f 100644 --- a/spec/requests/api/rest/admin/system/network_types_spec.rb +++ b/spec/requests/api/rest/admin/network_types_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::System::NetworkTypesController, type: :request do - include_context :json_api_admin_helpers, type: :'network-types', prefix: 'system' +RSpec.describe Api::Rest::Admin::NetworkTypesController, type: :request do + include_context :json_api_admin_helpers, type: :'network-types' - describe 'GET /api/rest/admin/system/network-types' do + describe 'GET /api/rest/admin/network-types' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/system/networks_spec.rb b/spec/requests/api/rest/admin/networks_spec.rb similarity index 74% rename from spec/requests/api/rest/admin/system/networks_spec.rb rename to spec/requests/api/rest/admin/networks_spec.rb index 43348583e..3c784b105 100644 --- a/spec/requests/api/rest/admin/system/networks_spec.rb +++ b/spec/requests/api/rest/admin/networks_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::System::NetworksController, type: :request do - include_context :json_api_admin_helpers, type: :networks, prefix: 'system' +RSpec.describe Api::Rest::Admin::NetworksController, type: :request do + include_context :json_api_admin_helpers, type: :networks - describe 'GET /api/rest/admin/system/networks' do + describe 'GET /api/rest/admin/networks' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/routing/numberlist_items_spec.rb b/spec/requests/api/rest/admin/numberlist_items_spec.rb similarity index 76% rename from spec/requests/api/rest/admin/routing/numberlist_items_spec.rb rename to spec/requests/api/rest/admin/numberlist_items_spec.rb index f9c7934a7..e60693dec 100644 --- a/spec/requests/api/rest/admin/routing/numberlist_items_spec.rb +++ b/spec/requests/api/rest/admin/numberlist_items_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::NumberlistItemsController, type: :request do - include_context :json_api_admin_helpers, type: :'numberlist-items', prefix: 'routing' +RSpec.describe Api::Rest::Admin::NumberlistItemsController, type: :request do + include_context :json_api_admin_helpers, type: :'numberlist-items' - describe 'GET /api/rest/admin/routing/numberlist-items' do + describe 'GET /api/rest/admin/numberlist-items' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/routing/numberlists_spec.rb b/spec/requests/api/rest/admin/numberlists_spec.rb similarity index 69% rename from spec/requests/api/rest/admin/routing/numberlists_spec.rb rename to spec/requests/api/rest/admin/numberlists_spec.rb index 5c32c36fc..9137332f4 100644 --- a/spec/requests/api/rest/admin/routing/numberlists_spec.rb +++ b/spec/requests/api/rest/admin/numberlists_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::NumberlistsController, type: :request do - include_context :json_api_admin_helpers, type: :numberlists, prefix: 'routing' +RSpec.describe Api::Rest::Admin::NumberlistsController, type: :request do + include_context :json_api_admin_helpers, type: :numberlists - describe 'GET /api/rest/admin/routing/numberlists' do + describe 'GET /api/rest/admin/numberlists' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/routing/rateplans_spec.rb b/spec/requests/api/rest/admin/rateplans_spec.rb similarity index 69% rename from spec/requests/api/rest/admin/routing/rateplans_spec.rb rename to spec/requests/api/rest/admin/rateplans_spec.rb index 6dbb70458..f70f5b825 100644 --- a/spec/requests/api/rest/admin/routing/rateplans_spec.rb +++ b/spec/requests/api/rest/admin/rateplans_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::RateplansController, type: :request do - include_context :json_api_admin_helpers, type: :rateplans, prefix: 'routing' +RSpec.describe Api::Rest::Admin::RateplansController, type: :request do + include_context :json_api_admin_helpers, type: :rateplans - describe 'GET /api/rest/admin/routing/rateplans' do + describe 'GET /api/rest/admin/rateplans' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/equipment/registrations_spec.rb b/spec/requests/api/rest/admin/registrations_spec.rb similarity index 96% rename from spec/requests/api/rest/admin/equipment/registrations_spec.rb rename to spec/requests/api/rest/admin/registrations_spec.rb index 1b141a5ff..739672748 100644 --- a/spec/requests/api/rest/admin/equipment/registrations_spec.rb +++ b/spec/requests/api/rest/admin/registrations_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Equipment::RegistrationsController do - include_context :json_api_admin_helpers, type: :registrations, prefix: 'equipment' +RSpec.describe Api::Rest::Admin::RegistrationsController do + include_context :json_api_admin_helpers, type: :registrations let!(:nodes) { create_list(:node, 2) } let(:transport_protocols) { Equipment::TransportProtocol.all.to_a } @@ -39,7 +39,7 @@ end end - describe 'GET /api/rest/admin/equipment/registrations' do + describe 'GET /api/rest/admin/registrations' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end @@ -63,7 +63,7 @@ it_behaves_like :json_api_admin_check_authorization end - describe 'GET /api/rest/admin/equipment/registrations/:id' do + describe 'GET /api/rest/admin/registrations/:id' do subject do get json_api_request_path, params: request_params, headers: json_api_request_headers end @@ -140,7 +140,7 @@ end end - describe 'POST /api/rest/admin/equipment/registrations' do + describe 'POST /api/rest/admin/registrations' do subject do post json_api_request_path, params: request_body.to_json, headers: json_api_request_headers end @@ -253,7 +253,7 @@ end end - describe 'PATCH /api/rest/admin/equipment/registrations/:id' do + describe 'PATCH /api/rest/admin/registrations/:id' do subject do patch json_api_request_path, params: request_body.to_json, headers: json_api_request_headers end @@ -309,7 +309,7 @@ end end - describe 'DELETE /api/rest/admin/equipment/registrations/:id' do + describe 'DELETE /api/rest/admin/registrations/:id' do subject do delete json_api_request_path, params: request_params, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/routing/routeset_discriminators_spec.rb b/spec/requests/api/rest/admin/routeset_discriminators_spec.rb similarity index 77% rename from spec/requests/api/rest/admin/routing/routeset_discriminators_spec.rb rename to spec/requests/api/rest/admin/routeset_discriminators_spec.rb index 71d453e2d..f6d333231 100644 --- a/spec/requests/api/rest/admin/routing/routeset_discriminators_spec.rb +++ b/spec/requests/api/rest/admin/routeset_discriminators_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::RoutesetDiscriminatorsController, type: :request do - include_context :json_api_admin_helpers, type: :'routeset-discriminators', prefix: 'routing' +RSpec.describe Api::Rest::Admin::RoutesetDiscriminatorsController, type: :request do + include_context :json_api_admin_helpers, type: :'routeset-discriminators' - describe 'GET /api/rest/admin/routing/routeset-discriminators' do + describe 'GET /api/rest/admin/routeset-discriminators' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/routing/destinations_spec.rb b/spec/requests/api/rest/admin/routing/destinations_spec.rb deleted file mode 100644 index 3bcd5ccc7..000000000 --- a/spec/requests/api/rest/admin/routing/destinations_spec.rb +++ /dev/null @@ -1,183 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe Api::Rest::Admin::Routing::DestinationsController, type: :request do - include_context :json_api_admin_helpers, type: :destinations, prefix: 'routing' - - describe 'GET /api/rest/admin/routing/destinations' do - subject do - get json_api_request_path, params: index_params, headers: json_api_request_headers - end - let(:index_params) { {} } - - let!(:destinations) do - [ - FactoryBot.create(:destination, prefix: '370614', rate_group:, routing_tag_ids: []), - FactoryBot.create(:destination, rate_group:, routing_tag_ids: [routing_tag.id, nil]) - ] - end - let!(:rate_group) { FactoryBot.create(:rate_group, rateplans:) } - let!(:rateplans) { FactoryBot.create_list(:rateplan, 2) } - let!(:routing_tag) { FactoryBot.create(:routing_tag) } - - include_examples :jsonapi_responds_with_pagination_links - include_examples :returns_json_api_collection do - let(:json_api_collection_ids) do - destinations.map { |r| r.id.to_s } - end - end - - it_behaves_like :json_api_admin_check_authorization - - context 'with included country, next_rate and network' do - let(:index_params) do - { - filter: { - rateplan_id_eq: rateplans[0].id - }, - include: 'destination-next-rates,country,network', - page: { - number: 1, - size: 1000 - } - } - end - let!(:next_rate) do - FactoryBot.create(:destination_next_rate, destination: destinations.first) - end - let(:network_prefix) { destinations[0].network_prefix } - - before do - # not affected destinations - another_plan = FactoryBot.create(:rateplan) - another_group = FactoryBot.create(:rate_group, rateplans: [rateplans[1], another_plan]) - FactoryBot.create_list(:destination, 2, rate_group: another_group) - end - - include_examples :jsonapi_responds_with_pagination_links - - it 'should return correct response' do - subject - - expect(response.status).to eq(200) - expect(response_json).to match( - hash_including( - data: match_array( - [ - hash_including( - id: destinations[0].id.to_s, - type: 'destinations', - attributes: { - 'acd-limit': destinations[0].acd_limit, - 'asr-limit': destinations[0].asr_limit, - 'connect-fee': destinations[0].connect_fee.to_s, - 'dp-margin-fixed': destinations[0].dp_margin_fixed.to_s, - 'dp-margin-percent': destinations[0].dp_margin_percent.to_s, - 'dst-number-max-length': destinations[0].dst_number_max_length, - 'dst-number-min-length': destinations[0].dst_number_min_length, - enabled: destinations[0].enabled, - 'external-id': destinations[0].external_id, - 'initial-interval': destinations[0].initial_interval, - 'initial-rate': destinations[0].initial_rate.to_s, - 'next-interval': destinations[0].next_interval, - 'next-rate': destinations[0].next_rate.to_s, - prefix: destinations[0].prefix, - 'profit-control-mode-id': destinations[0].profit_control_mode_id, - 'rate-policy-id': destinations[0].rate_policy_id, - 'reject-calls': destinations[0].reject_calls, - 'reverse-billing': destinations[0].reverse_billing, - 'routing-tag-ids': destinations[0].routing_tag_ids, - 'short-calls-limit': destinations[0].short_calls_limit, - 'use-dp-intervals': destinations[0].use_dp_intervals, - 'valid-from': destinations[0].valid_from.iso8601(3), - 'valid-till': destinations[0].valid_till.iso8601(3) - }, - relationships: hash_including( - 'destination-next-rates': { - :data => [{ :id => next_rate.id.to_s, :type => 'destination-next-rates' }] - }, - country: { - :data => { :id => network_prefix.country.id.to_s, :type => 'countries' }, - links: be_present - }, - network: { - :data => { id: network_prefix.network.id.to_s, type: 'networks' }, - links: be_present - } - ) - ), - hash_including( - id: destinations[1].id.to_s, - type: 'destinations', - attributes: { - 'acd-limit': destinations[1].acd_limit, - 'asr-limit': destinations[1].asr_limit, - 'connect-fee': destinations[1].connect_fee.to_s, - 'dp-margin-fixed': destinations[1].dp_margin_fixed.to_s, - 'dp-margin-percent': destinations[1].dp_margin_percent.to_s, - 'dst-number-max-length': destinations[1].dst_number_max_length, - 'dst-number-min-length': destinations[1].dst_number_min_length, - enabled: destinations[1].enabled, - 'external-id': destinations[1].external_id, - 'initial-interval': destinations[1].initial_interval, - 'initial-rate': destinations[1].initial_rate.to_s, - 'next-interval': destinations[1].next_interval, - 'next-rate': destinations[1].next_rate.to_s, - prefix: destinations[1].prefix, - 'profit-control-mode-id': destinations[1].profit_control_mode_id, - 'rate-policy-id': destinations[1].rate_policy_id, - 'reject-calls': destinations[1].reject_calls, - 'reverse-billing': destinations[1].reverse_billing, - 'routing-tag-ids': destinations[1].routing_tag_ids, - 'short-calls-limit': destinations[1].short_calls_limit, - 'use-dp-intervals': destinations[1].use_dp_intervals, - 'valid-from': destinations[1].valid_from.iso8601(3), - 'valid-till': destinations[1].valid_till.iso8601(3) - }, - relationships: hash_including( - 'destination-next-rates': { :data => [] }, - country: { :data => nil, links: be_present }, - network: { :data => nil, links: be_present } - ) - ) - ] - ), - included: match_array( - [ - hash_including( - id: next_rate.id.to_s, - type: 'destination-next-rates', - attributes: { - applied: next_rate.applied, - 'apply-time': next_rate.apply_time.iso8601(3), - 'connect-fee': next_rate.connect_fee.to_s, - 'external-id': next_rate.external_id, - 'initial-interval': next_rate.initial_interval, - 'initial-rate': next_rate.initial_rate.to_s, - 'next-interval': next_rate.next_interval, - 'next-rate': next_rate.next_rate.to_s - } - ), - hash_including( - id: network_prefix.country.id.to_s, - type: 'countries', - attributes: { - name: network_prefix.country.name, - iso2: network_prefix.country.iso2 - } - ), - hash_including( - id: network_prefix.network.id.to_s, - type: 'networks', - attributes: { - name: network_prefix.network.name - } - ) - ] - ), - meta: { 'total-count': destinations.size } - ) - ) - end - end - end -end diff --git a/spec/requests/api/rest/admin/routing/routing_groups_spec.rb b/spec/requests/api/rest/admin/routing_groups_spec.rb similarity index 78% rename from spec/requests/api/rest/admin/routing/routing_groups_spec.rb rename to spec/requests/api/rest/admin/routing_groups_spec.rb index 1ae77478e..6471615c5 100644 --- a/spec/requests/api/rest/admin/routing/routing_groups_spec.rb +++ b/spec/requests/api/rest/admin/routing_groups_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::RoutingGroupsController, type: :request do - include_context :json_api_admin_helpers, type: :'routing-groups', prefix: 'routing' +RSpec.describe Api::Rest::Admin::RoutingGroupsController, type: :request do + include_context :json_api_admin_helpers, type: :'routing-groups' - describe 'GET /api/rest/admin/routing/routing-groups' do + describe 'GET /api/rest/admin/routing-groups' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/routing/routing_tag_detection_rules_spec.rb b/spec/requests/api/rest/admin/routing_tag_detection_rules_spec.rb similarity index 74% rename from spec/requests/api/rest/admin/routing/routing_tag_detection_rules_spec.rb rename to spec/requests/api/rest/admin/routing_tag_detection_rules_spec.rb index 26aa59ac6..5531492e6 100644 --- a/spec/requests/api/rest/admin/routing/routing_tag_detection_rules_spec.rb +++ b/spec/requests/api/rest/admin/routing_tag_detection_rules_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::RoutingTagDetectionRulesController, type: :request do - include_context :json_api_admin_helpers, type: :'routing-tag-detection-rules', prefix: 'routing' +RSpec.describe Api::Rest::Admin::RoutingTagDetectionRulesController, type: :request do + include_context :json_api_admin_helpers, type: :'routing-tag-detection-rules' - describe 'GET /api/rest/admin/routing/routing-tag-detection-rules' do + describe 'GET /api/rest/admin/routing-tag-detection-rules' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/routing/routing_tag_modes_spec.rb b/spec/requests/api/rest/admin/routing_tag_modes_spec.rb similarity index 76% rename from spec/requests/api/rest/admin/routing/routing_tag_modes_spec.rb rename to spec/requests/api/rest/admin/routing_tag_modes_spec.rb index 3d83b8549..53434fd45 100644 --- a/spec/requests/api/rest/admin/routing/routing_tag_modes_spec.rb +++ b/spec/requests/api/rest/admin/routing_tag_modes_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::RoutingTagModesController, type: :request do - include_context :json_api_admin_helpers, type: :'routing-tag-modes', prefix: 'routing' +RSpec.describe Api::Rest::Admin::RoutingTagModesController, type: :request do + include_context :json_api_admin_helpers, type: :'routing-tag-modes' - describe 'GET /api/rest/admin/routing/routing-tag-modes' do + describe 'GET /api/rest/admin/routing-tag-modes' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/routing/routing_tags_spec.rb b/spec/requests/api/rest/admin/routing_tags_spec.rb similarity index 77% rename from spec/requests/api/rest/admin/routing/routing_tags_spec.rb rename to spec/requests/api/rest/admin/routing_tags_spec.rb index a78761079..f6cf5f750 100644 --- a/spec/requests/api/rest/admin/routing/routing_tags_spec.rb +++ b/spec/requests/api/rest/admin/routing_tags_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::RoutingTagsController, type: :request do - include_context :json_api_admin_helpers, type: :'routing-tags', prefix: 'routing' +RSpec.describe Api::Rest::Admin::RoutingTagsController, type: :request do + include_context :json_api_admin_helpers, type: :'routing-tags' - describe 'GET /api/rest/admin/routing/routing-tags' do + describe 'GET /api/rest/admin/routing-tags' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/system/sensor_levels_spec.rb b/spec/requests/api/rest/admin/sensor_levels_spec.rb similarity index 78% rename from spec/requests/api/rest/admin/system/sensor_levels_spec.rb rename to spec/requests/api/rest/admin/sensor_levels_spec.rb index 98722505d..f3929c0dc 100644 --- a/spec/requests/api/rest/admin/system/sensor_levels_spec.rb +++ b/spec/requests/api/rest/admin/sensor_levels_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::System::SensorLevelsController, type: :request do - include_context :json_api_admin_helpers, type: :'sensor-levels', prefix: 'system' +RSpec.describe Api::Rest::Admin::SensorLevelsController, type: :request do + include_context :json_api_admin_helpers, type: :'sensor-levels' - describe 'GET /api/rest/admin/system/sensor-levels' do + describe 'GET /api/rest/admin/sensor-levels' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/system/sensors_spec.rb b/spec/requests/api/rest/admin/sensors_spec.rb similarity index 70% rename from spec/requests/api/rest/admin/system/sensors_spec.rb rename to spec/requests/api/rest/admin/sensors_spec.rb index 12f5c9c79..f8518e5b1 100644 --- a/spec/requests/api/rest/admin/system/sensors_spec.rb +++ b/spec/requests/api/rest/admin/sensors_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::System::SensorsController, type: :request do - include_context :json_api_admin_helpers, type: :sensors, prefix: 'system' +RSpec.describe Api::Rest::Admin::SensorsController, type: :request do + include_context :json_api_admin_helpers, type: :sensors - describe 'GET /api/rest/admin/system/sensors' do + describe 'GET /api/rest/admin/sensors' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/equipment/sip_oprions_probers_spec.rb b/spec/requests/api/rest/admin/sip_oprions_probers_spec.rb similarity index 96% rename from spec/requests/api/rest/admin/equipment/sip_oprions_probers_spec.rb rename to spec/requests/api/rest/admin/sip_oprions_probers_spec.rb index a41bbfdec..38a3733f1 100644 --- a/spec/requests/api/rest/admin/equipment/sip_oprions_probers_spec.rb +++ b/spec/requests/api/rest/admin/sip_oprions_probers_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Equipment::SipOptionsProbersController do - include_context :json_api_admin_helpers, type: :'sip-options-probers', prefix: :equipment +RSpec.describe Api::Rest::Admin::SipOptionsProbersController do + include_context :json_api_admin_helpers, type: :'sip-options-probers' let!(:nodes) { create_list(:node, 2) } let(:transport_protocols) { Equipment::TransportProtocol.all.to_a } @@ -41,7 +41,7 @@ end end - describe 'GET /api/rest/admin/equipment/sip-options-probers' do + describe 'GET /api/rest/admin/sip-options-probers' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end @@ -65,7 +65,7 @@ it_behaves_like :json_api_admin_check_authorization end - describe 'GET /api/rest/admin/equipment/sip-options-probers/:id' do + describe 'GET /api/rest/admin/sip-options-probers/:id' do subject do get json_api_request_path, params: request_params, headers: json_api_request_headers end @@ -142,7 +142,7 @@ end end - describe 'POST /api/rest/admin/equipment/sip-oprions-probers' do + describe 'POST /api/rest/admin/sip-oprions-probers' do subject do post json_api_request_path, params: request_body.to_json, headers: json_api_request_headers end @@ -248,7 +248,7 @@ end end - describe 'PATCH /api/rest/admin/equipment/sip-options-probers/:id' do + describe 'PATCH /api/rest/admin/sip-options-probers/:id' do subject do patch json_api_request_path, params: request_body.to_json, headers: json_api_request_headers end @@ -310,7 +310,7 @@ end end - describe 'DELETE /api/rest/admin/equipment/sip-options-probers/:id' do + describe 'DELETE /api/rest/admin/sip-options-probers/:id' do subject do delete json_api_request_path, params: request_params, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/system/smtp_connections_spec.rb b/spec/requests/api/rest/admin/smtp_connections_spec.rb similarity index 77% rename from spec/requests/api/rest/admin/system/smtp_connections_spec.rb rename to spec/requests/api/rest/admin/smtp_connections_spec.rb index 2388d604d..e24bb36c6 100644 --- a/spec/requests/api/rest/admin/system/smtp_connections_spec.rb +++ b/spec/requests/api/rest/admin/smtp_connections_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::System::SmtpConnectionsController, type: :request do - include_context :json_api_admin_helpers, type: :'smtp-connections', prefix: 'system' +RSpec.describe Api::Rest::Admin::SmtpConnectionsController, type: :request do + include_context :json_api_admin_helpers, type: :'smtp-connections' - describe 'GET /api/rest/admin/system/smtp-connections' do + describe 'GET /api/rest/admin/smtp-connections' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/routing/tag_action_spec.rb b/spec/requests/api/rest/admin/tag_action_spec.rb similarity index 68% rename from spec/requests/api/rest/admin/routing/tag_action_spec.rb rename to spec/requests/api/rest/admin/tag_action_spec.rb index 0fbe1a1c1..36017a6e5 100644 --- a/spec/requests/api/rest/admin/routing/tag_action_spec.rb +++ b/spec/requests/api/rest/admin/tag_action_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Routing::TagActionsController, type: :request do - include_context :json_api_admin_helpers, type: :'tag-actions', prefix: 'routing' +RSpec.describe Api::Rest::Admin::TagActionsController, type: :request do + include_context :json_api_admin_helpers, type: :'tag-actions' - describe 'GET /api/rest/admin/routing/tag-actions' do + describe 'GET /api/rest/admin/tag-actions' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/system/timezones_spec.rb b/spec/requests/api/rest/admin/timezones_spec.rb similarity index 71% rename from spec/requests/api/rest/admin/system/timezones_spec.rb rename to spec/requests/api/rest/admin/timezones_spec.rb index 2a84c6358..a1ab68646 100644 --- a/spec/requests/api/rest/admin/system/timezones_spec.rb +++ b/spec/requests/api/rest/admin/timezones_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::System::TimezonesController, type: :request do - include_context :json_api_admin_helpers, type: :timezones, prefix: 'system' +RSpec.describe Api::Rest::Admin::TimezonesController, type: :request do + include_context :json_api_admin_helpers, type: :timezones - describe 'GET /api/rest/admin/system/timezones' do + describe 'GET /api/rest/admin/timezones' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/requests/api/rest/admin/equipment/transport_protocols_spec.rb b/spec/requests/api/rest/admin/transport_protocols_spec.rb similarity index 75% rename from spec/requests/api/rest/admin/equipment/transport_protocols_spec.rb rename to spec/requests/api/rest/admin/transport_protocols_spec.rb index f32d92852..761db598f 100644 --- a/spec/requests/api/rest/admin/equipment/transport_protocols_spec.rb +++ b/spec/requests/api/rest/admin/transport_protocols_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Api::Rest::Admin::Equipment::TransportProtocolsController, type: :request do - include_context :json_api_admin_helpers, type: :'transport-protocols', prefix: 'equipment' +RSpec.describe Api::Rest::Admin::TransportProtocolsController, type: :request do + include_context :json_api_admin_helpers, type: :'transport-protocols' - describe 'GET /api/rest/admin/equipment/transport-protocols' do + describe 'GET /api/rest/admin/transport-protocols' do subject do get json_api_request_path, params: nil, headers: json_api_request_headers end diff --git a/spec/support/contexts/acceptance/acceptance_delete.rb b/spec/support/contexts/acceptance/acceptance_delete.rb index 9c1f67718..f333f8cf5 100644 --- a/spec/support/contexts/acceptance/acceptance_delete.rb +++ b/spec/support/contexts/acceptance/acceptance_delete.rb @@ -1,11 +1,7 @@ # frozen_string_literal: true -RSpec.shared_context :acceptance_delete do |namespace: nil, type:| - resource_path = begin - str = '/api/rest/admin' - str += "/#{namespace}" if namespace - str + "/#{type}" - end +RSpec.shared_context :acceptance_delete do |type:| + resource_path = "/api/rest/admin/#{type}" delete "#{resource_path}/:id" do let(:id) { record.id } diff --git a/spec/support/contexts/acceptance/acceptance_index_show.rb b/spec/support/contexts/acceptance/acceptance_index_show.rb index a1ed615f4..4c3e5d80c 100644 --- a/spec/support/contexts/acceptance/acceptance_index_show.rb +++ b/spec/support/contexts/acceptance/acceptance_index_show.rb @@ -1,16 +1,12 @@ # frozen_string_literal: true -RSpec.shared_context :acceptance_index_show do |namespace: nil, type:| +RSpec.shared_context :acceptance_index_show do |type:| # let(:collection) { ModelClass.all } # let(:record) { ModelClass.take } let(:type) { type } - resource_path = begin - str = '/api/rest/admin' - str += "/#{namespace}" if namespace - str + "/#{type}" - end + resource_path = "/api/rest/admin/#{type}" get resource_path do before { collection } diff --git a/spec/support/contexts/json_api/json_api_admin_helpers.rb b/spec/support/contexts/json_api/json_api_admin_helpers.rb index d5dd2b805..06bf50a1c 100644 --- a/spec/support/contexts/json_api/json_api_admin_helpers.rb +++ b/spec/support/contexts/json_api/json_api_admin_helpers.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.shared_context :json_api_admin_helpers do |type: nil, prefix: nil| +RSpec.shared_context :json_api_admin_helpers do |type: nil| let(:json_api_resource_type) { type.to_s } let(:json_api_auth_token) { ::Knock::AuthToken.new(payload: { sub: admin_user.id }).token } - let(:json_api_request_path_prefix) { ['/api/rest/admin', prefix].compact.join('/') } + let(:json_api_request_path_prefix) { '/api/rest/admin' } let(:json_api_request_path) { "#{json_api_request_path_prefix}/#{json_api_resource_type}" } let(:json_api_request_headers) do { diff --git a/spec/support/examples/json_api/returns_json_api_record.rb b/spec/support/examples/json_api/returns_json_api_record.rb index f7e3dfe8a..517db7433 100644 --- a/spec/support/examples/json_api/returns_json_api_record.rb +++ b/spec/support/examples/json_api/returns_json_api_record.rb @@ -1,7 +1,10 @@ # frozen_string_literal: true RSpec.shared_examples :returns_json_api_record do |relationships: [], type: nil, status: 200| - let(:json_api_record_data) { response_json[:data] } # can be overridden to check one of collection's item + let(:json_api_data_detect_by_id_type) { response_json[:data].detect { |d| d[:id] == json_api_record_id && d[:type] == type } } + # can be overridden to check one of collection's item + # let(:json_api_record_data) { json_api_data_detect_by_id_type } + let(:json_api_record_data) { response_json[:data] } let(:json_api_record_id) { nil } let(:json_api_record_attributes) { nil } let(:json_api_record_type) { type || json_api_resource_type } From 5c63011ed9fc3396326dfa394b8189eca04980ff Mon Sep 17 00:00:00 2001 From: Denis Talakevich Date: Sun, 17 Nov 2024 16:54:30 +0200 Subject: [PATCH 2/2] remove Knock auth --- Gemfile | 1 - Gemfile.lock | 10 ---- .../api/rest/admin/auth_controller.rb | 34 +++++++---- .../concerns/admin_api_authorizable.rb | 18 +++--- app/lib/authentication/admin_auth.rb | 56 ++++++++++++++++++ app/lib/authorization/admin_auth.rb | 40 +++++++++++++ config/initializers/knock.rb | 59 ------------------- .../admin/api/accounting_profiles_spec.rb | 7 +-- .../rest/admin/api/accounts_spec.rb | 7 +-- .../rest/admin/api/active_calls_spec.rb | 7 +-- .../rest/admin/api/api_accesses_spec.rb | 7 +-- .../rest/admin/api/auth_profiles_spec.rb | 7 +-- .../rest/admin/api/cdr_exports_spec.rb | 7 +-- spec/acceptance/rest/admin/api/cdrs_spec.rb | 7 +-- .../rest/admin/api/codec_groups_spec.rb | 7 +-- .../rest/admin/api/contacts_spec.rb | 7 +-- .../rest/admin/api/contractors_spec.rb | 7 +-- .../rest/admin/api/customers_auths_spec.rb | 7 +-- .../admin/api/destination_next_rates_spec.rb | 7 +-- .../rest/admin/api/destinations_spec.rb | 7 +-- .../admin/api/dialpeer_next_rates_spec.rb | 7 +-- .../rest/admin/api/dialpeers_spec.rb | 7 +-- .../admin/api/disconnect_policies_spec.rb | 7 +-- .../rest/admin/api/diversion_policies_spec.rb | 7 +-- .../rest/admin/api/dtmf_receive_modes_spec.rb | 7 +-- .../rest/admin/api/dtmf_send_modes_spec.rb | 7 +-- .../rest/admin/api/filter_types_spec.rb | 7 +-- .../rest/admin/api/gateway_groups_spec.rb | 7 +-- ...ateway_inband_dtmf_filtering_modes_spec.rb | 7 +-- .../gateway_media_encryption_modes_spec.rb | 7 +-- ...ateway_network_protocol_priorities_spec.rb | 7 +-- .../admin/api/gateway_rel100_modes_spec.rb | 7 +-- .../rest/admin/api/gateways_spec.rb | 7 +-- .../admin/api/incoming_registrations_spec.rb | 7 +-- .../invoice_originated_destinations_spec.rb | 7 +-- .../api/invoice_originated_networks_spec.rb | 7 +-- .../admin/api/invoice_service_data_spec.rb | 7 +-- .../rest/admin/api/invoice_template_spec.rb | 7 +-- .../invoice_terminated_destinations_spec.rb | 7 +-- .../api/invoice_terminated_networks_spec.rb | 7 +-- .../rest/admin/api/invoices_spec.rb | 7 +-- .../rest/admin/api/network_types_spec.rb | 7 +-- .../rest/admin/api/networks_spec.rb | 7 +-- spec/acceptance/rest/admin/api/nodes_spec.rb | 7 +-- .../rest/admin/api/payments_spec.rb | 7 +-- spec/acceptance/rest/admin/api/pops_spec.rb | 7 +-- .../rest/admin/api/rateplans_spec.rb | 7 +-- .../admin/api/routeset_discriminators_spec.rb | 7 +-- .../rest/admin/api/routing_groups_spec.rb | 7 +-- .../rest/admin/api/routing_plans_spec.rb | 7 +-- .../rest/admin/api/sdp_c_locations_spec.rb | 7 +-- .../rest/admin/api/sensor_levels_spec.rb | 7 +-- .../acceptance/rest/admin/api/sensors_spec.rb | 7 +-- .../rest/admin/api/service_types_spec.rb | 7 +-- .../rest/admin/api/services_spec.rb | 7 +-- .../admin/api/session_refresh_methods_spec.rb | 7 +-- .../admin/api/sip_options_probers_spec.rb | 7 +-- .../rest/admin/api/smtp_connections_spec.rb | 7 +-- .../rest/admin/api/timezones_spec.rb | 7 +-- .../admin/api/transport_protocols_spec.rb | 7 +-- .../rest/admin/accounts_controller_spec.rb | 9 +-- .../admin/api_accesses_controller_spec.rb | 9 +-- .../api/rest/admin/balance_controller_spec.rb | 9 +-- .../admin/codec_groups_controller_spec.rb | 9 +-- .../rest/admin/contacts_controller_spec.rb | 9 +-- .../rest/admin/contractors_controller_spec.rb | 9 +-- .../admin/destinations_controller_spec.rb | 2 +- .../admin/gateway_groups_controller_spec.rb | 10 +--- .../rest/admin/payments_controller_spec.rb | 11 +--- .../admin/routing_plans_controller_spec.rb | 9 +-- .../acceptance/acceptance_admin_user.rb | 4 +- .../json_api/json_api_admin_helpers.rb | 2 +- .../support/contexts/jsonapi_admin_headers.rb | 4 +- .../json_api_admin_check_authorization.rb | 4 +- 74 files changed, 199 insertions(+), 490 deletions(-) create mode 100644 app/lib/authentication/admin_auth.rb create mode 100644 app/lib/authorization/admin_auth.rb delete mode 100644 config/initializers/knock.rb diff --git a/Gemfile b/Gemfile index 92b05781a..23117db8e 100644 --- a/Gemfile +++ b/Gemfile @@ -22,7 +22,6 @@ gem 'net-ldap', '~> 0.16.0' # Seamless JWT authentication for Rails API gem 'jwt' -gem 'knock', github: 'nsarno/knock' # ActiveAdmin gem 'activeadmin' diff --git a/Gemfile.lock b/Gemfile.lock index ab10fc481..a8f0cdbe8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -64,15 +64,6 @@ GIT jquery-ui-rails (7.0.0) railties (>= 3.2.16) -GIT - remote: https://github.com/nsarno/knock.git - revision: 37e403a7c6d44f585b56a086245e41566a8d6fe1 - specs: - knock (2.2.0) - bcrypt (~> 3.1) - jwt (~> 2.2.1) - rails (>= 5) - GIT remote: https://github.com/senid231/excelinator.git revision: 25afcc544a6f287a2ace9018adbe6fc96ea29cb2 @@ -900,7 +891,6 @@ DEPENDENCIES jrpc! jsonapi-resources (~> 0.9.12) jwt - knock! listen matrix (~> 0.4.2) mini_racer diff --git a/app/controllers/api/rest/admin/auth_controller.rb b/app/controllers/api/rest/admin/auth_controller.rb index c7d935242..ef9d369d1 100644 --- a/app/controllers/api/rest/admin/auth_controller.rb +++ b/app/controllers/api/rest/admin/auth_controller.rb @@ -1,40 +1,50 @@ # frozen_string_literal: true -class Api::Rest::Admin::AuthController < Knock::AuthTokenController +class Api::Rest::Admin::AuthController < ApplicationController + skip_before_action :verify_authenticity_token + include Memoizable include WithPayloads + rescue_from Authentication::AdminAuth::AuthenticationError, with: :handle_authentication_error + rescue_from Authentication::AdminAuth::IpAddressNotAllowedError, with: :handle_ip_not_allowed + define_memoizable :debug_mode, apply: -> { System::ApiLogConfig.exists?(controller: self.class.name) } + before_action :authenticate + + def create + render json: { jwt: @auth_token }, status: 201 + end + def meta nil end private - def entity_name - 'AdminUser' + def authenticate + result = Authentication::AdminAuth.authenticate!( + auth_params[:username], + auth_params[:password], + remote_ip: request.remote_ip + ) + @auth_token = result.token end def auth_params - params.require(:auth).permit :username, :password + params.require(:auth).permit(:username, :password) end - def not_found + def handle_authentication_error error = JSONAPI::Exceptions::AuthenticationFailed.new render status: 401, json: { errors: error.errors.map(&:to_hash) } end - def ip_not_allowed + def handle_ip_not_allowed error = JSONAPI::Exceptions::AuthenticationFailed.new( detail: 'Your IP address is not allowed.' ) render status: 401, json: { errors: error.errors.map(&:to_hash) } end - - def authenticate - super - - ip_not_allowed unless entity.ip_allowed?(request.remote_ip) - end end diff --git a/app/controllers/concerns/admin_api_authorizable.rb b/app/controllers/concerns/admin_api_authorizable.rb index 47e06fee7..6d71b7338 100644 --- a/app/controllers/concerns/admin_api_authorizable.rb +++ b/app/controllers/concerns/admin_api_authorizable.rb @@ -4,10 +4,10 @@ module AdminApiAuthorizable extend ActiveSupport::Concern included do - include Knock::Authenticable - undef :current_admin_user + rescue_from Authorization::AdminAuth::AuthorizationError, with: :handle_authorization_error - before_action :authenticate_admin_user! + before_action :authorize + attr_reader :current_admin_user end def context @@ -27,9 +27,13 @@ def capture_user private - def authenticate_admin_user! - if !authenticate_for(::AdminUser) || !current_admin_user.ip_allowed?(request.remote_ip) - unauthorized_entity('admin_user') - end + def authorize + auth_token = params[:token] || request.headers['Authorization']&.split&.last + result = Authorization::AdminAuth.authorize!(auth_token, remote_ip: request.remote_ip) + @current_admin_user = result.entity + end + + def handle_authorization_error + head 401 end end diff --git a/app/lib/authentication/admin_auth.rb b/app/lib/authentication/admin_auth.rb new file mode 100644 index 000000000..0cb24f3f5 --- /dev/null +++ b/app/lib/authentication/admin_auth.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +module Authentication + class AdminAuth + EXPIRATION_INTERVAL = YetiConfig.api.token_lifetime.presence&.seconds&.freeze + AUDIENCE = 'admin' + AuthenticationError = Class.new(StandardError) + IpAddressNotAllowedError = Class.new(AuthenticationError) + Result = Data.define(:token) + + class << self + # @param username [String] + # @param password [String] + # @param remote_ip [String] + # @return [Authentication::AdminAuth::Result] when success + # @raise [Authentication::AdminAuth::AuthenticationError] when failed caused by invalid username or password + # @raise [Authentication::AdminAuth::IpAddressNotAllowedError] when failed caused by IP address not allowed + def authenticate!(username, password, remote_ip:) + instance = new(username, password, remote_ip: remote_ip) + instance.authenticate! + end + + # @param admin_user [AdminUser] + # @param expires_at [Time,nil] overrides default expiration + # @return [Authentication::CustomerV1Auth::Result] + def build_auth_data(admin_user, expires_at: nil) + expires_at ||= EXPIRATION_INTERVAL&.from_now + payload = { sub: admin_user.id, aud: AUDIENCE } + payload[:exp] = expires_at.to_i unless expires_at.nil? + token = JwtToken.encode(payload) + Result.new(token) + end + end + + # @param username [String] + # @param password [String] + # @param remote_ip [String] + def initialize(username, password, remote_ip:) + @username = username + @password = password + @remote_ip = remote_ip + end + + # @return [Authentication::AdminAuth::Result] when success + # @raise [Authentication::AdminAuth::AuthenticationError] when failed caused by invalid username or password + # @raise [Authentication::AdminAuth::IpAddressNotAllowedError] when failed caused by IP address not allowed + def authenticate! + admin_user = AdminUser.find_by(username: @username) + raise AuthenticationError if admin_user.nil? + raise AuthenticationError unless admin_user.authenticate(@password) + raise IpAddressNotAllowedError unless admin_user.ip_allowed?(@remote_ip) + + self.class.build_auth_data(admin_user) + end + end +end diff --git a/app/lib/authorization/admin_auth.rb b/app/lib/authorization/admin_auth.rb new file mode 100644 index 000000000..71a0eef19 --- /dev/null +++ b/app/lib/authorization/admin_auth.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +module Authorization + class AdminAuth + Result = Struct.new(:entity) + AuthorizationError = Class.new(StandardError) + + class << self + # @param token [String] + # @param remote_ip [String] + # @return [Authorization::AdminAuth::Result] when success + # @raise [Authorization::AdminAuth::AuthenticationError] when failed + def authorize!(token, remote_ip:) + new(token, remote_ip:).authorize! + end + end + + # @param token [String] + # @param remote_ip [String] + def initialize(token, remote_ip:) + @token = token + @remote_ip = remote_ip + end + + # @return [Authorization::AdminAuth::Result] when success + # @raise [Authorization::AdminAuth::AuthenticationError] when failed + def authorize! + verify_expiration = Authentication::AdminAuth::EXPIRATION_INTERVAL.present? + audience = Authentication::AdminAuth::AUDIENCE + payload = JwtToken.decode(@token, verify_expiration: verify_expiration, aud: audience) + raise AuthorizationError if payload.nil? + + admin_user = AdminUser.find_by(id: payload[:sub]) + raise AuthorizationError if admin_user.nil? + raise AuthorizationError unless admin_user.ip_allowed?(@remote_ip) + + Result.new(admin_user) + end + end +end diff --git a/config/initializers/knock.rb b/config/initializers/knock.rb deleted file mode 100644 index 0600a26f9..000000000 --- a/config/initializers/knock.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -require 'rails/generators' -Knock.setup do |config| - ## Expiration claim - ## ---------------- - ## - ## How long before a token is expired. If nil is provided, token will - ## last forever. - ## - config.token_lifetime = YetiConfig.api.token_lifetime.presence&.seconds - - ## Audience claim - ## -------------- - ## - ## Configure the audience claim to identify the recipients that the token - ## is intended for. - ## - ## Default: - # config.token_audience = nil - - ## If using Auth0, uncomment the line below - # config.token_audience = -> { Rails.application.secrets.auth0_client_id } - - ## Signature algorithm - ## ------------------- - ## - ## Configure the algorithm used to encode the token - ## - ## Default: - # config.token_signature_algorithm = 'HS256' - - ## Signature key - ## ------------- - ## - ## Configure the key used to sign tokens. - ## - ## Default: - # config.token_secret_signature_key = -> { Rails.application.secrets.secret_key_base } - - ## If using Auth0, uncomment the line below - # config.token_secret_signature_key = -> { JWT.base64url_decode Rails.application.secrets.auth0_client_secret } - - ## Public key - ## ---------- - ## - ## Configure the public key used to decode tokens, if required. - ## - ## Default: - # config.token_public_key = nil - - ## Exception Class - ## --------------- - ## - ## Configure the exception to be used when user cannot be found. - ## - ## Default: - # config.not_found_exception_class_name = 'ActiveRecord::RecordNotFound' -end diff --git a/spec/acceptance/rest/admin/api/accounting_profiles_spec.rb b/spec/acceptance/rest/admin/api/accounting_profiles_spec.rb index 4fe915310..b03b06ce8 100644 --- a/spec/acceptance/rest/admin/api/accounting_profiles_spec.rb +++ b/spec/acceptance/rest/admin/api/accounting_profiles_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Accounting profiles' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'accounting-profiles' } required_params = %i[name server port secret timeout attempts] diff --git a/spec/acceptance/rest/admin/api/accounts_spec.rb b/spec/acceptance/rest/admin/api/accounts_spec.rb index 4051d9067..f3d4526d6 100644 --- a/spec/acceptance/rest/admin/api/accounts_spec.rb +++ b/spec/acceptance/rest/admin/api/accounts_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Accounts' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'accounts' } required_params = %i[name min-balance max-balance] diff --git a/spec/acceptance/rest/admin/api/active_calls_spec.rb b/spec/acceptance/rest/admin/api/active_calls_spec.rb index 071558f19..c3057109e 100644 --- a/spec/acceptance/rest/admin/api/active_calls_spec.rb +++ b/spec/acceptance/rest/admin/api/active_calls_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'ActiveCalls' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'active-calls' } include_context :active_calls_stub_helpers do diff --git a/spec/acceptance/rest/admin/api/api_accesses_spec.rb b/spec/acceptance/rest/admin/api/api_accesses_spec.rb index e3930dff2..fef4f526a 100644 --- a/spec/acceptance/rest/admin/api/api_accesses_spec.rb +++ b/spec/acceptance/rest/admin/api/api_accesses_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'ApiAccesses' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'api-accesses' } required_params = %i[customer-id login password] diff --git a/spec/acceptance/rest/admin/api/auth_profiles_spec.rb b/spec/acceptance/rest/admin/api/auth_profiles_spec.rb index 1b1c1f81c..8a2729311 100644 --- a/spec/acceptance/rest/admin/api/auth_profiles_spec.rb +++ b/spec/acceptance/rest/admin/api/auth_profiles_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Auth profiles' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'auth-profiles' } required_params = %i[name server port secret timeout attempts] diff --git a/spec/acceptance/rest/admin/api/cdr_exports_spec.rb b/spec/acceptance/rest/admin/api/cdr_exports_spec.rb index d81c744cc..1b83fdb22 100644 --- a/spec/acceptance/rest/admin/api/cdr_exports_spec.rb +++ b/spec/acceptance/rest/admin/api/cdr_exports_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Cdr Exports' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'cdr-exports' } let(:country) { System::Country.take! } diff --git a/spec/acceptance/rest/admin/api/cdrs_spec.rb b/spec/acceptance/rest/admin/api/cdrs_spec.rb index 9db89052f..4c4716d9b 100644 --- a/spec/acceptance/rest/admin/api/cdrs_spec.rb +++ b/spec/acceptance/rest/admin/api/cdrs_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Cdrs' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'cdrs' } get '/api/rest/admin/cdrs' do diff --git a/spec/acceptance/rest/admin/api/codec_groups_spec.rb b/spec/acceptance/rest/admin/api/codec_groups_spec.rb index 7ab3be509..a4617bf78 100644 --- a/spec/acceptance/rest/admin/api/codec_groups_spec.rb +++ b/spec/acceptance/rest/admin/api/codec_groups_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Codec groups' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'codec-groups' } get '/api/rest/admin/codec-groups' do diff --git a/spec/acceptance/rest/admin/api/contacts_spec.rb b/spec/acceptance/rest/admin/api/contacts_spec.rb index bce9aec60..3fcd523ec 100644 --- a/spec/acceptance/rest/admin/api/contacts_spec.rb +++ b/spec/acceptance/rest/admin/api/contacts_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Contacts' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'contacts' } required_params = %i[email] diff --git a/spec/acceptance/rest/admin/api/contractors_spec.rb b/spec/acceptance/rest/admin/api/contractors_spec.rb index c01a86bf1..875804804 100644 --- a/spec/acceptance/rest/admin/api/contractors_spec.rb +++ b/spec/acceptance/rest/admin/api/contractors_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Contractors' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'contractors' } required_params = %i[name vendor customer] diff --git a/spec/acceptance/rest/admin/api/customers_auths_spec.rb b/spec/acceptance/rest/admin/api/customers_auths_spec.rb index 539e7deef..b13abafd6 100644 --- a/spec/acceptance/rest/admin/api/customers_auths_spec.rb +++ b/spec/acceptance/rest/admin/api/customers_auths_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Customer Auths' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'customers-auths' } required_params = %i[name ip] diff --git a/spec/acceptance/rest/admin/api/destination_next_rates_spec.rb b/spec/acceptance/rest/admin/api/destination_next_rates_spec.rb index 68379d3d8..cad64a7c1 100644 --- a/spec/acceptance/rest/admin/api/destination_next_rates_spec.rb +++ b/spec/acceptance/rest/admin/api/destination_next_rates_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Destination next rates' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'destination-next-rates' } let(:destination) { create(:destination) } let(:destination_id) { destination.id } diff --git a/spec/acceptance/rest/admin/api/destinations_spec.rb b/spec/acceptance/rest/admin/api/destinations_spec.rb index 2e661ada4..eed38c724 100644 --- a/spec/acceptance/rest/admin/api/destinations_spec.rb +++ b/spec/acceptance/rest/admin/api/destinations_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Destinations' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'destinations' } required_params = %i[ diff --git a/spec/acceptance/rest/admin/api/dialpeer_next_rates_spec.rb b/spec/acceptance/rest/admin/api/dialpeer_next_rates_spec.rb index ef2dc8594..08bf5a4bf 100644 --- a/spec/acceptance/rest/admin/api/dialpeer_next_rates_spec.rb +++ b/spec/acceptance/rest/admin/api/dialpeer_next_rates_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Dialpeer next rates' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'dialpeer-next-rates' } let(:dialpeer) { create(:dialpeer) } let(:dialpeer_id) { dialpeer.id } diff --git a/spec/acceptance/rest/admin/api/dialpeers_spec.rb b/spec/acceptance/rest/admin/api/dialpeers_spec.rb index 89fd94fff..1b134441c 100644 --- a/spec/acceptance/rest/admin/api/dialpeers_spec.rb +++ b/spec/acceptance/rest/admin/api/dialpeers_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Dialpeers' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'dialpeers' } required_params = %i[ diff --git a/spec/acceptance/rest/admin/api/disconnect_policies_spec.rb b/spec/acceptance/rest/admin/api/disconnect_policies_spec.rb index 6a8caabf3..85679cc37 100644 --- a/spec/acceptance/rest/admin/api/disconnect_policies_spec.rb +++ b/spec/acceptance/rest/admin/api/disconnect_policies_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Disconnect policies' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'disconnect-policies' } get '/api/rest/admin/disconnect-policies' do diff --git a/spec/acceptance/rest/admin/api/diversion_policies_spec.rb b/spec/acceptance/rest/admin/api/diversion_policies_spec.rb index 8ec5b43cd..386d312a1 100644 --- a/spec/acceptance/rest/admin/api/diversion_policies_spec.rb +++ b/spec/acceptance/rest/admin/api/diversion_policies_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Diversion policies' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'diversion-policies' } get '/api/rest/admin/diversion-policies' do diff --git a/spec/acceptance/rest/admin/api/dtmf_receive_modes_spec.rb b/spec/acceptance/rest/admin/api/dtmf_receive_modes_spec.rb index 0c70351b9..dbed3ca72 100644 --- a/spec/acceptance/rest/admin/api/dtmf_receive_modes_spec.rb +++ b/spec/acceptance/rest/admin/api/dtmf_receive_modes_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Dtmf receive modes' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'dtmf-receive-modes' } get '/api/rest/admin/dtmf-receive-modes' do diff --git a/spec/acceptance/rest/admin/api/dtmf_send_modes_spec.rb b/spec/acceptance/rest/admin/api/dtmf_send_modes_spec.rb index 2d8bf5f6f..c926ba755 100644 --- a/spec/acceptance/rest/admin/api/dtmf_send_modes_spec.rb +++ b/spec/acceptance/rest/admin/api/dtmf_send_modes_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Dtmf send modes' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'dtmf-send-modes' } get '/api/rest/admin/dtmf-send-modes' do diff --git a/spec/acceptance/rest/admin/api/filter_types_spec.rb b/spec/acceptance/rest/admin/api/filter_types_spec.rb index b2aa2d816..e485a7f84 100644 --- a/spec/acceptance/rest/admin/api/filter_types_spec.rb +++ b/spec/acceptance/rest/admin/api/filter_types_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Filter types' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'filter-types' } get '/api/rest/admin/filter-types' do diff --git a/spec/acceptance/rest/admin/api/gateway_groups_spec.rb b/spec/acceptance/rest/admin/api/gateway_groups_spec.rb index 1cfc198bd..59f27e6d1 100644 --- a/spec/acceptance/rest/admin/api/gateway_groups_spec.rb +++ b/spec/acceptance/rest/admin/api/gateway_groups_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Gateway groups' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'gateway-groups' } get '/api/rest/admin/gateway-groups' do diff --git a/spec/acceptance/rest/admin/api/gateway_inband_dtmf_filtering_modes_spec.rb b/spec/acceptance/rest/admin/api/gateway_inband_dtmf_filtering_modes_spec.rb index ccfba42bb..d80dd18e9 100644 --- a/spec/acceptance/rest/admin/api/gateway_inband_dtmf_filtering_modes_spec.rb +++ b/spec/acceptance/rest/admin/api/gateway_inband_dtmf_filtering_modes_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Gateway inband dtmf filtering mode' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'gateway-inband-dtmf-filtering-modes' } get '/api/rest/admin/gateway-inband-dtmf-filtering-modes' do diff --git a/spec/acceptance/rest/admin/api/gateway_media_encryption_modes_spec.rb b/spec/acceptance/rest/admin/api/gateway_media_encryption_modes_spec.rb index 57c0c5702..c3a414ccc 100644 --- a/spec/acceptance/rest/admin/api/gateway_media_encryption_modes_spec.rb +++ b/spec/acceptance/rest/admin/api/gateway_media_encryption_modes_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Gateway Media encryption modes' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'gateway-media-encryption-modes' } get '/api/rest/admin/gateway-media-encryption-modes' do diff --git a/spec/acceptance/rest/admin/api/gateway_network_protocol_priorities_spec.rb b/spec/acceptance/rest/admin/api/gateway_network_protocol_priorities_spec.rb index caed96ae1..ab5afec67 100644 --- a/spec/acceptance/rest/admin/api/gateway_network_protocol_priorities_spec.rb +++ b/spec/acceptance/rest/admin/api/gateway_network_protocol_priorities_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Gateway Network protocol priorities' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'gateway-network-protocol-priorities' } get '/api/rest/admin/gateway-network-protocol-priorities' do diff --git a/spec/acceptance/rest/admin/api/gateway_rel100_modes_spec.rb b/spec/acceptance/rest/admin/api/gateway_rel100_modes_spec.rb index 325377ff9..1e4affbcc 100644 --- a/spec/acceptance/rest/admin/api/gateway_rel100_modes_spec.rb +++ b/spec/acceptance/rest/admin/api/gateway_rel100_modes_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Gateway rel100 modes' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'gateway-rel100-modes' } get '/api/rest/admin/gateway-rel100-modes' do diff --git a/spec/acceptance/rest/admin/api/gateways_spec.rb b/spec/acceptance/rest/admin/api/gateways_spec.rb index e21481428..12096a87f 100644 --- a/spec/acceptance/rest/admin/api/gateways_spec.rb +++ b/spec/acceptance/rest/admin/api/gateways_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Gateways' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'gateways' } resource_data = jsonapi_extract_fields_data(Api::Rest::Admin::GatewayResource) diff --git a/spec/acceptance/rest/admin/api/incoming_registrations_spec.rb b/spec/acceptance/rest/admin/api/incoming_registrations_spec.rb index 13b08c7b0..ea715f831 100644 --- a/spec/acceptance/rest/admin/api/incoming_registrations_spec.rb +++ b/spec/acceptance/rest/admin/api/incoming_registrations_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'IncomingRegistrations' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'incoming-registrations' } before { FactoryBot.create(:node) } diff --git a/spec/acceptance/rest/admin/api/invoice_originated_destinations_spec.rb b/spec/acceptance/rest/admin/api/invoice_originated_destinations_spec.rb index 906a19f80..3d545a16d 100644 --- a/spec/acceptance/rest/admin/api/invoice_originated_destinations_spec.rb +++ b/spec/acceptance/rest/admin/api/invoice_originated_destinations_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Invoice Originated Destinations' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'invoice-originated-destinations' } get '/api/rest/admin/invoice-originated-destinations' do diff --git a/spec/acceptance/rest/admin/api/invoice_originated_networks_spec.rb b/spec/acceptance/rest/admin/api/invoice_originated_networks_spec.rb index e42d0f06a..5acccaf31 100644 --- a/spec/acceptance/rest/admin/api/invoice_originated_networks_spec.rb +++ b/spec/acceptance/rest/admin/api/invoice_originated_networks_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Invoice Originated Networks' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'invoice-originated-networks' } get '/api/rest/admin/invoice-originated-networks' do diff --git a/spec/acceptance/rest/admin/api/invoice_service_data_spec.rb b/spec/acceptance/rest/admin/api/invoice_service_data_spec.rb index fe15b5348..9a652ba39 100644 --- a/spec/acceptance/rest/admin/api/invoice_service_data_spec.rb +++ b/spec/acceptance/rest/admin/api/invoice_service_data_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Invoice Service Data' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'invoice-service-data' } get '/api/rest/admin/invoice-service-data' do diff --git a/spec/acceptance/rest/admin/api/invoice_template_spec.rb b/spec/acceptance/rest/admin/api/invoice_template_spec.rb index b4820ca0c..4c7c4100a 100644 --- a/spec/acceptance/rest/admin/api/invoice_template_spec.rb +++ b/spec/acceptance/rest/admin/api/invoice_template_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Invoice template' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'invoice-templates' } get '/api/rest/admin/invoice-template' do diff --git a/spec/acceptance/rest/admin/api/invoice_terminated_destinations_spec.rb b/spec/acceptance/rest/admin/api/invoice_terminated_destinations_spec.rb index 11bd2df68..10966d3f0 100644 --- a/spec/acceptance/rest/admin/api/invoice_terminated_destinations_spec.rb +++ b/spec/acceptance/rest/admin/api/invoice_terminated_destinations_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Invoice Terminated Destinations' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'invoice-terminated-destinations' } get '/api/rest/admin/invoice-terminated-destinations' do diff --git a/spec/acceptance/rest/admin/api/invoice_terminated_networks_spec.rb b/spec/acceptance/rest/admin/api/invoice_terminated_networks_spec.rb index 2116dcc4a..7545b1b21 100644 --- a/spec/acceptance/rest/admin/api/invoice_terminated_networks_spec.rb +++ b/spec/acceptance/rest/admin/api/invoice_terminated_networks_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Invoice Terminated Networks' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'invoice-terminated-networks' } get '/api/rest/admin/invoice-terminated-networks' do diff --git a/spec/acceptance/rest/admin/api/invoices_spec.rb b/spec/acceptance/rest/admin/api/invoices_spec.rb index 691b45697..e0b27b40f 100644 --- a/spec/acceptance/rest/admin/api/invoices_spec.rb +++ b/spec/acceptance/rest/admin/api/invoices_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Invoices' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'invoices' } get '/api/rest/admin/invoices' do diff --git a/spec/acceptance/rest/admin/api/network_types_spec.rb b/spec/acceptance/rest/admin/api/network_types_spec.rb index 5a347de92..06bfc540c 100644 --- a/spec/acceptance/rest/admin/api/network_types_spec.rb +++ b/spec/acceptance/rest/admin/api/network_types_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'NetworkTypes' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'network-types' } required_params = %i[name] diff --git a/spec/acceptance/rest/admin/api/networks_spec.rb b/spec/acceptance/rest/admin/api/networks_spec.rb index d52659f31..7453bc988 100644 --- a/spec/acceptance/rest/admin/api/networks_spec.rb +++ b/spec/acceptance/rest/admin/api/networks_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Networks' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'networks' } required_params = %i[name] diff --git a/spec/acceptance/rest/admin/api/nodes_spec.rb b/spec/acceptance/rest/admin/api/nodes_spec.rb index 3355df865..237f65c40 100644 --- a/spec/acceptance/rest/admin/api/nodes_spec.rb +++ b/spec/acceptance/rest/admin/api/nodes_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Nodes' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'nodes' } get '/api/rest/admin/nodes' do diff --git a/spec/acceptance/rest/admin/api/payments_spec.rb b/spec/acceptance/rest/admin/api/payments_spec.rb index 8fc729982..9700c2353 100644 --- a/spec/acceptance/rest/admin/api/payments_spec.rb +++ b/spec/acceptance/rest/admin/api/payments_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Payments' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'payments' } get '/api/rest/admin/payments' do diff --git a/spec/acceptance/rest/admin/api/pops_spec.rb b/spec/acceptance/rest/admin/api/pops_spec.rb index 72eabda30..005605187 100644 --- a/spec/acceptance/rest/admin/api/pops_spec.rb +++ b/spec/acceptance/rest/admin/api/pops_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Pops' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'pops' } get '/api/rest/admin/pops' do diff --git a/spec/acceptance/rest/admin/api/rateplans_spec.rb b/spec/acceptance/rest/admin/api/rateplans_spec.rb index c72337f4e..b3b5375b1 100644 --- a/spec/acceptance/rest/admin/api/rateplans_spec.rb +++ b/spec/acceptance/rest/admin/api/rateplans_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Rateplans' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'rateplans' } get '/api/rest/admin/rateplans' do diff --git a/spec/acceptance/rest/admin/api/routeset_discriminators_spec.rb b/spec/acceptance/rest/admin/api/routeset_discriminators_spec.rb index 27ddffbfa..9dde1b41a 100644 --- a/spec/acceptance/rest/admin/api/routeset_discriminators_spec.rb +++ b/spec/acceptance/rest/admin/api/routeset_discriminators_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Routeset discriminators' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'routeset-discriminators' } get '/api/rest/admin/routeset-discriminators' do diff --git a/spec/acceptance/rest/admin/api/routing_groups_spec.rb b/spec/acceptance/rest/admin/api/routing_groups_spec.rb index 5d1ab46f2..67627f9fa 100644 --- a/spec/acceptance/rest/admin/api/routing_groups_spec.rb +++ b/spec/acceptance/rest/admin/api/routing_groups_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Routing groups' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'routing-groups' } get '/api/rest/admin/routing-groups' do diff --git a/spec/acceptance/rest/admin/api/routing_plans_spec.rb b/spec/acceptance/rest/admin/api/routing_plans_spec.rb index 1370d5027..74ac8709c 100644 --- a/spec/acceptance/rest/admin/api/routing_plans_spec.rb +++ b/spec/acceptance/rest/admin/api/routing_plans_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Routing plans' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'routing-plans' } get '/api/rest/admin/routing-plans' do diff --git a/spec/acceptance/rest/admin/api/sdp_c_locations_spec.rb b/spec/acceptance/rest/admin/api/sdp_c_locations_spec.rb index 3ca0a9d55..3dab76d11 100644 --- a/spec/acceptance/rest/admin/api/sdp_c_locations_spec.rb +++ b/spec/acceptance/rest/admin/api/sdp_c_locations_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Sdp c locations' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'sdp-c-locations' } get '/api/rest/admin/sdp-c-locations' do diff --git a/spec/acceptance/rest/admin/api/sensor_levels_spec.rb b/spec/acceptance/rest/admin/api/sensor_levels_spec.rb index 41e2113b7..be205fcae 100644 --- a/spec/acceptance/rest/admin/api/sensor_levels_spec.rb +++ b/spec/acceptance/rest/admin/api/sensor_levels_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Sensor levels' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'sensor-levels' } get '/api/rest/admin/sensor-levels' do diff --git a/spec/acceptance/rest/admin/api/sensors_spec.rb b/spec/acceptance/rest/admin/api/sensors_spec.rb index 3c52c1750..ada4a7093 100644 --- a/spec/acceptance/rest/admin/api/sensors_spec.rb +++ b/spec/acceptance/rest/admin/api/sensors_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Sensors' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'sensors' } required_params = %i[name mode-id target-ip source-ip] diff --git a/spec/acceptance/rest/admin/api/service_types_spec.rb b/spec/acceptance/rest/admin/api/service_types_spec.rb index dc1255e4e..8b88b2c47 100644 --- a/spec/acceptance/rest/admin/api/service_types_spec.rb +++ b/spec/acceptance/rest/admin/api/service_types_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Service Types' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'service-types' } get '/api/rest/admin/service-types' do diff --git a/spec/acceptance/rest/admin/api/services_spec.rb b/spec/acceptance/rest/admin/api/services_spec.rb index 4c30d2273..bc0392c91 100644 --- a/spec/acceptance/rest/admin/api/services_spec.rb +++ b/spec/acceptance/rest/admin/api/services_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Services' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'services' } get '/api/rest/admin/services' do diff --git a/spec/acceptance/rest/admin/api/session_refresh_methods_spec.rb b/spec/acceptance/rest/admin/api/session_refresh_methods_spec.rb index fc90e8ebb..948f99687 100644 --- a/spec/acceptance/rest/admin/api/session_refresh_methods_spec.rb +++ b/spec/acceptance/rest/admin/api/session_refresh_methods_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Session refresh methods' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'session-refresh-methods' } get '/api/rest/admin/session-refresh-methods' do diff --git a/spec/acceptance/rest/admin/api/sip_options_probers_spec.rb b/spec/acceptance/rest/admin/api/sip_options_probers_spec.rb index 6f626a958..63ee5f06e 100644 --- a/spec/acceptance/rest/admin/api/sip_options_probers_spec.rb +++ b/spec/acceptance/rest/admin/api/sip_options_probers_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Sip options prober' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'sip-options-probers' } required_params = %i[name ruri-username ruri-domain] diff --git a/spec/acceptance/rest/admin/api/smtp_connections_spec.rb b/spec/acceptance/rest/admin/api/smtp_connections_spec.rb index 3efa3c999..1d936e598 100644 --- a/spec/acceptance/rest/admin/api/smtp_connections_spec.rb +++ b/spec/acceptance/rest/admin/api/smtp_connections_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Smtp connections' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'smtp-connections' } required_params = %i[name host port from-address] diff --git a/spec/acceptance/rest/admin/api/timezones_spec.rb b/spec/acceptance/rest/admin/api/timezones_spec.rb index 21d5eee6c..a49549f7f 100644 --- a/spec/acceptance/rest/admin/api/timezones_spec.rb +++ b/spec/acceptance/rest/admin/api/timezones_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Timezones' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'timezones' } get '/api/rest/admin/timezones' do diff --git a/spec/acceptance/rest/admin/api/transport_protocols_spec.rb b/spec/acceptance/rest/admin/api/transport_protocols_spec.rb index 82ef808a6..d80af801e 100644 --- a/spec/acceptance/rest/admin/api/transport_protocols_spec.rb +++ b/spec/acceptance/rest/admin/api/transport_protocols_spec.rb @@ -3,12 +3,7 @@ require 'rspec_api_documentation/dsl' RSpec.resource 'Transport protocol' do - header 'Accept', 'application/vnd.api+json' - header 'Content-Type', 'application/vnd.api+json' - header 'Authorization', :auth_token - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } + include_context :acceptance_admin_user let(:type) { 'transport-protocols' } get '/api/rest/admin/transport-protocols' do diff --git a/spec/controllers/api/rest/admin/accounts_controller_spec.rb b/spec/controllers/api/rest/admin/accounts_controller_spec.rb index 11e158353..073fd0897 100755 --- a/spec/controllers/api/rest/admin/accounts_controller_spec.rb +++ b/spec/controllers/api/rest/admin/accounts_controller_spec.rb @@ -1,14 +1,7 @@ # frozen_string_literal: true RSpec.describe Api::Rest::Admin::AccountsController, type: :controller do - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } - - before do - request.accept = 'application/vnd.api+json' - request.headers['Content-Type'] = 'application/vnd.api+json' - request.headers['Authorization'] = auth_token - end + include_context :jsonapi_admin_headers describe 'GET index' do let!(:accounts) { create_list :account, 2 } diff --git a/spec/controllers/api/rest/admin/api_accesses_controller_spec.rb b/spec/controllers/api/rest/admin/api_accesses_controller_spec.rb index 485d9c6f9..806823372 100644 --- a/spec/controllers/api/rest/admin/api_accesses_controller_spec.rb +++ b/spec/controllers/api/rest/admin/api_accesses_controller_spec.rb @@ -1,14 +1,7 @@ # frozen_string_literal: true RSpec.describe Api::Rest::Admin::ApiAccessesController, type: :controller do - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } - - before do - request.accept = 'application/vnd.api+json' - request.headers['Content-Type'] = 'application/vnd.api+json' - request.headers['Authorization'] = auth_token - end + include_context :jsonapi_admin_headers describe 'GET index' do let!(:api_access) { create_list :api_access, 2 } diff --git a/spec/controllers/api/rest/admin/balance_controller_spec.rb b/spec/controllers/api/rest/admin/balance_controller_spec.rb index 8a8b9a5c4..2ebc63fe2 100644 --- a/spec/controllers/api/rest/admin/balance_controller_spec.rb +++ b/spec/controllers/api/rest/admin/balance_controller_spec.rb @@ -1,14 +1,7 @@ # frozen_string_literal: true RSpec.describe Api::Rest::Admin::BalanceController, type: :controller do - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } - - before do - request.accept = 'application/vnd.api+json' - request.headers['Content-Type'] = 'application/vnd.api+json' - request.headers['Authorization'] = auth_token - end + include_context :jsonapi_admin_headers describe 'PUT update', versioning: true do let(:external_id) do diff --git a/spec/controllers/api/rest/admin/codec_groups_controller_spec.rb b/spec/controllers/api/rest/admin/codec_groups_controller_spec.rb index f0fa451ea..36cc2366c 100644 --- a/spec/controllers/api/rest/admin/codec_groups_controller_spec.rb +++ b/spec/controllers/api/rest/admin/codec_groups_controller_spec.rb @@ -1,14 +1,7 @@ # frozen_string_literal: true RSpec.describe Api::Rest::Admin::CodecGroupsController, type: :controller do - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } - - before do - request.accept = 'application/vnd.api+json' - request.headers['Content-Type'] = 'application/vnd.api+json' - request.headers['Authorization'] = auth_token - end + include_context :jsonapi_admin_headers describe 'GET index with ransack filters' do subject do diff --git a/spec/controllers/api/rest/admin/contacts_controller_spec.rb b/spec/controllers/api/rest/admin/contacts_controller_spec.rb index 01bf14c92..b8e32ef1e 100644 --- a/spec/controllers/api/rest/admin/contacts_controller_spec.rb +++ b/spec/controllers/api/rest/admin/contacts_controller_spec.rb @@ -1,14 +1,7 @@ # frozen_string_literal: true RSpec.describe Api::Rest::Admin::ContactsController, type: :controller do - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } - - before do - request.accept = 'application/vnd.api+json' - request.headers['Content-Type'] = 'application/vnd.api+json' - request.headers['Authorization'] = auth_token - end + include_context :jsonapi_admin_headers describe 'GET index with ransack filters' do subject do diff --git a/spec/controllers/api/rest/admin/contractors_controller_spec.rb b/spec/controllers/api/rest/admin/contractors_controller_spec.rb index c30f1fdd9..34ec7bcd8 100755 --- a/spec/controllers/api/rest/admin/contractors_controller_spec.rb +++ b/spec/controllers/api/rest/admin/contractors_controller_spec.rb @@ -1,14 +1,7 @@ # frozen_string_literal: true RSpec.describe Api::Rest::Admin::ContractorsController, type: :controller do - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } - - before do - request.accept = 'application/vnd.api+json' - request.headers['Content-Type'] = 'application/vnd.api+json' - request.headers['Authorization'] = auth_token - end + include_context :jsonapi_admin_headers describe 'GET index' do let!(:contractors) { create_list :contractor, 2, vendor: true } diff --git a/spec/controllers/api/rest/admin/destinations_controller_spec.rb b/spec/controllers/api/rest/admin/destinations_controller_spec.rb index e95af49f6..bb27b3be1 100755 --- a/spec/controllers/api/rest/admin/destinations_controller_spec.rb +++ b/spec/controllers/api/rest/admin/destinations_controller_spec.rb @@ -295,7 +295,7 @@ before { get :show, params: { id: destination.to_param, include: 'country' } } include_examples :responds_with_status, 200 - include_examples :returns_json_api_record, type: 'destinations', relationships: %i[country network] do + include_examples :returns_json_api_record, type: 'destinations', relationships: %i[country network destination-next-rates rate-group routing-tag-mode] do let(:json_api_record_id) { destination.id.to_s } let(:json_api_record_attributes) do hash_including( diff --git a/spec/controllers/api/rest/admin/gateway_groups_controller_spec.rb b/spec/controllers/api/rest/admin/gateway_groups_controller_spec.rb index d2843d3e4..fb1b4199c 100755 --- a/spec/controllers/api/rest/admin/gateway_groups_controller_spec.rb +++ b/spec/controllers/api/rest/admin/gateway_groups_controller_spec.rb @@ -2,15 +2,7 @@ RSpec.describe Api::Rest::Admin::GatewayGroupsController, type: :controller do let(:vendor) { create :contractor, vendor: true } - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } - - before do - request.accept = 'application/vnd.api+json' - request.headers['Content-Type'] = 'application/vnd.api+json' - request.headers['Authorization'] = auth_token - end + include_context :jsonapi_admin_headers describe 'GET index' do let!(:gateway_groups) { create_list :gateway_group, 2 } diff --git a/spec/controllers/api/rest/admin/payments_controller_spec.rb b/spec/controllers/api/rest/admin/payments_controller_spec.rb index abc6f58a2..5b3f315e0 100755 --- a/spec/controllers/api/rest/admin/payments_controller_spec.rb +++ b/spec/controllers/api/rest/admin/payments_controller_spec.rb @@ -1,16 +1,7 @@ # frozen_string_literal: true RSpec.describe Api::Rest::Admin::PaymentsController, type: :controller do - let(:account) { create(:account) } - - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } - - before do - request.accept = 'application/vnd.api+json' - request.headers['Content-Type'] = 'application/vnd.api+json' - request.headers['Authorization'] = auth_token - end + include_context :jsonapi_admin_headers describe 'GET index' do let!(:payments) { create_list :payment, 2 } diff --git a/spec/controllers/api/rest/admin/routing_plans_controller_spec.rb b/spec/controllers/api/rest/admin/routing_plans_controller_spec.rb index c732dc655..d241b0124 100755 --- a/spec/controllers/api/rest/admin/routing_plans_controller_spec.rb +++ b/spec/controllers/api/rest/admin/routing_plans_controller_spec.rb @@ -1,14 +1,7 @@ # frozen_string_literal: true RSpec.describe Api::Rest::Admin::RoutingPlansController, type: :controller do - let(:user) { create :admin_user } - let(:auth_token) { ::Knock::AuthToken.new(payload: { sub: user.id }).token } - - before do - request.accept = 'application/vnd.api+json' - request.headers['Content-Type'] = 'application/vnd.api+json' - request.headers['Authorization'] = auth_token - end + include_context :jsonapi_admin_headers describe 'GET index' do let!(:routing_plans) { create_list :routing_plan, 2 } diff --git a/spec/support/contexts/acceptance/acceptance_admin_user.rb b/spec/support/contexts/acceptance/acceptance_admin_user.rb index 85b873a0a..e026f9b30 100644 --- a/spec/support/contexts/acceptance/acceptance_admin_user.rb +++ b/spec/support/contexts/acceptance/acceptance_admin_user.rb @@ -5,9 +5,9 @@ header 'Content-Type', 'application/vnd.api+json' header 'Authorization', :auth_token - let(:user) { create :admin_user } + let(:admin_user) { create :admin_user } let(:auth_token) do - ::Knock::AuthToken.new(payload: { sub: user.id }).token + Authentication::AdminAuth.build_auth_data(admin_user).token end end diff --git a/spec/support/contexts/json_api/json_api_admin_helpers.rb b/spec/support/contexts/json_api/json_api_admin_helpers.rb index 06bf50a1c..34b15d2fb 100644 --- a/spec/support/contexts/json_api/json_api_admin_helpers.rb +++ b/spec/support/contexts/json_api/json_api_admin_helpers.rb @@ -2,7 +2,7 @@ RSpec.shared_context :json_api_admin_helpers do |type: nil| let(:json_api_resource_type) { type.to_s } - let(:json_api_auth_token) { ::Knock::AuthToken.new(payload: { sub: admin_user.id }).token } + let(:json_api_auth_token) { Authentication::AdminAuth.build_auth_data(admin_user).token } let(:json_api_request_path_prefix) { '/api/rest/admin' } let(:json_api_request_path) { "#{json_api_request_path_prefix}/#{json_api_resource_type}" } let(:json_api_request_headers) do diff --git a/spec/support/contexts/jsonapi_admin_headers.rb b/spec/support/contexts/jsonapi_admin_headers.rb index 5fcdb8383..32ee1f4e4 100644 --- a/spec/support/contexts/jsonapi_admin_headers.rb +++ b/spec/support/contexts/jsonapi_admin_headers.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true RSpec.shared_context :jsonapi_admin_headers do - let(:user) { create :admin_user } + let(:admin_user) { create :admin_user } let(:auth_token) do - ::Knock::AuthToken.new(payload: { sub: user.id }).token + Authentication::AdminAuth.build_auth_data(admin_user).token end before do diff --git a/spec/support/examples/json_api/json_api_admin_check_authorization.rb b/spec/support/examples/json_api/json_api_admin_check_authorization.rb index 57a3d6bd8..9e0cd5389 100644 --- a/spec/support/examples/json_api/json_api_admin_check_authorization.rb +++ b/spec/support/examples/json_api/json_api_admin_check_authorization.rb @@ -17,7 +17,7 @@ context 'with expired auth token' do let(:json_api_auth_token) do - ::Knock::AuthToken.new(payload: { sub: admin_user.id, exp: 1.minute.ago.to_i }).token + Authentication::AdminAuth.build_auth_data(admin_user, expires_at: 1.minute.ago).token end include_examples :responds_with_status, 401, without_body: true @@ -31,7 +31,7 @@ include_examples :responds_with_status, 401, without_body: true end - context 'when admin_user.allowed_ips does not match request.remote_ip' do + context 'when admin_user.allowed_ips matches request.remote_ip' do before do admin_user.update! allowed_ips: ['127.0.0.1'] when_valid_auth