Maintenance: Improve translation search collector to handle nil descriptions
Approved-by: Florian Liebe <fl@zammad.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user