From 739e666f7b6a018f7141416b5497f31eeb7ef304 Mon Sep 17 00:00:00 2001 From: Joerg Reichert Date: Thu, 5 Jan 2017 22:14:07 +0100 Subject: [PATCH] 28 - cover stemming and compound feature with tests --- spec/features/basic_search_spec.rb | 81 ++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/spec/features/basic_search_spec.rb b/spec/features/basic_search_spec.rb index a78aba2..52331cd 100644 --- a/spec/features/basic_search_spec.rb +++ b/spec/features/basic_search_spec.rb @@ -129,4 +129,85 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do linkName2 = getLinkName(newPaper2) expect(resultSubEntries[1]).to have_link(linkName2, href: newPaper2.url) end + + scenario "Papers with common reference id handled also for missing prefix" do + mainPaper = FactoryGirl.create(:paper, published_at: '2016-12-19T19:00:00', + name: "Opendata als default", reference: "VI-0815") + newPaper1 = FactoryGirl.create(:paper, published_at: '2016-12-23T12:00:00', + name: "Opendata als optional", reference: "VI-0815-NF-01") + newPaper1Change = FactoryGirl.create(:paper, published_at: '2016-12-23T12:00:00', + name: "Opendata als nicht optional", reference: "-0815-NF-01-ÄA-01") + Paper.__elasticsearch__.refresh_index! + visit search_path body: "leipzig", paper_search: {query: "default"} + expect(page).to have_content("1 Dokument in der Datenbank") + resultEntry = page.find("li.search-result", match: :first) + + resultSubEntries = resultEntry.find("ul").all("li") + linkName1 = getLinkName(newPaper1) + expect(resultSubEntries[2]).to have_link(linkName1, href: newPaper1.url) + linkName2 = getLinkName(newPaper1Change) + expect(resultSubEntries[1]).to have_link(linkName2, href: newPaper1Change.url) + end + + scenario "Finds 'Testen' with search 'Test'" do + paper = FactoryGirl.create(:paper, name: "Testen") + Paper.__elasticsearch__.refresh_index! + visit search_path body: "leipzig", paper_search: {query: "Test"} + expect(page).to have_content("1 Dokument in der Datenbank") + resultEntry = page.find("li.search-result", match: :first) + expect(resultEntry).to have_content(paper.name) + end + + scenario "Finds 'Test' with search 'Testen'" do + paper = FactoryGirl.create(:paper, name: "Test") + Paper.__elasticsearch__.refresh_index! + visit search_path body: "leipzig", paper_search: {query: "Testen"} + expect(page).to have_content("1 Dokument in der Datenbank") + resultEntry = page.find("li.search-result", match: :first) + expect(resultEntry).to have_content(paper.name) + end + + scenario "Finds 'Fahrräderverleih' with search 'Fahrrad'" do + paper = FactoryGirl.create(:paper, name: "Fahrräderverleih") + Paper.__elasticsearch__.refresh_index! + visit search_path body: "leipzig", paper_search: {query: "Fahrrad"} + expect(page).to have_content("1 Dokument in der Datenbank") + resultEntry = page.find("li.search-result", match: :first) + expect(resultEntry).to have_content(paper.name) + end + + scenario "Finds 'Fahrräderverleih' with search 'Fahrräder'" do + paper = FactoryGirl.create(:paper, name: "Fahrräderverleih") + Paper.__elasticsearch__.refresh_index! + visit search_path body: "leipzig", paper_search: {query: "Fahrräder"} + expect(page).to have_content("1 Dokument in der Datenbank") + resultEntry = page.find("li.search-result", match: :first) + expect(resultEntry).to have_content(paper.name) + end + + scenario "Finds 'Fahrräderverleih' with search 'Verleih'" do + paper = FactoryGirl.create(:paper, name: "Fahrräderverleih") + Paper.__elasticsearch__.refresh_index! + visit search_path body: "leipzig", paper_search: {query: "Verleih"} + expect(page).to have_content("1 Dokument in der Datenbank") + resultEntry = page.find("li.search-result", match: :first) + expect(resultEntry).to have_content(paper.name) + end + + scenario "Finds 'Fahrräderverleih' with search 'Autoverleih'" do + paper = FactoryGirl.create(:paper, name: "Fahrräderverleih") + Paper.__elasticsearch__.refresh_index! + visit search_path body: "leipzig", paper_search: {query: "Autoverleih"} + expect(page).to have_content("1 Dokument in der Datenbank") + resultEntry = page.find("li.search-result", match: :first) + expect(resultEntry).to have_content(paper.name) + end + + scenario "Finds no 'Fahrrad' with search 'Rad'" do + paper = FactoryGirl.create(:paper, name: "Fahrrad") + Paper.__elasticsearch__.refresh_index! + visit search_path body: "leipzig", paper_search: {query: "Rad"} + expect(page).to have_content("0 Dokumente in der Datenbank") + end + end