Fix search_by_title_or_id method

Results were not including records without translations for current
locale (I18n.locale). Now we search for given title against all
translation fallbacks for current locale.
This commit is contained in:
Senén Rodero Rodríguez
2019-02-18 16:51:22 +01:00
committed by voodoorai2000
parent 66f885f8e4
commit bb2ee6dd3c
3 changed files with 44 additions and 13 deletions

View File

@@ -826,33 +826,43 @@ describe "Admin budget investments" do
end
before do
create(:budget_investment, title: "Some investment", budget: budget)
I18n.with_locale(:es) do
Globalize.with_locale(:es) do
create(:budget_investment, title: "Proyecto de inversión", budget: budget)
end
end
end
scenario "Search investments by title" do
visit admin_budget_budget_investments_path(budget)
expect(page).to have_content("Some investment")
expect(page).to have_content("Proyecto de inversión")
expect(page).to have_content("Some other investment")
fill_in "title_or_id", with: "Some investment"
fill_in "title_or_id", with: "Proyecto de inversión"
click_button "Filter"
expect(page).to have_content("Some investment")
expect(page).to have_content("Proyecto de inversión")
expect(page).not_to have_content("Some other investment")
fill_in "title_or_id", with: "Some other investment"
click_button "Filter"
expect(page).not_to have_content("Proyecto de inversión")
expect(page).to have_content("Some other investment")
end
scenario "Search investments by ID" do
visit admin_budget_budget_investments_path(budget)
expect(page).to have_content("Some investment")
expect(page).to have_content("Proyecto de inversión")
expect(page).to have_content("Some other investment")
fill_in "title_or_id", with: first_investment.id
click_button "Filter"
expect(page).to have_content("Some other investment")
expect(page).not_to have_content("Some investment")
expect(page).not_to have_content("Proyecto de inversión")
end
end