Add translations to budget investments pg_search_scope
Some Budget::Investment attributes are now translatable so we need to include all existing translations on pg_search model scope.
This commit is contained in:
committed by
voodoorai2000
parent
9a459070e9
commit
e8f53cb8b7
@@ -198,12 +198,10 @@ class Budget
|
||||
end
|
||||
|
||||
def searchable_values
|
||||
{ title => "A",
|
||||
author.username => "B",
|
||||
{ author.username => "B",
|
||||
heading.name => "B",
|
||||
tag_list.join(" ") => "B",
|
||||
description => "C"
|
||||
}
|
||||
tag_list.join(" ") => "B"
|
||||
}.merge(searchable_globalized_values)
|
||||
end
|
||||
|
||||
def self.search(terms)
|
||||
@@ -419,5 +417,10 @@ class Budget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def searchable_translations_definitions
|
||||
{ title => "A",
|
||||
description => "D" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -683,12 +683,23 @@ describe Budget::Investment do
|
||||
|
||||
context "attributes" do
|
||||
|
||||
let(:attributes) { { title: "save the world",
|
||||
description: "in order to save the world one must think about...",
|
||||
title_es: "para salvar el mundo uno debe pensar en...",
|
||||
description_es: "uno debe pensar" } }
|
||||
|
||||
it "searches by title" do
|
||||
budget_investment = create(:budget_investment, title: "save the world")
|
||||
budget_investment = create(:budget_investment, attributes)
|
||||
results = described_class.search("save the world")
|
||||
expect(results).to eq([budget_investment])
|
||||
end
|
||||
|
||||
it "searches by title across all languages" do
|
||||
budget_investment = create(:budget_investment, attributes)
|
||||
results = described_class.search("salvar el mundo")
|
||||
expect(results).to eq([budget_investment])
|
||||
end
|
||||
|
||||
it "searches by author name" do
|
||||
author = create(:user, username: "Danny Trejo")
|
||||
budget_investment = create(:budget_investment, author: author)
|
||||
|
||||
Reference in New Issue
Block a user