Commit b816663f authored by Nina's avatar Nina

Merge branch 'rails-5.x' into 'master'

Upgrade to Rails 5.x

See merge request !66
parents 9c13726b 37f56ce9
Pipeline #36317 passed with stages
in 3 minutes and 46 seconds
......@@ -48,9 +48,6 @@ codespell:
- codespell -q 2 -f -I utils/ci/codespell/ignored_words.txt -S turing-questions.yml,de.yml,es.yml,vendor
stage: static
ruby:2.3:
image: ruby:2.3
<<: *test_ruby
ruby:2.4:
image: ruby:2.4
<<: *test_ruby
......
source 'https://rubygems.org'
gem 'rake'
gem 'rails', '~> 4.2'
gem 'rails', '~> 5.2.0'
gem 'bootsnap'
gem 'bcrypt', '~> 3.1'
gem 'activeresource', '~> 4.0'
gem 'haml-rails', '~> 1.0.0'
gem 'activeresource', '~> 5.1.0'
gem 'haml-rails', '~> 2.0.0'
gem 'sass-rails', '~> 5.0'
gem 'bootstrap-sass', '~> 3.3'
gem 'simple_form', '~> 3.2'
gem 'simple_form', '~> 5.0.0'
gem 'squire', '~> 1.3'
gem 'cancancan', '~> 1.9'
gem 'cancancan', '~> 3.0.0'
gem 'sqlite3', '~> 1.3.6'
gem 'sqlite3', '~> 1.4.0'
gem 'thin'
gem "activeresource-response"
group :development do
gem 'spring'
gem 'byebug'
gem 'listen'
end
group :development, :test do
......@@ -25,7 +27,7 @@ group :development, :test do
end
group :test do
gem 'capybara', '~> 3.15.0'
gem 'capybara', '~> 3.0'
gem 'factory_bot_rails'
gem 'webmock'
gem 'sinatra'
......
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.11.1)
actionpack (= 4.2.11.1)
actionview (= 4.2.11.1)
activejob (= 4.2.11.1)
actioncable (5.2.4)
actionpack (= 5.2.4)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.4)
actionpack (= 5.2.4)
actionview (= 5.2.4)
activejob (= 5.2.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.11.1)
actionview (= 4.2.11.1)
activesupport (= 4.2.11.1)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-dom-testing (~> 2.0)
actionpack (5.2.4)
actionview (= 5.2.4)
activesupport (= 5.2.4)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.11.1)
activesupport (= 4.2.11.1)
actionview (5.2.4)
activesupport (= 5.2.4)
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.11.1)
activesupport (= 4.2.11.1)
globalid (>= 0.3.0)
activemodel (4.2.11.1)
activesupport (= 4.2.11.1)
activejob (5.2.4)
activesupport (= 5.2.4)
globalid (>= 0.3.6)
activemodel (5.2.4)
activesupport (= 5.2.4)
activemodel-serializers-xml (1.0.2)
activemodel (> 5.x)
activesupport (> 5.x)
builder (~> 3.1)
activerecord (4.2.11.1)
activemodel (= 4.2.11.1)
activesupport (= 4.2.11.1)
arel (~> 6.0)
activeresource (4.1.0)
activemodel (~> 4.0)
activesupport (~> 4.0)
rails-observers (~> 0.1.2)
activeresource-response (1.2.0)
activeresource (>= 3, < 6)
activesupport (4.2.11.1)
i18n (~> 0.7)
activerecord (5.2.4)
activemodel (= 5.2.4)
activesupport (= 5.2.4)
arel (>= 9.0)
activeresource (5.1.0)
activemodel (>= 5.0, < 7)
activemodel-serializers-xml (~> 1.0)
activesupport (>= 5.0, < 7)
activeresource-response (1.4.0)
activeresource (>= 3, < 6.1)
activestorage (5.2.4)
actionpack (= 5.2.4)
activerecord (= 5.2.4)
marcel (~> 0.3.1)
activesupport (5.2.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
arel (6.0.4)
autoprefixer-rails (9.5.1.1)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
arel (9.0.0)
autoprefixer-rails (9.7.3)
execjs
bcrypt (3.1.12)
bcrypt (3.1.13)
bootsnap (1.4.5)
msgpack (~> 1.0)
bootstrap-sass (3.4.1)
autoprefixer-rails (>= 5.2.1)
sassc (>= 2.0.0)
builder (3.2.3)
byebug (11.0.1)
cancancan (1.17.0)
capybara (3.15.1)
cancancan (3.0.1)
capybara (3.29.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (~> 1.2)
regexp_parser (~> 1.5)
xpath (~> 3.2)
concurrent-ruby (1.1.5)
crack (0.4.3)
......@@ -67,100 +80,109 @@ GEM
crass (1.0.5)
daemons (1.3.1)
diff-lcs (1.3)
erubi (1.9.0)
erubis (2.7.0)
eventmachine (1.2.7)
execjs (2.7.0)
factory_bot (5.0.2)
factory_bot (5.1.1)
activesupport (>= 4.2.0)
factory_bot_rails (5.0.2)
factory_bot (~> 5.0.2)
factory_bot_rails (5.1.1)
factory_bot (~> 5.1.0)
railties (>= 4.2.0)
ffi (1.10.0)
ffi (1.11.3)
globalid (0.4.2)
activesupport (>= 4.2.0)
haml (5.1.2)
temple (>= 0.8.0)
tilt
haml-rails (1.0.0)
actionpack (>= 4.0.1)
activesupport (>= 4.0.1)
haml-rails (2.0.1)
actionpack (>= 5.1)
activesupport (>= 5.1)
haml (>= 4.0.6, < 6.0)
html2haml (>= 1.0.1)
railties (>= 4.0.1)
hashdiff (0.3.9)
railties (>= 5.1)
hashdiff (1.0.0)
html2haml (2.2.0)
erubis (~> 2.7.0)
haml (>= 4.0, < 6)
nokogiri (>= 1.6.0)
ruby_parser (~> 3.5)
i18n (0.9.5)
i18n (1.7.0)
concurrent-ruby (~> 1.0)
launchy (2.4.3)
addressable (~> 2.3)
listen (3.2.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.4.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
mini_mime (1.0.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.2)
mimemagic (0.3.3)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.11.3)
minitest (5.13.0)
msgpack (1.3.1)
mustermann (1.0.3)
nio4r (2.5.2)
nokogiri (1.10.7)
mini_portile2 (~> 2.4.0)
public_suffix (3.0.3)
rack (1.6.12)
rack-protection (1.5.5)
public_suffix (4.0.1)
rack (2.0.7)
rack-protection (2.0.7)
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.11.1)
actionmailer (= 4.2.11.1)
actionpack (= 4.2.11.1)
actionview (= 4.2.11.1)
activejob (= 4.2.11.1)
activemodel (= 4.2.11.1)
activerecord (= 4.2.11.1)
activesupport (= 4.2.11.1)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.11.1)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.9)
activesupport (>= 4.2.0, < 5.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
rails-observers (0.1.5)
activemodel (>= 4.0)
railties (4.2.11.1)
actionpack (= 4.2.11.1)
activesupport (= 4.2.11.1)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.4)
actioncable (= 5.2.4)
actionmailer (= 5.2.4)
actionpack (= 5.2.4)
actionview (= 5.2.4)
activejob (= 5.2.4)
activemodel (= 5.2.4)
activerecord (= 5.2.4)
activestorage (= 5.2.4)
activesupport (= 5.2.4)
bundler (>= 1.3.0)
railties (= 5.2.4)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (5.2.4)
actionpack (= 5.2.4)
activesupport (= 5.2.4)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.3.2)
thor (>= 0.19.0, < 2.0)
rake (13.0.1)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
ffi (~> 1.0)
regexp_parser (1.4.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.3)
regexp_parser (1.6.0)
rspec-core (3.9.0)
rspec-support (~> 3.9.0)
rspec-expectations (3.9.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-rails (3.8.2)
rspec-support (~> 3.9.0)
rspec-rails (3.9.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.0)
ruby_parser (3.14.1)
sexp_processor (~> 4.9)
safe_yaml (1.0.5)
......@@ -175,19 +197,18 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sassc (2.0.1)
sassc (2.2.1)
ffi (~> 1.9)
rake
sexp_processor (4.13.0)
simple_form (3.5.1)
actionpack (> 4, < 5.2)
activemodel (> 4, < 5.2)
sinatra (1.4.8)
rack (~> 1.5)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
spring (2.0.2)
activesupport (>= 4.2)
simple_form (5.0.1)
actionpack (>= 5.0)
activemodel (>= 5.0)
sinatra (2.0.7)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.7)
tilt (~> 2.0)
spring (2.1.0)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
......@@ -195,7 +216,7 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
sqlite3 (1.4.1)
squire (1.3.7)
activesupport (>= 3.0.0)
temple (0.8.2)
......@@ -208,10 +229,13 @@ GEM
tilt (2.0.10)
tzinfo (1.2.5)
thread_safe (~> 0.1)
webmock (3.5.1)
webmock (3.7.6)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
hashdiff (>= 0.4.0, < 2.0.0)
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
xpath (3.2.0)
nokogiri (~> 1.8)
......@@ -219,27 +243,29 @@ PLATFORMS
ruby
DEPENDENCIES
activeresource (~> 4.0)
activeresource (~> 5.1.0)
activeresource-response
bcrypt (~> 3.1)
bootsnap
bootstrap-sass (~> 3.3)
byebug
cancancan (~> 1.9)
capybara (~> 3.15.0)
cancancan (~> 3.0.0)
capybara (~> 3.0)
factory_bot_rails
haml-rails (~> 1.0.0)
haml-rails (~> 2.0.0)
launchy
rails (~> 4.2)
listen
rails (~> 5.2.0)
rake
rspec-rails
sass-rails (~> 5.0)
simple_form (~> 3.2)
simple_form (~> 5.0.0)
sinatra
spring
sqlite3 (~> 1.3.6)
sqlite3 (~> 1.4.0)
squire (~> 1.3)
thin
webmock
BUNDLED WITH
1.17.2
2.0.2
class AccountsController < ApplicationController
skip_before_filter :authenticate, only: [:new, :verify, :setup, :create]
skip_before_action :authenticate, only: [:new, :verify, :setup, :create]
skip_load_resource only: [:verify, :setup, :create]
before_filter :validate_turing_answer, only: :verify
before_action :validate_turing_answer, only: :verify
def index
redirect_to root_path
......@@ -42,7 +42,7 @@ class AccountsController < ApplicationController
ac_req = AccountRequest.find_by_token!(params[:token])
if ! ac_req.still_valid?
render text: t(".token_too_old")
render plain: t(".token_too_old")
ac_req.destroy
return
end
......
......@@ -2,8 +2,8 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :authenticate
before_filter :set_locale
before_action :authenticate
before_action :set_locale
load_and_authorize_resource
# ensure authorization is checked.
check_authorization
......
......@@ -2,9 +2,9 @@ class KeysController < ApplicationController
include KeyUpload
skip_load_and_authorize_resource
skip_authorization_check
before_filter :load_list_resource
before_filter :load_subscription_resource, only: [:index, :show, :new]
before_filter :load_key, only: [:show, :destroy]
before_action :load_list_resource
before_action :load_subscription_resource, only: [:index, :show, :new]
before_action :load_key, only: [:show, :destroy]
# TODO: authorize if current_account.subscribed_to?(@list) || current_account.superadmin?
def index
......
class LoginsController < ApplicationController
skip_before_filter :authenticate
skip_before_action :authenticate
skip_load_and_authorize_resource
skip_authorization_check
......
class Account < ActiveRecord::Base
class Account < ApplicationRecord
has_secure_password
validates :email, presence: true, email: true
before_save { email.downcase! }
......
class AccountRequest < ActiveRecord::Base
class AccountRequest < ApplicationRecord
after_initialize :set_token
def set_token
......
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
......@@ -26,6 +26,6 @@ class Base < ActiveResource::Base
end
def self.api_version
get(:version)
get(:version)["version"]
end
end
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
load Gem.bin_path('bundler', 'bundle')
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir APP_ROOT do
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file:
# Add necessary setup steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "== Installing dependencies =="
system "gem install bundler --conservative"
system "bundle check || bundle install --path vendor/bundle"
# Install JavaScript dependencies if using Yarn
# system('bin/yarn')
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# end
puts "\n== Preparing database =="
system "bin/rake db:setup"
system! 'bin/rails db:setup'
puts "\n== Removing old logs and tempfiles =="
system "rm -f log/*"
system "rm -rf tmp/cache"
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system! 'bin/rails restart'
puts "\n== Manual tasks =="
puts "\n* In config/secrets.yml change secret_key_base"
......
#!/usr/bin/env ruby
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a way to update your development environment automatically.
# Add necessary update steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
# Install JavaScript dependencies if using Yarn
# system('bin/yarn')
puts "\n== Updating database =="
system! 'bin/rails db:migrate'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system! 'bin/rails restart'
end
#!/usr/bin/env ruby
APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
begin
exec "yarnpkg", *ARGV
rescue Errno::ENOENT
$stderr.puts "Yarn executable was not detected in the system."
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
exit 1
end
end
require File.expand_path('../boot', __FILE__)
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module SchleuderWeb
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.1
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
require 'openssl'
require 'mail'
require 'bcrypt'
require 'active_resource'
require 'haml-rails'
require 'sass-rails'
require 'bootstrap-sass'
require 'simple_form'
require 'squire'
require 'cancancan'
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
end
end
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
development:
adapter: async
test:
adapter: async
production:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
channel_prefix: schleuder_web_production
# Load the Rails application.
require File.expand_path('../application', __FILE__)
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!
......@@ -9,31 +9,55 @@ Rails.application.configure do
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Show full error reports.
config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join('tmp', 'caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Suppress logger output for asset requests.
config.assets.quiet = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
config.log_level = :debug
end
......@@ -14,13 +14,14 @@ Rails.application.configure do
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).