Migration to Ruby 2.5, Rails 5.1.5, Elasticsearch 5.4.3

This commit is contained in:
Joerg Reichert 2018-03-18 21:21:59 +01:00
parent 85d2ad5d57
commit ad77627973
17 changed files with 180 additions and 170 deletions

View file

@ -1 +1 @@
2.1.5 2.5.0

View file

@ -1,8 +1,8 @@
FROM ruby:2.2 FROM ruby:2.5
RUN apt-get update && \ RUN curl -sL https://deb.nodesource.com/setup_9.x | bash - && apt-get update && \
apt-get install -y build-essential zlib1g-dev libsqlite3-dev nodejs nodejs-legacy npm \ apt-get install -y build-essential zlib1g-dev libsqlite3-dev nodejs npm \
libxml2-dev libxslt1-dev pkg-config \ libxml2-dev libxslt1-dev pkg-config \
libqt4-webkit libqt4-dev xvfb libqtwebkit4 libqtwebkit-dev libqt4-dev xvfb
RUN mkdir -p /app RUN mkdir -p /app

12
Gemfile
View file

@ -2,7 +2,7 @@ source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails' gem 'rails', '~> 5.1.5'
gem 'rails-i18n' gem 'rails-i18n'
# Use sqlite3 as the database for Active Record # Use sqlite3 as the database for Active Record
gem 'sqlite3' gem 'sqlite3'
@ -30,8 +30,9 @@ gem 'validate_url'
gem 'omniauth' gem 'omniauth'
gem 'omniauth-browserid' gem 'omniauth-browserid'
gem 'elasticsearch' gem 'elasticsearch', '~> 6'
gem 'elasticsearch-model' gem 'elasticsearch-model'
gem 'elasticsearch-rails'
gem 'elasticsearch-dsl' gem 'elasticsearch-dsl'
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw] gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
@ -42,7 +43,8 @@ gem 'sdoc', '~> 0.4.0', group: :doc
group :development do group :development do
gem 'spring' gem 'spring'
gem 'spring-commands-rspec' gem 'spring-commands-rspec'
gem 'quiet_assets' # https://rossta.net/blog/quiet-assets-in-rails-5.html
# gem 'quiet_assets'
gem 'awesome_print' gem 'awesome_print'
# gem 'guard-rspec', require: false # gem 'guard-rspec', require: false
# gem 'terminal-notifier-guard' # FIXME cross-platform # gem 'terminal-notifier-guard' # FIXME cross-platform
@ -57,14 +59,14 @@ group :development, :test do
end end
group :test do group :test do
gem 'factory_girl_rails' gem "factory_bot_rails"
gem 'shoulda-matchers', '~> 3.1' gem 'shoulda-matchers', '~> 3.1'
gem 'faker' gem 'faker'
gem 'simplecov', require: false gem 'simplecov', require: false
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 'capybara-webkit' gem 'capybara-webkit'
gem 'rails-controller-testing'
end end
# Use ActiveModel has_secure_password # Use ActiveModel has_secure_password

View file

@ -1,54 +1,57 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actionmailer (4.2.10) actioncable (5.1.5)
actionpack (= 4.2.10) actionpack (= 5.1.5)
actionview (= 4.2.10) nio4r (~> 2.0)
activejob (= 4.2.10) websocket-driver (~> 0.6.1)
actionmailer (5.1.5)
actionpack (= 5.1.5)
actionview (= 5.1.5)
activejob (= 5.1.5)
mail (~> 2.5, >= 2.5.4) mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5) rails-dom-testing (~> 2.0)
actionpack (4.2.10) actionpack (5.1.5)
actionview (= 4.2.10) actionview (= 5.1.5)
activesupport (= 4.2.10) activesupport (= 5.1.5)
rack (~> 1.6) rack (~> 2.0)
rack-test (~> 0.6.2) rack-test (>= 0.6.3)
rails-dom-testing (~> 1.0, >= 1.0.5) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2) rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.10) actionview (5.1.5)
activesupport (= 4.2.10) activesupport (= 5.1.5)
builder (~> 3.1) builder (~> 3.1)
erubis (~> 2.7.0) erubi (~> 1.4)
rails-dom-testing (~> 1.0, >= 1.0.5) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3) rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (4.2.10) activejob (5.1.5)
activesupport (= 4.2.10) activesupport (= 5.1.5)
globalid (>= 0.3.0) globalid (>= 0.3.6)
activemodel (4.2.10) activemodel (5.1.5)
activesupport (= 4.2.10) activesupport (= 5.1.5)
builder (~> 3.1) activerecord (5.1.5)
activerecord (4.2.10) activemodel (= 5.1.5)
activemodel (= 4.2.10) activesupport (= 5.1.5)
activesupport (= 4.2.10) arel (~> 8.0)
arel (~> 6.0) activesupport (5.1.5)
activesupport (4.2.10) concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7) i18n (~> 0.7)
minitest (~> 5.1) minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.5.2) addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0) public_suffix (>= 2.0.2, < 4.0)
arel (6.0.4) arel (8.0.0)
awesome_print (1.8.0) awesome_print (1.8.0)
builder (3.2.3) builder (3.2.3)
capybara (2.13.0) capybara (2.18.0)
addressable addressable
mime-types (>= 1.16) mini_mime (>= 0.1.3)
nokogiri (>= 1.3.3) nokogiri (>= 1.3.3)
rack (>= 1.0.0) rack (>= 1.0.0)
rack-test (>= 0.5.4) rack-test (>= 0.5.4)
xpath (~> 2.0) xpath (>= 2.0, < 4.0)
capybara-webkit (1.14.0) capybara-webkit (1.15.0)
capybara (>= 2.3.0, < 2.14.0) capybara (>= 2.3, < 4.0)
json json
coderay (1.1.2) coderay (1.1.2)
coffee-rails (4.2.2) coffee-rails (4.2.2)
@ -59,47 +62,48 @@ GEM
execjs execjs
coffee-script-source (1.12.2) coffee-script-source (1.12.2)
concurrent-ruby (1.0.5) concurrent-ruby (1.0.5)
coveralls (0.8.21) coveralls (0.7.2)
json (>= 1.8, < 3) multi_json (~> 1.3)
simplecov (~> 0.14.1) rest-client (= 1.6.7)
term-ansicolor (~> 1.3) simplecov (>= 0.7)
thor (~> 0.19.4) term-ansicolor (= 1.2.2)
tins (~> 1.6) thor (= 0.18.1)
crass (1.0.3) crass (1.0.3)
database_cleaner (1.6.2) database_cleaner (1.6.2)
diff-lcs (1.3) diff-lcs (1.3)
docile (1.1.5) docile (1.3.0)
elasticsearch (5.0.4) elasticsearch (6.0.2)
elasticsearch-api (= 5.0.4) elasticsearch-api (= 6.0.2)
elasticsearch-transport (= 5.0.4) elasticsearch-transport (= 6.0.2)
elasticsearch-api (5.0.4) elasticsearch-api (6.0.2)
multi_json multi_json
elasticsearch-dsl (0.1.5) elasticsearch-dsl (0.1.5)
elasticsearch-model (5.0.2) elasticsearch-model (5.0.0)
activesupport (> 3) activesupport (> 3)
elasticsearch (~> 5) elasticsearch (> 1)
hashie hashie
elasticsearch-transport (5.0.4) elasticsearch-rails (5.0.2)
elasticsearch-transport (6.0.2)
faraday faraday
multi_json multi_json
erubis (2.7.0) erubi (1.7.1)
execjs (2.7.0) execjs (2.7.0)
factory_girl (4.9.0) factory_bot (4.8.2)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
factory_girl_rails (4.9.0) factory_bot_rails (4.8.2)
factory_girl (~> 4.9.0) factory_bot (~> 4.8.2)
railties (>= 3.0.0) railties (>= 3.0.0)
faker (1.8.5) faker (1.8.7)
i18n (~> 0.9.1) i18n (>= 0.7)
faraday (0.13.1) faraday (0.14.0)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
foundation-rails (5.5.3.2) foundation-rails (5.5.3.2)
railties (>= 3.1.0) railties (>= 3.1.0)
sass (>= 3.3.0, < 3.5) sass (>= 3.3.0, < 3.5)
globalid (0.4.1) globalid (0.4.1)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
hashie (3.5.6) hashie (3.5.7)
i18n (0.9.1) i18n (0.9.5)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
jquery-rails (4.3.1) jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3) rails-dom-testing (>= 1, < 3)
@ -118,12 +122,12 @@ GEM
activerecord activerecord
kaminari-core (= 1.1.1) kaminari-core (= 1.1.1)
kaminari-core (1.1.1) kaminari-core (1.1.1)
kaminari-i18n (0.4.0) kaminari-i18n (0.5.0)
kaminari kaminari
rails rails
launchy (2.4.3) launchy (2.4.3)
addressable (~> 2.3) addressable (~> 2.3)
loofah (2.1.1) loofah (2.2.2)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.7.0) mail (2.7.0)
@ -134,12 +138,13 @@ GEM
mime-types-data (3.2016.0521) mime-types-data (3.2016.0521)
mini_mime (1.0.0) mini_mime (1.0.0)
mini_portile2 (2.3.0) mini_portile2 (2.3.0)
minitest (5.10.3) minitest (5.11.3)
multi_json (1.12.2) multi_json (1.13.1)
multipart-post (2.0.0) multipart-post (2.0.0)
nokogiri (1.8.1) nio4r (2.3.0)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0) mini_portile2 (~> 2.3.0)
omniauth (1.7.1) omniauth (1.8.1)
hashie (>= 3.4.6, < 3.6.0) hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3) rack (>= 1.6.2, < 3)
omniauth-browserid (0.0.1) omniauth-browserid (0.0.1)
@ -151,42 +156,45 @@ GEM
method_source (~> 0.9.0) method_source (~> 0.9.0)
pry-rails (0.3.6) pry-rails (0.3.6)
pry (>= 0.10.4) pry (>= 0.10.4)
public_suffix (3.0.1) public_suffix (3.0.2)
quiet_assets (1.1.0) rack (2.0.4)
railties (>= 3.1, < 5.0) rack-test (0.8.3)
rack (1.6.8) rack (>= 1.0, < 3)
rack-test (0.6.3) rails (5.1.5)
rack (>= 1.0) actioncable (= 5.1.5)
rails (4.2.10) actionmailer (= 5.1.5)
actionmailer (= 4.2.10) actionpack (= 5.1.5)
actionpack (= 4.2.10) actionview (= 5.1.5)
actionview (= 4.2.10) activejob (= 5.1.5)
activejob (= 4.2.10) activemodel (= 5.1.5)
activemodel (= 4.2.10) activerecord (= 5.1.5)
activerecord (= 4.2.10) activesupport (= 5.1.5)
activesupport (= 4.2.10) bundler (>= 1.3.0)
bundler (>= 1.3.0, < 2.0) railties (= 5.1.5)
railties (= 4.2.10) sprockets-rails (>= 2.0.0)
sprockets-rails rails-controller-testing (1.0.2)
rails-deprecated_sanitizer (1.0.3) actionpack (~> 5.x, >= 5.0.1)
activesupport (>= 4.2.0.alpha) actionview (~> 5.x, >= 5.0.1)
rails-dom-testing (1.0.8) activesupport (~> 5.x)
activesupport (>= 4.2.0.beta, < 5.0) rails-dom-testing (2.0.3)
nokogiri (~> 1.6) activesupport (>= 4.2.0)
rails-deprecated_sanitizer (>= 1.0.1) nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3) rails-html-sanitizer (1.0.4)
loofah (~> 2.0) loofah (~> 2.2, >= 2.2.2)
rails-i18n (4.0.9) rails-i18n (5.1.1)
i18n (~> 0.7) i18n (>= 0.7, < 2)
railties (~> 4.0) railties (>= 5.0, < 6)
railties (4.2.10) railties (5.1.5)
actionpack (= 4.2.10) actionpack (= 5.1.5)
activesupport (= 4.2.10) activesupport (= 5.1.5)
method_source
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
rake (12.3.0) rake (12.3.1)
rdoc (4.3.0) rdoc (4.3.0)
rspec-core (3.7.0) rest-client (1.6.7)
mime-types (>= 1.16)
rspec-core (3.7.1)
rspec-support (~> 3.7.0) rspec-support (~> 3.7.0)
rspec-expectations (3.7.0) rspec-expectations (3.7.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
@ -202,7 +210,7 @@ GEM
rspec-expectations (~> 3.7.0) rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0) rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0) rspec-support (~> 3.7.0)
rspec-support (3.7.0) rspec-support (3.7.1)
sass (3.4.25) sass (3.4.25)
sass-rails (5.0.7) sass-rails (5.0.7)
railties (>= 4.0.0, < 6) railties (>= 4.0.0, < 6)
@ -215,8 +223,8 @@ GEM
rdoc (~> 4.0) rdoc (~> 4.0)
shoulda-matchers (3.1.2) shoulda-matchers (3.1.2)
activesupport (>= 4.0.0) activesupport (>= 4.0.0)
simplecov (0.14.1) simplecov (0.16.1)
docile (~> 1.1.0) docile (~> 1.1)
json (>= 1.8, < 3) json (>= 1.8, < 3)
simplecov-html (~> 0.10.0) simplecov-html (~> 0.10.0)
simplecov-html (0.10.2) simplecov-html (0.10.2)
@ -240,26 +248,27 @@ GEM
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
sqlite3 (1.3.13) sqlite3 (1.3.13)
temple (0.8.0) temple (0.8.0)
term-ansicolor (1.6.0) term-ansicolor (1.2.2)
tins (~> 1.0) tins (~> 0.8)
test_after_commit (1.1.0) thor (0.18.1)
activerecord (>= 3.2)
thor (0.19.4)
thread_safe (0.3.6) thread_safe (0.3.6)
tilt (2.0.8) tilt (2.0.8)
tins (1.16.3) tins (0.13.2)
turbolinks (5.0.1) turbolinks (5.1.0)
turbolinks-source (~> 5) turbolinks-source (~> 5.1)
turbolinks-source (5.0.3) turbolinks-source (5.1.0)
tzinfo (1.2.4) tzinfo (1.2.5)
thread_safe (~> 0.1) thread_safe (~> 0.1)
uglifier (4.0.1) uglifier (4.1.8)
execjs (>= 0.3.0, < 3) execjs (>= 0.3.0, < 3)
validate_url (1.0.2) validate_url (1.0.2)
activemodel (>= 3.0.0) activemodel (>= 3.0.0)
addressable addressable
xpath (2.1.0) websocket-driver (0.6.5)
nokogiri (~> 1.3) websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
xpath (3.0.0)
nokogiri (~> 1.8)
PLATFORMS PLATFORMS
ruby ruby
@ -271,10 +280,11 @@ DEPENDENCIES
coffee-rails coffee-rails
coveralls coveralls
database_cleaner database_cleaner
elasticsearch elasticsearch (~> 6)
elasticsearch-dsl elasticsearch-dsl
elasticsearch-model elasticsearch-model
factory_girl_rails elasticsearch-rails
factory_bot_rails
faker faker
foundation-rails (~> 5.5) foundation-rails (~> 5.5)
jquery-rails jquery-rails
@ -285,8 +295,8 @@ DEPENDENCIES
omniauth-browserid omniauth-browserid
pry pry
pry-rails pry-rails
quiet_assets rails (~> 5.1.5)
rails rails-controller-testing
rails-i18n rails-i18n
rspec-rails (~> 3.0) rspec-rails (~> 3.0)
sass-rails sass-rails
@ -297,11 +307,10 @@ DEPENDENCIES
spring spring
spring-commands-rspec spring-commands-rspec
sqlite3 sqlite3
test_after_commit
turbolinks turbolinks
tzinfo-data tzinfo-data
uglifier uglifier
validate_url validate_url
BUNDLED WITH BUNDLED WITH
1.16.0 1.16.1

