Add feature spec for originator filter

This commit is contained in:
Lars Henrik Mai 2016-03-13 10:30:06 +01:00
parent bc9b1c733b
commit d2da4bece9

View file

@ -3,10 +3,25 @@ require 'rails_helper'
RSpec.feature "Search filters", type: :feature, elasticsearch: true do
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")
@antrag = FactoryGirl.create(:paper,
paper_type: "Antrag",
name: "Mehr Spielplätze in Leipzig",
originator: "Dezernat Jugend, Soziales, Gesundheit und Schule"
)
@anfrage = FactoryGirl.create(:paper,
paper_type: "Anfrage",
originator: "CDU-Fraktion"
)
@vorlage_1 = FactoryGirl.create(:paper,
paper_type: "Vorlage",
name: "Zustand der Spielplätze",
originator: "Dezernat Jugend, Soziales, Gesundheit und Schule"
)
@vorlage_2 = FactoryGirl.create(:paper,
paper_type: "Vorlage",
name: "Mehr Ampeln in der Innenstadt",
originator: "Oberbürgermeister"
)
Paper.__elasticsearch__.refresh_index!
end
@ -31,4 +46,24 @@ RSpec.feature "Search filters", type: :feature, elasticsearch: true do
expect(page).to have_css("li.search-result", count: 1, text: "Spielplätze")
end
scenario "Displays originators and their respective count within the search results" do
visit search_path body: "leipzig"
originator_filter = page.find("select#paper_search_originator")
expect(originator_filter).to have_css("option", text: "CDU-Fraktion (1)")
expect(originator_filter).to have_css("option", text: "Dezernat Jugend, Soziales, Gesundheit und Schule (2)")
expect(originator_filter).to have_css("option", text: "Oberbürgermeister (1)")
visit search_path body: "leipzig", paper_search: {query: "Spielplätze"}
originator_filter = page.find("select#paper_search_originator")
expect(originator_filter).to have_css("option", text: "Dezernat Jugend, Soziales, Gesundheit und Schule (2)")
expect(originator_filter).not_to have_css("option", text: "Oberbürgermeister")
end
scenario "Filtering by originator", js: true do
visit search_path body: "leipzig"
expect(page).to have_css("li.search-result", count: 4)
select "Oberbürgermeister (1)", from: "Einreicher"
expect(page).to have_css("li.search-result", count: 1, text: "Ampeln")
end
end