Maintenance: Improve translation search collector to handle nil descriptions

Approved-by: Florian Liebe <fl@zammad.com>
This commit is contained in:
Rene Reimann
2026-08-07 12:05:22 +02:00
parent fe9f337e76
commit d3e3d47fcb
2 changed files with 12 additions and 1 deletions

View File

@@ -20,6 +20,6 @@ class Service::Translation::Search::Collector::PublicLink < Service::Translation
end
def link_descriptions
public_links.pluck(:description)
public_links.pluck(:description).compact
end
end

View File

@@ -85,6 +85,17 @@ RSpec.describe Service::Translation::Search do
context 'with description attribute' do
it_behaves_like 'returns filtered result', :public_link, 'description', 2
end
context 'with nil description on a public link' do
before do
create(:public_link, description: nil)
create(:public_link, description: "desc #{query}")
end
it 'does not crash on nil descriptions' do
expect { service_result }.not_to raise_error
end
end
end
context 'with custom object attribute' do