Skip to content

A platform for community discussion. Free, open, simple.

DEV: Pass a list of tag group names when using the search endpoint. (#12721)

Roman Rizzifd8441d6d5b8
diff --git a/app/controllers/tag_groups_controller.rb b/app/controllers/tag_groups_controller.rb
index 5419779c25d..76cecc02fad 100644
--- a/app/controllers/tag_groups_controller.rb
+++ b/app/controllers/tag_groups_controller.rb
@@ -67,8 +67,8 @@ class TagGroupsController < ApplicationController
matches = matches.where('lower(name) ILIKE ?', "%#{params[:q].strip}%")
end
- if params[:ids].present?
- matches = matches.where(id: params[:ids])
+ if params[:names].present?
+ matches = matches.where(name: params[:names].map(&:downcase))
end
matches = matches.order('name').limit(params[:limit] || 5)
diff --git a/spec/requests/tag_groups_controller_spec.rb b/spec/requests/tag_groups_controller_spec.rb
index 045906a9b53..6fcbf9a2b02 100644
--- a/spec/requests/tag_groups_controller_spec.rb
+++ b/spec/requests/tag_groups_controller_spec.rb
@@ -83,7 +83,7 @@ RSpec.describe TagGroupsController do
it 'returns the tag group with the associated tag names' do
tag_group = tag_group_with_permission(everyone, readonly)
- get '/tag_groups/filter/search.json', params: { ids: [tag_group.id] }
+ get '/tag_groups/filter/search.json', params: { names: [tag_group.name] }
expect(response.status).to eq(200)
results = JSON.parse(response.body, symbolize_names: true).fetch(:results)
@@ -95,7 +95,7 @@ RSpec.describe TagGroupsController do
it 'returns an empty array if the tag group is private' do
tag_group = tag_group_with_permission(staff, full)
- get '/tag_groups/filter/search.json', params: { ids: [tag_group.id] }
+ get '/tag_groups/filter/search.json', params: { names: [tag_group.name] }
expect(response.status).to eq(200)
results = JSON.parse(response.body, symbolize_names: true).fetch(:results)