Add feature specs for simple search queries

This commit is contained in:
Lars Henrik Mai 2016-03-05 12:40:35 +01:00
parent 1bbcbdc94e
commit 0d09ebaad3
2 changed files with 22 additions and 1 deletions

View file

@ -8,7 +8,7 @@ div
.right
/ button.button. TODO: Suche Abbonieren
- else
| #{@papers.total} Dokumente in der Datenbank
| #{pluralize(@papers.total, "Dokument", "Dokumente")} in der Datenbank
div
ul.no-bullet#search_results
- @papers.each do |doc|

View file

@ -53,4 +53,25 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
expect(result).to have_css("span.published", text: I18n.l(paper.published_at.to_date))
end
scenario "Finds papers by name" do
paper = FactoryGirl.create(:paper, name: "Opendata als default")
Paper.__elasticsearch__.refresh_index!
visit search_path body: "leipzig", paper_search: {query: "Opendata"}
expect(page).to have_content("1 Dokument in der Datenbank")
result = page.find("li.search-result", match: :first)
expect(result).to have_link(paper.name, href: paper.url)
end
scenario "Finds papers by content" do
paper = FactoryGirl.create(:paper,
name: "Opendata als default",
content: "Alle Verwaltungsdokumente werden als Opendata veröffentlicht"
)
Paper.__elasticsearch__.refresh_index!
visit search_path body: "leipzig", paper_search: {query: "Verwaltungsdokumente"}
expect(page).to have_content("1 Dokument in der Datenbank")
result = page.find("li.search-result", match: :first)
expect(result).to have_link(paper.name, href: paper.url)
end
end