View file

@ -1,5 +1,5 @@
class ImportController < ApplicationController class ImportController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => [:new_papers_callback] skip_before_action :verify_authenticity_token, :only => [:new_papers_callback]
def new_papers_callback def new_papers_callback
require 'open-uri' require 'open-uri'

View file

@ -21,7 +21,8 @@ module LorisWeb
config.i18n.default_locale = :de config.i18n.default_locale = :de
config.active_record.raise_in_transactional_callbacks = true # https://stackoverflow.com/a/28008145
#config.active_record.raise_in_transactional_callbacks = true
end end
end end

View file

@ -1,4 +0,0 @@
Rails.application.config.middleware.use OmniAuth::Builder do
provider :developer if Rails.env.test?
provider :browser_id
end

View file

@ -9,7 +9,9 @@ web:
environment: environment:
ELASTICSEARCH_URL: 'http://elasticsearch:9200' ELASTICSEARCH_URL: 'http://elasticsearch:9200'
elasticsearch: elasticsearch:
image: elasticsearch:1.7 image: elasticsearch:5.4.3
ports:
- "9200:9200"
volumes: volumes:
- .:/apps - .:/apps
entrypoint: /apps/docker-entrypoint-es-plugins.sh entrypoint: /apps/docker-entrypoint-es-plugins.sh

View file

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
plugin -install elasticsearch-analysis-decompound --url http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-analysis-decompound/1.7.1.3/elasticsearch-analysis-decompound-1.7.1.3-plugin.zip ./bin/elasticsearch-plugin install http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-analysis-decompound/5.4.3.0/elasticsearch-analysis-decompound-5.4.3.0-plugin.zip
exec /docker-entrypoint.sh elasticsearch exec /docker-entrypoint.sh elasticsearch

View file

@ -3,7 +3,7 @@ class ParseableDateValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value) def validate_each(record, attribute, value)
raw_value = record.read_attribute_before_type_cast(attribute) raw_value = record.read_attribute_before_type_cast(attribute)
return nil if raw_value.nil? return nil if raw_value.nil?
Date.parse(raw_value) Date.parse(raw_value.to_json)
nil nil
rescue ArgumentError => e rescue ArgumentError => e
record.errors[attribute] << (options[:message] || I18n.t("errors.messages.unparseable_date")) record.errors[attribute] << (options[:message] || I18n.t("errors.messages.unparseable_date"))

View file

@ -1,6 +1,6 @@
require_relative '../factory_helper' require_relative '../factory_helper'
FactoryGirl.define do FactoryBot.define do
factory :paper do factory :paper do
name { Faker::Lorem.sentence } name { Faker::Lorem.sentence }
sequence(:url) { |n| Faker::Internet.url("ris.example.org", "/paper-#{n}.html") } sequence(:url) { |n| Faker::Internet.url("ris.example.org", "/paper-#{n}.html") }

View file

@ -4,7 +4,7 @@ require 'pp'
RSpec.feature "Basic search", type: :feature, elasticsearch: true do RSpec.feature "Basic search", type: :feature, elasticsearch: true do
before(:each) do before(:each) do
@papers = FactoryGirl.create_list(:paper, 11) @papers = FactoryBot.create_list(:paper, 11)
Paper.__elasticsearch__.refresh_index! Paper.__elasticsearch__.refresh_index!
end end
@ -63,7 +63,7 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
end end
scenario "Finds papers by name" do scenario "Finds papers by name" do
paper = FactoryGirl.create(:paper, name: "Opendata als default") paper = FactoryBot.create(:paper, name: "Opendata als default")
Paper.__elasticsearch__.refresh_index! Paper.__elasticsearch__.refresh_index!
visit search_path body: "leipzig", paper_search: {query: "Opendata"} visit search_path body: "leipzig", paper_search: {query: "Opendata"}
expect(page).to have_content("1 Dokument in der Datenbank") expect(page).to have_content("1 Dokument in der Datenbank")
@ -76,7 +76,7 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
end end
scenario "Finds papers by content" do scenario "Finds papers by content" do
paper = FactoryGirl.create(:paper, paper = FactoryBot.create(:paper,
name: "Opendata als default", name: "Opendata als default",
content: "Alle Verwaltungsdokumente werden als Opendata veröffentlicht" content: "Alle Verwaltungsdokumente werden als Opendata veröffentlicht"
) )
@ -92,9 +92,9 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
end end
scenario "Papers with common reference id in search result ordered by date" do scenario "Papers with common reference id in search result ordered by date" do
mainPaper = FactoryGirl.create(:paper, published_at: '2016-12-19T19:00:00', mainPaper = FactoryBot.create(:paper, published_at: '2016-12-19T19:00:00',
name: "Opendata als default", reference: "VI-0815") name: "Opendata als default", reference: "VI-0815")
newPaper = FactoryGirl.create(:paper, published_at: '2016-12-23T12:00:00', newPaper = FactoryBot.create(:paper, published_at: '2016-12-23T12:00:00',
name: "Opendata als optional", reference: "VI-0815-ÄA-01") name: "Opendata als optional", reference: "VI-0815-ÄA-01")
Paper.__elasticsearch__.refresh_index! Paper.__elasticsearch__.refresh_index!
visit search_path body: "leipzig", paper_search: {query: "default"} visit search_path body: "leipzig", paper_search: {query: "default"}
@ -112,11 +112,11 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
end end
scenario "Papers with common reference id in search result ordered by ref" do scenario "Papers with common reference id in search result ordered by ref" do
mainPaper = FactoryGirl.create(:paper, published_at: '2016-12-19T19:00:00', mainPaper = FactoryBot.create(:paper, published_at: '2016-12-19T19:00:00',
name: "Opendata als default", reference: "VI-0815") name: "Opendata als default", reference: "VI-0815")
newPaper1 = FactoryGirl.create(:paper, published_at: '2016-12-23T12:00:00', newPaper1 = FactoryBot.create(:paper, published_at: '2016-12-23T12:00:00',
name: "Opendata als optional", reference: "VI-0815-ÄA-02") name: "Opendata als optional", reference: "VI-0815-ÄA-02")
newPaper2 = FactoryGirl.create(:paper, published_at: '2016-12-23T12:00:00', newPaper2 = FactoryBot.create(:paper, published_at: '2016-12-23T12:00:00',
name: "Opendata als optional", reference: "VI-0815-ÄA-01") name: "Opendata als optional", reference: "VI-0815-ÄA-01")
Paper.__elasticsearch__.refresh_index! Paper.__elasticsearch__.refresh_index!
visit search_path body: "leipzig", paper_search: {query: "default"} visit search_path body: "leipzig", paper_search: {query: "default"}
@ -131,11 +131,11 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
end end
scenario "Papers with common reference id handled also for missing prefix" do scenario "Papers with common reference id handled also for missing prefix" do
mainPaper = FactoryGirl.create(:paper, published_at: '2016-12-19T19:00:00', mainPaper = FactoryBot.create(:paper, published_at: '2016-12-19T19:00:00',
name: "Opendata als default", reference: "VI-0815") name: "Opendata als default", reference: "VI-0815")
newPaper1 = FactoryGirl.create(:paper, published_at: '2016-12-23T12:00:00', newPaper1 = FactoryBot.create(:paper, published_at: '2016-12-23T12:00:00',
name: "Opendata als optional", reference: "VI-0815-NF-01") name: "Opendata als optional", reference: "VI-0815-NF-01")
newPaper1Change = FactoryGirl.create(:paper, published_at: '2016-12-23T12:00:00', newPaper1Change = FactoryBot.create(:paper, published_at: '2016-12-23T12:00:00',
name: "Opendata als nicht optional", reference: "-0815-NF-01-ÄA-01") name: "Opendata als nicht optional", reference: "-0815-NF-01-ÄA-01")
Paper.__elasticsearch__.refresh_index! Paper.__elasticsearch__.refresh_index!
visit search_path body: "leipzig", paper_search: {query: "default"} visit search_path body: "leipzig", paper_search: {query: "default"}
@ -150,7 +150,7 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
end end
scenario "Finds 'Testen' with search 'Test'" do scenario "Finds 'Testen' with search 'Test'" do
paper = FactoryGirl.create(:paper, name: "Testen") paper = FactoryBot.create(:paper, name: "Testen")
Paper.__elasticsearch__.refresh_index! Paper.__elasticsearch__.refresh_index!
visit search_path body: "leipzig", paper_search: {query: "Test"} visit search_path body: "leipzig", paper_search: {query: "Test"}
expect(page).to have_content("1 Dokument in der Datenbank") expect(page).to have_content("1 Dokument in der Datenbank")
@ -159,7 +159,7 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
end end
scenario "Finds 'Test' with search 'Testen'" do scenario "Finds 'Test' with search 'Testen'" do
paper = FactoryGirl.create(:paper, name: "Test") paper = FactoryBot.create(:paper, name: "Test")
Paper.__elasticsearch__.refresh_index! Paper.__elasticsearch__.refresh_index!
visit search_path body: "leipzig", paper_search: {query: "Testen"} visit search_path body: "leipzig", paper_search: {query: "Testen"}
expect(page).to have_content("1 Dokument in der Datenbank") expect(page).to have_content("1 Dokument in der Datenbank")
@ -168,7 +168,7 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
end end
scenario "Finds 'Fahrräderverleih' with search 'Fahrrad'" do scenario "Finds 'Fahrräderverleih' with search 'Fahrrad'" do
paper = FactoryGirl.create(:paper, name: "Fahrräderverleih") paper = FactoryBot.create(:paper, name: "Fahrräderverleih")
Paper.__elasticsearch__.refresh_index! Paper.__elasticsearch__.refresh_index!
visit search_path body: "leipzig", paper_search: {query: "Fahrrad"} visit search_path body: "leipzig", paper_search: {query: "Fahrrad"}
expect(page).to have_content("1 Dokument in der Datenbank") expect(page).to have_content("1 Dokument in der Datenbank")
@ -177,7 +177,7 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
end end
scenario "Finds 'Fahrräderverleih' with search 'Fahrräder'" do scenario "Finds 'Fahrräderverleih' with search 'Fahrräder'" do
paper = FactoryGirl.create(:paper, name: "Fahrräderverleih") paper = FactoryBot.create(:paper, name: "Fahrräderverleih")
Paper.__elasticsearch__.refresh_index! Paper.__elasticsearch__.refresh_index!
visit search_path body: "leipzig", paper_search: {query: "Fahrräder"} visit search_path body: "leipzig", paper_search: {query: "Fahrräder"}
expect(page).to have_content("1 Dokument in der Datenbank") expect(page).to have_content("1 Dokument in der Datenbank")
@ -186,7 +186,7 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
end end
scenario "Finds 'Fahrräderverleih' with search 'Verleih'" do scenario "Finds 'Fahrräderverleih' with search 'Verleih'" do
paper = FactoryGirl.create(:paper, name: "Fahrräderverleih") paper = FactoryBot.create(:paper, name: "Fahrräderverleih")
Paper.__elasticsearch__.refresh_index! Paper.__elasticsearch__.refresh_index!
visit search_path body: "leipzig", paper_search: {query: "Verleih"} visit search_path body: "leipzig", paper_search: {query: "Verleih"}
expect(page).to have_content("1 Dokument in der Datenbank") expect(page).to have_content("1 Dokument in der Datenbank")
@ -195,7 +195,7 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
end end
scenario "Finds 'Fahrräderverleih' with search 'Autoverleih'" do scenario "Finds 'Fahrräderverleih' with search 'Autoverleih'" do
paper = FactoryGirl.create(:paper, name: "Fahrräderverleih") paper = FactoryBot.create(:paper, name: "Fahrräderverleih")
Paper.__elasticsearch__.refresh_index! Paper.__elasticsearch__.refresh_index!
visit search_path body: "leipzig", paper_search: {query: "Autoverleih"} visit search_path body: "leipzig", paper_search: {query: "Autoverleih"}
expect(page).to have_content("1 Dokument in der Datenbank") expect(page).to have_content("1 Dokument in der Datenbank")
@ -204,16 +204,16 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
end end
scenario "Finds no 'Fahrrad' with search 'Rad'" do scenario "Finds no 'Fahrrad' with search 'Rad'" do
paper = FactoryGirl.create(:paper, name: "Fahrrad") paper = FactoryBot.create(:paper, name: "Fahrrad")
Paper.__elasticsearch__.refresh_index! Paper.__elasticsearch__.refresh_index!
visit search_path body: "leipzig", paper_search: {query: "Rad"} visit search_path body: "leipzig", paper_search: {query: "Rad"}
expect(page).to have_content("0 Dokumente in der Datenbank") expect(page).to have_content("0 Dokumente in der Datenbank")
end end
scenario "Papers with reference id having slash is escaped" do scenario "Papers with reference id having slash is escaped" do
mainPaper = FactoryGirl.create(:paper, published_at: '2016-12-19T19:00:00', mainPaper = FactoryBot.create(:paper, published_at: '2016-12-19T19:00:00',
name: "Opendata als default", reference: "VI-00768/14") name: "Opendata als default", reference: "VI-00768/14")
newPaper = FactoryGirl.create(:paper, published_at: '2016-12-23T12:00:00', newPaper = FactoryBot.create(:paper, published_at: '2016-12-23T12:00:00',
name: "Opendata als optional", reference: "VI-00768/14-ÄA-01") name: "Opendata als optional", reference: "VI-00768/14-ÄA-01")
Paper.__elasticsearch__.refresh_index! Paper.__elasticsearch__.refresh_index!
visit search_path body: "leipzig", paper_search: {query: "default"} visit search_path body: "leipzig", paper_search: {query: "default"}

View file

@ -3,21 +3,21 @@ 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, @antrag = FactoryBot.create(:paper,
paper_type: "Antrag", paper_type: "Antrag",
name: "Mehr Spielplätze in Leipzig", name: "Mehr Spielplätze in Leipzig",
originator: "Dezernat Jugend, Soziales, Gesundheit und Schule" originator: "Dezernat Jugend, Soziales, Gesundheit und Schule"
) )
@anfrage = FactoryGirl.create(:paper, @anfrage = FactoryBot.create(:paper,
paper_type: "Anfrage", paper_type: "Anfrage",
originator: "CDU-Fraktion" originator: "CDU-Fraktion"
) )
@vorlage_1 = FactoryGirl.create(:paper, @vorlage_1 = FactoryBot.create(:paper,
paper_type: "Vorlage", paper_type: "Vorlage",
name: "Zustand der Spielplätze", name: "Zustand der Spielplätze",
originator: "Dezernat Jugend, Soziales, Gesundheit und Schule" originator: "Dezernat Jugend, Soziales, Gesundheit und Schule"
) )
@vorlage_2 = FactoryGirl.create(:paper, @vorlage_2 = FactoryBot.create(:paper,
paper_type: "Vorlage", paper_type: "Vorlage",
name: "Mehr Ampeln in der Innenstadt", name: "Mehr Ampeln in der Innenstadt",
originator: "Oberbürgermeister" originator: "Oberbürgermeister"

View file

@ -9,13 +9,13 @@ RSpec.describe Paper do
it { should validate_length_of(:url).is_at_most(1000) } it { should validate_length_of(:url).is_at_most(1000) }
context "URL uniqueness" do context "URL uniqueness" do
subject { FactoryGirl.build(:paper) } subject { FactoryBot.build(:paper) }
it { should validate_uniqueness_of(:url) } it { should validate_uniqueness_of(:url) }
end end
it "validate url format sane" do it "validate url format sane" do
expected_error = "ist keine gültige URL" expected_error = "ist keine gültige URL"
paper = FactoryGirl.build(:paper, url: "wtf") paper = FactoryBot.build(:paper, url: "wtf")
expect(paper).not_to be_valid, "Expected paper to not be valid with invalid URL" expect(paper).not_to be_valid, "Expected paper to not be valid with invalid URL"
expect(paper.errors[:url]).not_to be_empty expect(paper.errors[:url]).not_to be_empty
expect(paper.errors[:url]).to include(expected_error), "Expected #{paper.errors[:url]} to include \"#{expected_error}\"" expect(paper.errors[:url]).to include(expected_error), "Expected #{paper.errors[:url]} to include \"#{expected_error}\""
@ -40,7 +40,7 @@ RSpec.describe Paper do
it { should validate_presence_of(:published_at) } it { should validate_presence_of(:published_at) }
it "validate date is parseable" do it "validate date is parseable" do
expected_error = "ist kein gültiges Datum" expected_error = "ist kein gültiges Datum"
paper = FactoryGirl.build(:paper, published_at: "fubar") paper = FactoryBot.build(:paper, published_at: "fubar")
expect(paper).not_to be_valid expect(paper).not_to be_valid
expect(paper.errors[:published_at]).not_to be_empty expect(paper.errors[:published_at]).not_to be_empty
expect(paper.errors[:published_at]).to include(expected_error), "Expected #{paper.errors[:published_at]} to include \"#{expected_error}\"" expect(paper.errors[:published_at]).to include(expected_error), "Expected #{paper.errors[:published_at]} to include \"#{expected_error}\""

View file

@ -0,0 +1,3 @@
RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
end

View file

@ -1,3 +0,0 @@
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end

View file

@ -9,12 +9,12 @@ class PaperTest < ActiveSupport::TestCase
should validate_presence_of(:url) should validate_presence_of(:url)
should validate_length_of(:url).is_at_most(1000) should validate_length_of(:url).is_at_most(1000)
context "URL uniqueness" do context "URL uniqueness" do
subject { FactoryGirl.build(:paper) } subject { FactoryBot.build(:paper) }
should validate_uniqueness_of(:url) should validate_uniqueness_of(:url)
end end
should "validate url format sane" do should "validate url format sane" do
expected_error = "ist keine gültige URL" expected_error = "ist keine gültige URL"
paper = FactoryGirl.build(:paper, url: "wtf") paper = FactoryBot.build(:paper, url: "wtf")
assert_not paper.valid?, "Expected paper to not be valid with invalid URL" assert_not paper.valid?, "Expected paper to not be valid with invalid URL"
assert_not paper.errors[:url].empty? assert_not paper.errors[:url].empty?
assert paper.errors[:url].include?(expected_error), "Expected #{paper.errors[:url]} to include \"#{expected_error}\"" assert paper.errors[:url].include?(expected_error), "Expected #{paper.errors[:url]} to include \"#{expected_error}\""
@ -39,7 +39,7 @@ class PaperTest < ActiveSupport::TestCase
should validate_presence_of(:published_at) should validate_presence_of(:published_at)
should "validate date is parseable" do should "validate date is parseable" do
expected_error = "ist kein gültiges Datum" expected_error = "ist kein gültiges Datum"
paper = FactoryGirl.build(:paper, published_at: "fubar") paper = FactoryBot.build(:paper, published_at: "fubar")
assert_not paper.valid? assert_not paper.valid?
assert_not paper.errors[:published_at].empty? assert_not paper.errors[:published_at].empty?
assert paper.errors[:published_at].include?(expected_error), "Expected #{paper.errors[:published_at]} to include \"#{expected_error}\"" assert paper.errors[:published_at].include?(expected_error), "Expected #{paper.errors[:published_at]} to include \"#{expected_error}\""