mirror of
https://github.com/CodeforLeipzig/stadtratmonitor.git
synced 2024-12-22 23:53:15 +01:00
commit
568da30c54
7 changed files with 109 additions and 2 deletions
|
@ -1,9 +1,13 @@
|
||||||
FROM ruby:2.2
|
FROM ruby:2.2
|
||||||
RUN apt-get update && apt-get install -y build-essential zlib1g-dev libsqlite3-dev nodejs nodejs-legacy
|
RUN apt-get update && apt-get install -y build-essential zlib1g-dev libsqlite3-dev nodejs nodejs-legacy npm
|
||||||
|
|
||||||
|
RUN npm install phantomjs-prebuilt
|
||||||
|
RUN ln -sf /node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /usr/local/bin/
|
||||||
|
|
||||||
RUN mkdir -p /app
|
RUN mkdir -p /app
|
||||||
|
|
||||||
WORKDIR /tmp
|
WORKDIR /tmp
|
||||||
|
|
||||||
COPY Gemfile Gemfile
|
COPY Gemfile Gemfile
|
||||||
COPY Gemfile.lock Gemfile.lock
|
COPY Gemfile.lock Gemfile.lock
|
||||||
RUN bundle install
|
RUN bundle install
|
||||||
|
|
1
Gemfile
1
Gemfile
|
@ -64,6 +64,7 @@ group :test do
|
||||||
gem 'test_after_commit' # TODO remove when moving to rails 5
|
gem 'test_after_commit' # TODO remove when moving to rails 5
|
||||||
gem 'database_cleaner'
|
gem 'database_cleaner'
|
||||||
gem 'coveralls', require: false
|
gem 'coveralls', require: false
|
||||||
|
gem 'poltergeist'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Use ActiveModel has_secure_password
|
# Use ActiveModel has_secure_password
|
||||||
|
|
10
Gemfile.lock
10
Gemfile.lock
|
@ -46,6 +46,7 @@ GEM
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
rack-test (>= 0.5.4)
|
rack-test (>= 0.5.4)
|
||||||
xpath (~> 2.0)
|
xpath (~> 2.0)
|
||||||
|
cliver (0.3.2)
|
||||||
coderay (1.1.0)
|
coderay (1.1.0)
|
||||||
coffee-rails (4.1.0)
|
coffee-rails (4.1.0)
|
||||||
coffee-script (>= 2.2.0)
|
coffee-script (>= 2.2.0)
|
||||||
|
@ -153,6 +154,11 @@ GEM
|
||||||
faraday
|
faraday
|
||||||
multi_json
|
multi_json
|
||||||
omniauth (~> 1.0)
|
omniauth (~> 1.0)
|
||||||
|
poltergeist (1.9.0)
|
||||||
|
capybara (~> 2.1)
|
||||||
|
cliver (~> 0.3.1)
|
||||||
|
multi_json (~> 1.0)
|
||||||
|
websocket-driver (>= 0.2.0)
|
||||||
pry (0.10.1)
|
pry (0.10.1)
|
||||||
coderay (~> 1.1.0)
|
coderay (~> 1.1.0)
|
||||||
method_source (~> 0.8.1)
|
method_source (~> 0.8.1)
|
||||||
|
@ -283,6 +289,9 @@ GEM
|
||||||
validate_url (1.0.2)
|
validate_url (1.0.2)
|
||||||
activemodel (>= 3.0.0)
|
activemodel (>= 3.0.0)
|
||||||
addressable
|
addressable
|
||||||
|
websocket-driver (0.6.3)
|
||||||
|
websocket-extensions (>= 0.1.0)
|
||||||
|
websocket-extensions (0.1.2)
|
||||||
win32console (1.3.2)
|
win32console (1.3.2)
|
||||||
xpath (2.0.0)
|
xpath (2.0.0)
|
||||||
nokogiri (~> 1.3)
|
nokogiri (~> 1.3)
|
||||||
|
@ -310,6 +319,7 @@ DEPENDENCIES
|
||||||
launchy
|
launchy
|
||||||
omniauth
|
omniauth
|
||||||
omniauth-browserid
|
omniauth-browserid
|
||||||
|
poltergeist
|
||||||
pry
|
pry
|
||||||
pry-rails
|
pry-rails
|
||||||
quiet_assets
|
quiet_assets
|
||||||
|
|
|
@ -8,7 +8,7 @@ div
|
||||||
.right
|
.right
|
||||||
/ button.button. TODO: Suche Abbonieren
|
/ button.button. TODO: Suche Abbonieren
|
||||||
- else
|
- else
|
||||||
| #{@papers.total} Dokumente in der Datenbank
|
| #{pluralize(@papers.total, "Dokument", "Dokumente")} in der Datenbank
|
||||||
div
|
div
|
||||||
ul.no-bullet#search_results
|
ul.no-bullet#search_results
|
||||||
- @papers.each do |doc|
|
- @papers.each do |doc|
|
||||||
|
|
|
@ -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))
|
expect(result).to have_css("span.published", text: I18n.l(paper.published_at.to_date))
|
||||||
end
|
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
|
end
|
||||||
|
|
69
spec/features/search_filters_spec.rb
Normal file
69
spec/features/search_filters_spec.rb
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
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",
|
||||||
|
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
|
||||||
|
|
||||||
|
scenario "Displays paper types and their respective count witin the search results" do
|
||||||
|
visit search_path body: "leipzig"
|
||||||
|
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, 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
|
2
spec/support/capybara.rb
Normal file
2
spec/support/capybara.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
require 'capybara/poltergeist'
|
||||||
|
Capybara.javascript_driver = :poltergeist
|
Loading…
Reference in a new issue