Commit 30053faa authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'peterhegman/group-link-route-allow-placeholder' into 'master'

Allow placeholder `:id` for group link route

See merge request gitlab-org/gitlab!44346
parents 552786bc e684c697
...@@ -87,7 +87,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do ...@@ -87,7 +87,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
delete :leave, on: :collection delete :leave, on: :collection
end end
resources :group_links, only: [:create, :update, :destroy], constraints: { id: /\d+/ } resources :group_links, only: [:create, :update, :destroy], constraints: { id: /\d+|:id/ }
resources :uploads, only: [:create] do resources :uploads, only: [:create] do
collection do collection do
......
...@@ -15,6 +15,21 @@ RSpec.describe Groups::GroupLinksController do ...@@ -15,6 +15,21 @@ RSpec.describe Groups::GroupLinksController do
shared_with_group.add_developer(group_member) shared_with_group.add_developer(group_member)
end end
shared_examples 'placeholder is passed as `id` parameter' do |action|
it 'returns a 404' do
post(
action,
params: {
group_id: shared_group,
id: ':id'
},
format: :json
)
expect(response).to have_gitlab_http_status(:not_found)
end
end
describe '#create' do describe '#create' do
let(:shared_with_group_id) { shared_with_group.id } let(:shared_with_group_id) { shared_with_group.id }
let(:shared_group_access) { GroupGroupLink.default_access } let(:shared_group_access) { GroupGroupLink.default_access }
...@@ -125,6 +140,8 @@ RSpec.describe Groups::GroupLinksController do ...@@ -125,6 +140,8 @@ RSpec.describe Groups::GroupLinksController do
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
include_examples 'placeholder is passed as `id` parameter', :create
end end
describe '#update' do describe '#update' do
...@@ -197,6 +214,8 @@ RSpec.describe Groups::GroupLinksController do ...@@ -197,6 +214,8 @@ RSpec.describe Groups::GroupLinksController do
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
include_examples 'placeholder is passed as `id` parameter', :update
end end
describe '#destroy' do describe '#destroy' do
...@@ -232,5 +251,7 @@ RSpec.describe Groups::GroupLinksController do ...@@ -232,5 +251,7 @@ RSpec.describe Groups::GroupLinksController do
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
include_examples 'placeholder is passed as `id` parameter', :destroy
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