Commit 217408c3 authored by Sashi's avatar Sashi

Add constraint to id param for NetworkPoliciesController

This change fixes the bug while trying to update
Cilium policies. The reason for the bug was that rails does not
accept dots in routes by default for id params.
Changelog: fixed
EE: true
parent 08d0566f
......@@ -53,7 +53,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :audit_events, only: [:index]
namespace :security do
resources :network_policies, only: [:index, :create, :update, :destroy] do
resources :network_policies, only: [:index, :create, :update, :destroy], constraints: { id: %r{[^/]+} } do
get :summary, on: :collection
end
......
......@@ -82,4 +82,16 @@ RSpec.describe 'EE-specific project routing' do
end
end
end
describe Projects::Security::NetworkPoliciesController, 'routing' do
where(:id) do
%w[test.1.2 test-policy test:policy]
end
with_them do
it "to #update" do
expect(put("/gitlab/gitlabhq/-/security/network_policies/#{id}")).to route_to('projects/security/network_policies#update', namespace_id: 'gitlab', project_id: 'gitlabhq', id: id)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment