Skip to content

API for outing_plan_static_routes - #2075

Merged
dmitry-sinina merged 3 commits into
yeti-switch:masterfrom
dmitry-sinina:routing_plan_static_route_api
Aug 8, 2026
Merged

API for outing_plan_static_routes#2075
dmitry-sinina merged 3 commits into
yeti-switch:masterfrom
dmitry-sinina:routing_plan_static_route_api

Conversation

@dmitry-sinina

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI lite review requested due to automatic review settings August 6, 2026 21:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_routes JSON:API resource/controller/routes plus comprehensive request + acceptance specs.
  • Extends RoutingPlan JSON:API resource to expose static_routes relationship and tests include=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.

Comment on lines +88 to +93
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
Comment on lines +15 to +20
# 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
Comment thread app/admin/system/api_accesses.rb Outdated
Comment on lines +83 to +84
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: '' })
Comment thread app/admin/equipment/gateways.rb Outdated
Comment on lines +405 to +406
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: '' })

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Latin C, 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 Latin C, 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 is routing-plans (for example, customers_auths_spec.rb:60 uses 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_id filter 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

@dmitry-sinina
dmitry-sinina merged commit c5f0f5e into yeti-switch:master Aug 8, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants