Expand search filter spec to test type filter for aggregation counts

This commit is contained in:
Lars Henrik Mai 2016-03-10 08:57:15 +01:00
parent 871c05dc11
commit bc9b1c733b

View file

@ -2,17 +2,33 @@ require 'rails_helper'
RSpec.feature "Search filters", type: :feature, elasticsearch: true do
scenario "Filtering by paper type", js: true do
paper_types = %w(Antrag Anfrage Beschlussvorlage)
papers = paper_types.map do |t|
FactoryGirl.create(:paper, paper_type: t)
end
before(:each) do
@antrag = FactoryGirl.create(:paper, paper_type: "Antrag", name: "Mehr Spielplätze in Leipzig")
@anfrage = FactoryGirl.create(:paper, paper_type: "Anfrage")
@vorlage_1 = FactoryGirl.create(:paper, paper_type: "Vorlage", name: "Zustand der Spielplätze")
@vorlage_2 = FactoryGirl.create(:paper, paper_type: "Vorlage", name: "Mehr Ampeln in der Innenstadt")
Paper.__elasticsearch__.refresh_index!
end
scenario "Displays paper types and their respective count witin the search results" do
visit search_path body: "leipzig"
expect(page).to have_css("li.search-result", count: 3)
paper_type_filter = page.find("select#paper_search_paper_type")
expect(paper_type_filter).to have_css("option", text: "Antrag (1)")
expect(paper_type_filter).to have_css("option", text: "Anfrage (1)")
expect(paper_type_filter).to have_css("option", text: "Vorlage (2)")
visit search_path body: "leipzig", paper_search: {query: "Spielplätze"}
paper_type_filter = page.find("select#paper_search_paper_type")
expect(paper_type_filter).to have_css("option", text: "Antrag (1)")
expect(paper_type_filter).not_to have_css("option", text: "Anfrage")
expect(paper_type_filter).to have_css("option", text: "Vorlage (1)")
end
scenario "Filtering by paper type", js: true do
visit search_path body: "leipzig"
expect(page).to have_css("li.search-result", count: 4)
select "Antrag (1)", from: "Typ"
expect(page).to have_css("li.search-result", count: 1)
expect(page).to have_css("li.search-result", count: 1, text: "Spielplätze")
end
end