mirror of
https://github.com/CodeforLeipzig/stadtratmonitor.git
synced 2024-12-31 11:32:56 +01:00
Migration to Ruby 2.5, Rails 5.1.5, Elasticsearch 5.4.3
This commit is contained in:
parent
85d2ad5d57
commit
ad77627973
17 changed files with 180 additions and 170 deletions
|
@ -1 +1 @@
|
|||
2.1.5
|
||||
2.5.0
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
FROM ruby:2.2
|
||||
RUN apt-get update && \
|
||||
apt-get install -y build-essential zlib1g-dev libsqlite3-dev nodejs nodejs-legacy npm \
|
||||
FROM ruby:2.5
|
||||
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 npm \
|
||||
libxml2-dev libxslt1-dev pkg-config \
|
||||
libqt4-webkit libqt4-dev xvfb
|
||||
libqtwebkit4 libqtwebkit-dev libqt4-dev xvfb
|
||||
|
||||
RUN mkdir -p /app
|
||||
|
||||
|
|
12
Gemfile
12
Gemfile
|
@ -2,7 +2,7 @@ source 'https://rubygems.org'
|
|||
|
||||
|
||||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
||||
gem 'rails'
|
||||
gem 'rails', '~> 5.1.5'
|
||||
gem 'rails-i18n'
|
||||
# Use sqlite3 as the database for Active Record
|
||||
gem 'sqlite3'
|
||||
|
@ -30,8 +30,9 @@ gem 'validate_url'
|
|||
gem 'omniauth'
|
||||
gem 'omniauth-browserid'
|
||||
|
||||
gem 'elasticsearch'
|
||||
gem 'elasticsearch', '~> 6'
|
||||
gem 'elasticsearch-model'
|
||||
gem 'elasticsearch-rails'
|
||||
gem 'elasticsearch-dsl'
|
||||
|
||||
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
|
||||
|
@ -42,7 +43,8 @@ gem 'sdoc', '~> 0.4.0', group: :doc
|
|||
group :development do
|
||||
gem 'spring'
|
||||
gem 'spring-commands-rspec'
|
||||
gem 'quiet_assets'
|
||||
# https://rossta.net/blog/quiet-assets-in-rails-5.html
|
||||
# gem 'quiet_assets'
|
||||
gem 'awesome_print'
|
||||
# gem 'guard-rspec', require: false
|
||||
# gem 'terminal-notifier-guard' # FIXME cross-platform
|
||||
|
@ -57,14 +59,14 @@ group :development, :test do
|
|||
end
|
||||
|
||||
group :test do
|
||||
gem 'factory_girl_rails'
|
||||
gem "factory_bot_rails"
|
||||
gem 'shoulda-matchers', '~> 3.1'
|
||||
gem 'faker'
|
||||
gem 'simplecov', require: false
|
||||
gem 'test_after_commit' # TODO remove when moving to rails 5
|
||||
gem 'database_cleaner'
|
||||
gem 'coveralls', require: false
|
||||
gem 'capybara-webkit'
|
||||
gem 'rails-controller-testing'
|
||||
end
|
||||
|
||||
# Use ActiveModel has_secure_password
|
||||
|
|
243
Gemfile.lock
243
Gemfile.lock
|
@ -1,54 +1,57 @@
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionmailer (4.2.10)
|
||||
actionpack (= 4.2.10)
|
||||
actionview (= 4.2.10)
|
||||
activejob (= 4.2.10)
|
||||
actioncable (5.1.5)
|
||||
actionpack (= 5.1.5)
|
||||
nio4r (~> 2.0)
|
||||
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)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
actionpack (4.2.10)
|
||||
actionview (= 4.2.10)
|
||||
activesupport (= 4.2.10)
|
||||
rack (~> 1.6)
|
||||
rack-test (~> 0.6.2)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.1.5)
|
||||
actionview (= 5.1.5)
|
||||
activesupport (= 5.1.5)
|
||||
rack (~> 2.0)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (4.2.10)
|
||||
activesupport (= 4.2.10)
|
||||
actionview (5.1.5)
|
||||
activesupport (= 5.1.5)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activejob (4.2.10)
|
||||
activesupport (= 4.2.10)
|
||||
globalid (>= 0.3.0)
|
||||
activemodel (4.2.10)
|
||||
activesupport (= 4.2.10)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.2.10)
|
||||
activemodel (= 4.2.10)
|
||||
activesupport (= 4.2.10)
|
||||
arel (~> 6.0)
|
||||
activesupport (4.2.10)
|
||||
activejob (5.1.5)
|
||||
activesupport (= 5.1.5)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.1.5)
|
||||
activesupport (= 5.1.5)
|
||||
activerecord (5.1.5)
|
||||
activemodel (= 5.1.5)
|
||||
activesupport (= 5.1.5)
|
||||
arel (~> 8.0)
|
||||
activesupport (5.1.5)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (~> 0.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
addressable (2.5.2)
|
||||
public_suffix (>= 2.0.2, < 4.0)
|
||||
arel (6.0.4)
|
||||
arel (8.0.0)
|
||||
awesome_print (1.8.0)
|
||||
builder (3.2.3)
|
||||
capybara (2.13.0)
|
||||
capybara (2.18.0)
|
||||
addressable
|
||||
mime-types (>= 1.16)
|
||||
mini_mime (>= 0.1.3)
|
||||
nokogiri (>= 1.3.3)
|
||||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
xpath (~> 2.0)
|
||||
capybara-webkit (1.14.0)
|
||||
capybara (>= 2.3.0, < 2.14.0)
|
||||
xpath (>= 2.0, < 4.0)
|
||||
capybara-webkit (1.15.0)
|
||||
capybara (>= 2.3, < 4.0)
|
||||
json
|
||||
coderay (1.1.2)
|
||||
coffee-rails (4.2.2)
|
||||
|
@ -59,47 +62,48 @@ GEM
|
|||
execjs
|
||||
coffee-script-source (1.12.2)
|
||||
concurrent-ruby (1.0.5)
|
||||
coveralls (0.8.21)
|
||||
json (>= 1.8, < 3)
|
||||
simplecov (~> 0.14.1)
|
||||
term-ansicolor (~> 1.3)
|
||||
thor (~> 0.19.4)
|
||||
tins (~> 1.6)
|
||||
coveralls (0.7.2)
|
||||
multi_json (~> 1.3)
|
||||
rest-client (= 1.6.7)
|
||||
simplecov (>= 0.7)
|
||||
term-ansicolor (= 1.2.2)
|
||||
thor (= 0.18.1)
|
||||
crass (1.0.3)
|
||||
database_cleaner (1.6.2)
|
||||
diff-lcs (1.3)
|
||||
docile (1.1.5)
|
||||
elasticsearch (5.0.4)
|
||||
elasticsearch-api (= 5.0.4)
|
||||
elasticsearch-transport (= 5.0.4)
|
||||
elasticsearch-api (5.0.4)
|
||||
docile (1.3.0)
|
||||
elasticsearch (6.0.2)
|
||||
elasticsearch-api (= 6.0.2)
|
||||
elasticsearch-transport (= 6.0.2)
|
||||
elasticsearch-api (6.0.2)
|
||||
multi_json
|
||||
elasticsearch-dsl (0.1.5)
|
||||
elasticsearch-model (5.0.2)
|
||||
elasticsearch-model (5.0.0)
|
||||
activesupport (> 3)
|
||||
elasticsearch (~> 5)
|
||||
elasticsearch (> 1)
|
||||
hashie
|
||||
elasticsearch-transport (5.0.4)
|
||||
elasticsearch-rails (5.0.2)
|
||||
elasticsearch-transport (6.0.2)
|
||||
faraday
|
||||
multi_json
|
||||
erubis (2.7.0)
|
||||
erubi (1.7.1)
|
||||
execjs (2.7.0)
|
||||
factory_girl (4.9.0)
|
||||
factory_bot (4.8.2)
|
||||
activesupport (>= 3.0.0)
|
||||
factory_girl_rails (4.9.0)
|
||||
factory_girl (~> 4.9.0)
|
||||
factory_bot_rails (4.8.2)
|
||||
factory_bot (~> 4.8.2)
|
||||
railties (>= 3.0.0)
|
||||
faker (1.8.5)
|
||||
i18n (~> 0.9.1)
|
||||
faraday (0.13.1)
|
||||
faker (1.8.7)
|
||||
i18n (>= 0.7)
|
||||
faraday (0.14.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
foundation-rails (5.5.3.2)
|
||||
railties (>= 3.1.0)
|
||||
sass (>= 3.3.0, < 3.5)
|
||||
globalid (0.4.1)
|
||||
activesupport (>= 4.2.0)
|
||||
hashie (3.5.6)
|
||||
i18n (0.9.1)
|
||||
hashie (3.5.7)
|
||||
i18n (0.9.5)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jquery-rails (4.3.1)
|
||||
rails-dom-testing (>= 1, < 3)
|
||||
|
@ -118,12 +122,12 @@ GEM
|
|||
activerecord
|
||||
kaminari-core (= 1.1.1)
|
||||
kaminari-core (1.1.1)
|
||||
kaminari-i18n (0.4.0)
|
||||
kaminari-i18n (0.5.0)
|
||||
kaminari
|
||||
rails
|
||||
launchy (2.4.3)
|
||||
addressable (~> 2.3)
|
||||
loofah (2.1.1)
|
||||
loofah (2.2.2)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.0)
|
||||
|
@ -134,12 +138,13 @@ GEM
|
|||
mime-types-data (3.2016.0521)
|
||||
mini_mime (1.0.0)
|
||||
mini_portile2 (2.3.0)
|
||||
minitest (5.10.3)
|
||||
multi_json (1.12.2)
|
||||
minitest (5.11.3)
|
||||
multi_json (1.13.1)
|
||||
multipart-post (2.0.0)
|
||||
nokogiri (1.8.1)
|
||||
nio4r (2.3.0)
|
||||
nokogiri (1.8.2)
|
||||
mini_portile2 (~> 2.3.0)
|
||||
omniauth (1.7.1)
|
||||
omniauth (1.8.1)
|
||||
hashie (>= 3.4.6, < 3.6.0)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-browserid (0.0.1)
|
||||
|
@ -151,42 +156,45 @@ GEM
|
|||
method_source (~> 0.9.0)
|
||||
pry-rails (0.3.6)
|
||||
pry (>= 0.10.4)
|
||||
public_suffix (3.0.1)
|
||||
quiet_assets (1.1.0)
|
||||
railties (>= 3.1, < 5.0)
|
||||
rack (1.6.8)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (4.2.10)
|
||||
actionmailer (= 4.2.10)
|
||||
actionpack (= 4.2.10)
|
||||
actionview (= 4.2.10)
|
||||
activejob (= 4.2.10)
|
||||
activemodel (= 4.2.10)
|
||||
activerecord (= 4.2.10)
|
||||
activesupport (= 4.2.10)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.2.10)
|
||||
sprockets-rails
|
||||
rails-deprecated_sanitizer (1.0.3)
|
||||
activesupport (>= 4.2.0.alpha)
|
||||
rails-dom-testing (1.0.8)
|
||||
activesupport (>= 4.2.0.beta, < 5.0)
|
||||
nokogiri (~> 1.6)
|
||||
rails-deprecated_sanitizer (>= 1.0.1)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
rails-i18n (4.0.9)
|
||||
i18n (~> 0.7)
|
||||
railties (~> 4.0)
|
||||
railties (4.2.10)
|
||||
actionpack (= 4.2.10)
|
||||
activesupport (= 4.2.10)
|
||||
public_suffix (3.0.2)
|
||||
rack (2.0.4)
|
||||
rack-test (0.8.3)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (5.1.5)
|
||||
actioncable (= 5.1.5)
|
||||
actionmailer (= 5.1.5)
|
||||
actionpack (= 5.1.5)
|
||||
actionview (= 5.1.5)
|
||||
activejob (= 5.1.5)
|
||||
activemodel (= 5.1.5)
|
||||
activerecord (= 5.1.5)
|
||||
activesupport (= 5.1.5)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.1.5)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-controller-testing (1.0.2)
|
||||
actionpack (~> 5.x, >= 5.0.1)
|
||||
actionview (~> 5.x, >= 5.0.1)
|
||||
activesupport (~> 5.x)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.0.4)
|
||||
loofah (~> 2.2, >= 2.2.2)
|
||||
rails-i18n (5.1.1)
|
||||
i18n (>= 0.7, < 2)
|
||||
railties (>= 5.0, < 6)
|
||||
railties (5.1.5)
|
||||
actionpack (= 5.1.5)
|
||||
activesupport (= 5.1.5)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (12.3.0)
|
||||
rake (12.3.1)
|
||||
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-expectations (3.7.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
|
@ -202,7 +210,7 @@ GEM
|
|||
rspec-expectations (~> 3.7.0)
|
||||
rspec-mocks (~> 3.7.0)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-support (3.7.0)
|
||||
rspec-support (3.7.1)
|
||||
sass (3.4.25)
|
||||
sass-rails (5.0.7)
|
||||
railties (>= 4.0.0, < 6)
|
||||
|
@ -215,8 +223,8 @@ GEM
|
|||
rdoc (~> 4.0)
|
||||
shoulda-matchers (3.1.2)
|
||||
activesupport (>= 4.0.0)
|
||||
simplecov (0.14.1)
|
||||
docile (~> 1.1.0)
|
||||
simplecov (0.16.1)
|
||||
docile (~> 1.1)
|
||||
json (>= 1.8, < 3)
|
||||
simplecov-html (~> 0.10.0)
|
||||
simplecov-html (0.10.2)
|
||||
|
@ -240,26 +248,27 @@ GEM
|
|||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
temple (0.8.0)
|
||||
term-ansicolor (1.6.0)
|
||||
tins (~> 1.0)
|
||||
test_after_commit (1.1.0)
|
||||
activerecord (>= 3.2)
|
||||
thor (0.19.4)
|
||||
term-ansicolor (1.2.2)
|
||||
tins (~> 0.8)
|
||||
thor (0.18.1)
|
||||
thread_safe (0.3.6)
|
||||
tilt (2.0.8)
|
||||
tins (1.16.3)
|
||||
turbolinks (5.0.1)
|
||||
turbolinks-source (~> 5)
|
||||
turbolinks-source (5.0.3)
|
||||
tzinfo (1.2.4)
|
||||
tins (0.13.2)
|
||||
turbolinks (5.1.0)
|
||||
turbolinks-source (~> 5.1)
|
||||
turbolinks-source (5.1.0)
|
||||
tzinfo (1.2.5)
|
||||
thread_safe (~> 0.1)
|
||||
uglifier (4.0.1)
|
||||
uglifier (4.1.8)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
validate_url (1.0.2)
|
||||
activemodel (>= 3.0.0)
|
||||
addressable
|
||||
xpath (2.1.0)
|
||||
nokogiri (~> 1.3)
|
||||
websocket-driver (0.6.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.3)
|
||||
xpath (3.0.0)
|
||||
nokogiri (~> 1.8)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
@ -271,10 +280,11 @@ DEPENDENCIES
|
|||
coffee-rails
|
||||
coveralls
|
||||
database_cleaner
|
||||
elasticsearch
|
||||
elasticsearch (~> 6)
|
||||
elasticsearch-dsl
|
||||
elasticsearch-model
|
||||
factory_girl_rails
|
||||
elasticsearch-rails
|
||||
factory_bot_rails
|
||||
faker
|
||||
foundation-rails (~> 5.5)
|
||||
jquery-rails
|
||||
|
@ -285,8 +295,8 @@ DEPENDENCIES
|
|||
omniauth-browserid
|
||||
pry
|
||||
pry-rails
|
||||
quiet_assets
|
||||
rails
|
||||
rails (~> 5.1.5)
|
||||
rails-controller-testing
|
||||
rails-i18n
|
||||
rspec-rails (~> 3.0)
|
||||
sass-rails
|
||||
|
@ -297,11 +307,10 @@ DEPENDENCIES
|
|||
spring
|
||||
spring-commands-rspec
|
||||
sqlite3
|
||||
test_after_commit
|
||||
turbolinks
|
||||
tzinfo-data
|
||||
uglifier
|
||||
validate_url
|
||||
|
||||
BUNDLED WITH
|
||||
1.16.0
|
||||
1.16.1
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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
|
||||
require 'open-uri'
|
||||
|
|
|
@ -21,7 +21,8 @@ module LorisWeb
|
|||
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
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
Rails.application.config.middleware.use OmniAuth::Builder do
|
||||
provider :developer if Rails.env.test?
|
||||
provider :browser_id
|
||||
end
|
|
@ -9,7 +9,9 @@ web:
|
|||
environment:
|
||||
ELASTICSEARCH_URL: 'http://elasticsearch:9200'
|
||||
elasticsearch:
|
||||
image: elasticsearch:1.7
|
||||
image: elasticsearch:5.4.3
|
||||
ports:
|
||||
- "9200:9200"
|
||||
volumes:
|
||||
- .:/apps
|
||||
entrypoint: /apps/docker-entrypoint-es-plugins.sh
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/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
|
||||
|
|
|
@ -3,7 +3,7 @@ class ParseableDateValidator < ActiveModel::EachValidator
|
|||
def validate_each(record, attribute, value)
|
||||
raw_value = record.read_attribute_before_type_cast(attribute)
|
||||
return nil if raw_value.nil?
|
||||
Date.parse(raw_value)
|
||||
Date.parse(raw_value.to_json)
|
||||
nil
|
||||
rescue ArgumentError => e
|
||||
record.errors[attribute] << (options[:message] || I18n.t("errors.messages.unparseable_date"))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require_relative '../factory_helper'
|
||||
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory :paper do
|
||||
name { Faker::Lorem.sentence }
|
||||
sequence(:url) { |n| Faker::Internet.url("ris.example.org", "/paper-#{n}.html") }
|
||||
|
|
|
@ -4,7 +4,7 @@ require 'pp'
|
|||
RSpec.feature "Basic search", type: :feature, elasticsearch: true do
|
||||
|
||||
before(:each) do
|
||||
@papers = FactoryGirl.create_list(:paper, 11)
|
||||
@papers = FactoryBot.create_list(:paper, 11)
|
||||
Paper.__elasticsearch__.refresh_index!
|
||||
end
|
||||
|
||||
|
@ -63,7 +63,7 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
|
|||
end
|
||||
|
||||
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!
|
||||
visit search_path body: "leipzig", paper_search: {query: "Opendata"}
|
||||
expect(page).to have_content("1 Dokument in der Datenbank")
|
||||
|
@ -76,7 +76,7 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
|
|||
end
|
||||
|
||||
scenario "Finds papers by content" do
|
||||
paper = FactoryGirl.create(:paper,
|
||||
paper = FactoryBot.create(:paper,
|
||||
name: "Opendata als default",
|
||||
content: "Alle Verwaltungsdokumente werden als Opendata veröffentlicht"
|
||||
)
|
||||
|
@ -92,9 +92,9 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
|
|||
end
|
||||
|
||||
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")
|
||||
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")
|
||||
Paper.__elasticsearch__.refresh_index!
|
||||
visit search_path body: "leipzig", paper_search: {query: "default"}
|
||||
|
@ -112,11 +112,11 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
|
|||
end
|
||||
|
||||
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")
|
||||
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")
|
||||
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")
|
||||
Paper.__elasticsearch__.refresh_index!
|
||||
visit search_path body: "leipzig", paper_search: {query: "default"}
|
||||
|
@ -131,11 +131,11 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
|
|||
end
|
||||
|
||||
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")
|
||||
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")
|
||||
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")
|
||||
Paper.__elasticsearch__.refresh_index!
|
||||
visit search_path body: "leipzig", paper_search: {query: "default"}
|
||||
|
@ -150,7 +150,7 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
|
|||
end
|
||||
|
||||
scenario "Finds 'Testen' with search 'Test'" do
|
||||
paper = FactoryGirl.create(:paper, name: "Testen")
|
||||
paper = FactoryBot.create(:paper, name: "Testen")
|
||||
Paper.__elasticsearch__.refresh_index!
|
||||
visit search_path body: "leipzig", paper_search: {query: "Test"}
|
||||
expect(page).to have_content("1 Dokument in der Datenbank")
|
||||
|
@ -159,7 +159,7 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
|
|||
end
|
||||
|
||||
scenario "Finds 'Test' with search 'Testen'" do
|
||||
paper = FactoryGirl.create(:paper, name: "Test")
|
||||
paper = FactoryBot.create(:paper, name: "Test")
|
||||
Paper.__elasticsearch__.refresh_index!
|
||||
visit search_path body: "leipzig", paper_search: {query: "Testen"}
|
||||
expect(page).to have_content("1 Dokument in der Datenbank")
|
||||
|
@ -168,7 +168,7 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
|
|||
end
|
||||
|
||||
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!
|
||||
visit search_path body: "leipzig", paper_search: {query: "Fahrrad"}
|
||||
expect(page).to have_content("1 Dokument in der Datenbank")
|
||||
|
@ -177,7 +177,7 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
|
|||
end
|
||||
|
||||
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!
|
||||
visit search_path body: "leipzig", paper_search: {query: "Fahrräder"}
|
||||
expect(page).to have_content("1 Dokument in der Datenbank")
|
||||
|
@ -186,7 +186,7 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
|
|||
end
|
||||
|
||||
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!
|
||||
visit search_path body: "leipzig", paper_search: {query: "Verleih"}
|
||||
expect(page).to have_content("1 Dokument in der Datenbank")
|
||||
|
@ -195,7 +195,7 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
|
|||
end
|
||||
|
||||
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!
|
||||
visit search_path body: "leipzig", paper_search: {query: "Autoverleih"}
|
||||
expect(page).to have_content("1 Dokument in der Datenbank")
|
||||
|
@ -204,16 +204,16 @@ RSpec.feature "Basic search", type: :feature, elasticsearch: true do
|
|||
end
|
||||
|
||||
scenario "Finds no 'Fahrrad' with search 'Rad'" do
|
||||
paper = FactoryGirl.create(:paper, name: "Fahrrad")
|
||||
paper = FactoryBot.create(:paper, name: "Fahrrad")
|
||||
Paper.__elasticsearch__.refresh_index!
|
||||
visit search_path body: "leipzig", paper_search: {query: "Rad"}
|
||||
expect(page).to have_content("0 Dokumente in der Datenbank")
|
||||
end
|
||||
|
||||
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")
|
||||
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")
|
||||
Paper.__elasticsearch__.refresh_index!
|
||||
visit search_path body: "leipzig", paper_search: {query: "default"}
|
||||
|
|
|
@ -3,21 +3,21 @@ require 'rails_helper'
|
|||
RSpec.feature "Search filters", type: :feature, elasticsearch: true do
|
||||
|
||||
before(:each) do
|
||||
@antrag = FactoryGirl.create(:paper,
|
||||
@antrag = FactoryBot.create(:paper,
|
||||
paper_type: "Antrag",
|
||||
name: "Mehr Spielplätze in Leipzig",
|
||||
originator: "Dezernat Jugend, Soziales, Gesundheit und Schule"
|
||||
)
|
||||
@anfrage = FactoryGirl.create(:paper,
|
||||
@anfrage = FactoryBot.create(:paper,
|
||||
paper_type: "Anfrage",
|
||||
originator: "CDU-Fraktion"
|
||||
)
|
||||
@vorlage_1 = FactoryGirl.create(:paper,
|
||||
@vorlage_1 = FactoryBot.create(:paper,
|
||||
paper_type: "Vorlage",
|
||||
name: "Zustand der Spielplätze",
|
||||
originator: "Dezernat Jugend, Soziales, Gesundheit und Schule"
|
||||
)
|
||||
@vorlage_2 = FactoryGirl.create(:paper,
|
||||
@vorlage_2 = FactoryBot.create(:paper,
|
||||
paper_type: "Vorlage",
|
||||
name: "Mehr Ampeln in der Innenstadt",
|
||||
originator: "Oberbürgermeister"
|
||||
|
|
|
@ -9,13 +9,13 @@ RSpec.describe Paper do
|
|||
it { should validate_length_of(:url).is_at_most(1000) }
|
||||
|
||||
context "URL uniqueness" do
|
||||
subject { FactoryGirl.build(:paper) }
|
||||
subject { FactoryBot.build(:paper) }
|
||||
it { should validate_uniqueness_of(:url) }
|
||||
end
|
||||
|
||||
it "validate url format sane" do
|
||||
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.errors[:url]).not_to be_empty
|
||||
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 "validate date is parseable" do
|
||||
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.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}\""
|
||||
|
|
3
spec/support/factory_bot.rb
Normal file
3
spec/support/factory_bot.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
RSpec.configure do |config|
|
||||
config.include FactoryBot::Syntax::Methods
|
||||
end
|
|
@ -1,3 +0,0 @@
|
|||
RSpec.configure do |config|
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
end
|
|
@ -9,12 +9,12 @@ class PaperTest < ActiveSupport::TestCase
|
|||
should validate_presence_of(:url)
|
||||
should validate_length_of(:url).is_at_most(1000)
|
||||
context "URL uniqueness" do
|
||||
subject { FactoryGirl.build(:paper) }
|
||||
subject { FactoryBot.build(:paper) }
|
||||
should validate_uniqueness_of(:url)
|
||||
end
|
||||
should "validate url format sane" do
|
||||
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.errors[:url].empty?
|
||||
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 date is parseable" do
|
||||
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.errors[:published_at].empty?
|
||||
assert paper.errors[:published_at].include?(expected_error), "Expected #{paper.errors[:published_at]} to include \"#{expected_error}\""
|
||||
|
|
Loading…
Reference in a new issue