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 RSpec.feature "Search filters", type: :feature, elasticsearch: true do
before(:each) do before(:each) do
@antrag = FactoryGirl.create(:paper, paper_type: "Antrag", name: "Mehr Spielplätze in Leipzig") @antrag = FactoryGirl.create(:paper,
@anfrage = FactoryGirl.create(:paper, paper_type: "Anfrage") paper_type: "Antrag",
@vorlage_1 = FactoryGirl.create(:paper, paper_type: "Vorlage", name: "Zustand der Spielplätze") name: "Mehr Spielplätze in Leipzig",
@vorlage_2 = FactoryGirl.create(:paper, paper_type: "Vorlage", name: "Mehr Ampeln in der Innenstadt") 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! Paper.__elasticsearch__.refresh_index!
end 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") expect(page).to have_css("li.search-result", count: 1, text: "Spielplätze")
end 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 end