API for outing_plan_static_routes - #2075
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds Admin REST JSON:API support for Routing Plan Static Routes and updates admin credential generation to be CSP-friendly (removes inline onclick JavaScript).
Changes:
- Adds
routing_plan_static_routesJSON:API resource/controller/routes plus comprehensive request + acceptance specs. - Extends RoutingPlan JSON:API resource to expose
static_routesrelationship and testsinclude=static-routes. - Reworks credential generator to use delegated click handlers via
data-*attributes (no inline JS).
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/requests/api/rest/admin/routing_plans_spec.rb | Adds GET-by-id coverage for include=static-routes on routing plans |
| spec/requests/api/rest/admin/routing_plan_static_routes_spec.rb | Adds request specs for CRUD, filters, validation, and relationship behavior |
| spec/acceptance/rest/admin/api/routing_plan_static_routes_spec.rb | Adds API documentation acceptance specs for the new endpoints |
| config/routes.rb | Exposes routing_plan_static_routes routes under admin REST API |
| app/resources/api/rest/admin/routing_plan_static_route_resource.rb | Introduces JSON:API resource definition, fields, relationships, and filters |
| app/resources/api/rest/admin/routing_plan_resource.rb | Exposes static_routes relationship from routing plans |
| app/controllers/api/rest/admin/routing_plan_static_routes_controller.rb | Adds controller for the new resource |
| app/assets/javascripts/credential_generator.js | Implements delegated handler for credential generation (CSP compliant) |
| app/admin/system/api_accesses.rb | Replaces inline onclick with data-generate-credential |
| app/admin/equipment/gateways.rb | Replaces inline onclick with data-generate-credential |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let(:json_api_request_relationships) do | ||
| { | ||
| 'routing-plan': { data: { id: routing_plan.id.to_s, type: 'routing_plans' } }, | ||
| 'vendor': { data: { id: vendor.id.to_s, type: 'contractors' } } | ||
| } | ||
| end |
| end | ||
| end | ||
|
|
||
| put '/api/rest/admin/routing-plan-static-routes/:id' do |
| # read-only: routing_plan_id is NOT NULL, so static routes can only be | ||
| # (re)assigned from the routing-plan-static-routes endpoint | ||
| has_many :static_routes, class_name: 'RoutingPlanStaticRoute', | ||
| exclude_links: %i[default self], | ||
| relation_name: :static_routes, | ||
| foreign_key_on: :related |
| f.input :login, hint: link_to('Сlick to fill random login', '#', data: { generate_credential: '' }) | ||
| f.input :password, as: :string, hint: link_to('Сlick to fill random password', '#', data: { generate_credential: '' }) |
| f.input :incoming_auth_username, hint: "#{link_to('Сlick to fill random username', '#', data: { generate_credential: '' })}. #{t('formtastic.hints.gateway.incoming_auth_username')}".html_safe | ||
| f.input :incoming_auth_password, as: :string, input_html: { autocomplete: 'off' }, hint: link_to('Сlick to fill random password', '#', data: { generate_credential: '' }) |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.
Suppressed comments (4)
app/admin/system/api_accesses.rb:84
- Both user-facing labels start with Cyrillic
Сrather than LatinC, which makes “Click” incorrectly encoded for search, copy, and accessibility tooling.
f.input :login, hint: link_to('Сlick to fill random login', '#', data: { generate_credential: '' })
f.input :password, as: :string, hint: link_to('Сlick to fill random password', '#', data: { generate_credential: '' })
app/admin/equipment/gateways.rb:406
- Both user-facing labels start with Cyrillic
Сrather than LatinC, which makes “Click” incorrectly encoded for search, copy, and accessibility tooling.
f.input :incoming_auth_username, hint: "#{link_to('Сlick to fill random username', '#', data: { generate_credential: '' })}. #{t('formtastic.hints.gateway.incoming_auth_username')}".html_safe
f.input :incoming_auth_password, as: :string, input_html: { autocomplete: 'off' }, hint: link_to('Сlick to fill random password', '#', data: { generate_credential: '' })
spec/acceptance/rest/admin/api/routing_plan_static_routes_spec.rb:40
- The generated JSON:API example identifies the related resource as
routing_plans, but its public type isrouting-plans(for example,customers_auths_spec.rb:60uses that type). This would publish a noncanonical relationship payload in the API documentation.
let(:'routing-plan') { wrap_relationship(:routing_plans, create(:routing_plan, :with_static_routes).id) }
app/resources/api/rest/admin/routing_plan_static_route_resource.rb:19
- The new
network_prefix_idfilter has no request-level behavior test, while every other filter declared by this resource is exercised in the new request spec. Add the corresponding foreign-key/number filter example so this API behavior is covered.
ransack_filter :network_prefix_id, type: :number
No description provided.