diff --git a/Gemfile b/Gemfile index d9738fd3a..03e30eadd 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' ruby '2.4.2' -gem 'rails', '~> 5.0' +gem 'rails', '5.1.4' gem 'scrivito' gem 'scrivito_section_widgets' @@ -34,6 +34,7 @@ gem 'faraday_middleware', '0.10' group :development do gem 'web-console' gem 'spring' + gem 'listen' end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 48ecc83bf..61f147006 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,216 +1,233 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.0.1) - actionpack (= 5.0.1) - nio4r (~> 1.2) + actioncable (5.1.4) + actionpack (= 5.1.4) + nio4r (~> 2.0) websocket-driver (~> 0.6.1) - actionmailer (5.0.1) - actionpack (= 5.0.1) - actionview (= 5.0.1) - activejob (= 5.0.1) + actionmailer (5.1.4) + actionpack (= 5.1.4) + actionview (= 5.1.4) + activejob (= 5.1.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.0.1) - actionview (= 5.0.1) - activesupport (= 5.0.1) + actionpack (5.1.4) + actionview (= 5.1.4) + activesupport (= 5.1.4) rack (~> 2.0) - rack-test (~> 0.6.3) + rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.0.1) - activesupport (= 5.0.1) + actionview (5.1.4) + activesupport (= 5.1.4) builder (~> 3.1) - erubis (~> 2.7.0) + erubi (~> 1.4) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (5.0.1) - activesupport (= 5.0.1) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.1.4) + activesupport (= 5.1.4) globalid (>= 0.3.6) - activemodel (5.0.1) - activesupport (= 5.0.1) - activerecord (5.0.1) - activemodel (= 5.0.1) - activesupport (= 5.0.1) - arel (~> 7.0) - activesupport (5.0.1) + activemodel (5.1.4) + activesupport (= 5.1.4) + activerecord (5.1.4) + activemodel (= 5.1.4) + activesupport (= 5.1.4) + arel (~> 8.0) + activesupport (5.1.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.4.0) - arel (7.1.4) - autoprefixer-rails (6.7.0) + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) + arel (8.0.0) + autoprefixer-rails (7.1.6) execjs - backports (3.6.8) + backports (3.10.3) + bindex (0.5.0) bootstrap-sass (3.3.7) autoprefixer-rails (>= 5.2.1) sass (>= 3.3.4) builder (3.2.3) - capybara (2.11.0) + capybara (2.15.4) 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) - childprocess (0.5.9) + childprocess (0.8.0) ffi (~> 1.0, >= 1.0.11) - coderay (1.1.1) - coffee-rails (4.2.1) + coderay (1.1.2) + coffee-rails (4.2.2) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.2.x) + railties (>= 4.0.0) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.0.4) + concurrent-ruby (1.0.5) connection_pool (2.2.1) - debug_inspector (0.0.2) - diff-lcs (1.2.5) - erubis (2.7.0) - ethon (0.10.1) + crass (1.0.2) + diff-lcs (1.3) + erubi (1.7.0) + ethon (0.11.0) ffi (>= 1.3.0) execjs (2.7.0) faraday (0.9.2) multipart-post (>= 1.2, < 3) faraday_middleware (0.10.0) faraday (>= 0.7.4, < 0.10) - ffi (1.9.17) - font-awesome-rails (4.7.0.1) - railties (>= 3.2, < 5.1) - gh (0.15.0) - addressable (~> 2.4.0) + ffi (1.9.18) + font-awesome-rails (4.7.0.2) + railties (>= 3.2, < 5.2) + gh (0.14.0) + addressable backports faraday (~> 0.8) multi_json (~> 1.0) - net-http-persistent (~> 2.9) + net-http-persistent (>= 2.7) net-http-pipeline - globalid (0.3.7) - activesupport (>= 4.1.0) + globalid (0.4.1) + activesupport (>= 4.2.0) highline (1.7.8) - hyp_diff (0.0.4) - diff-lcs (~> 1.2.5) - nokogiri (~> 1.6.5) - i18n (0.7.0) - jbuilder (2.6.1) - activesupport (>= 3.0.0, < 5.1) - multi_json (~> 1.2) - jquery-rails (4.2.2) + hyp_diff (0.0.5) + diff-lcs (~> 1.2, >= 1.2.5) + nokogiri (~> 1.6, >= 1.6.5) + i18n (0.9.0) + concurrent-ruby (~> 1.0) + jbuilder (2.7.0) + activesupport (>= 4.2.0) + multi_json (>= 1.2) + jquery-rails (4.3.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) jquery-ui-rails (6.0.1) railties (>= 3.2.16) - json (2.0.3) - kramdown (1.13.2) + json (2.1.0) + kramdown (1.15.0) launchy (2.4.3) addressable (~> 2.3) - loofah (2.0.3) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.1.1) + crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.6.4) + mail (2.6.6) mime-types (>= 1.16, < 4) - memoist (0.15.0) - method_source (0.8.2) + memoist (0.16.0) + method_source (0.9.0) mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) - mini_portile2 (2.1.0) - minitest (5.10.1) - minitest-retry (0.1.8) + mini_mime (0.1.4) + mini_portile2 (2.3.0) + minitest (5.10.3) + minitest-retry (0.1.9) minitest (>= 5.0) - multi_json (1.12.1) + multi_json (1.12.2) multipart-post (2.0.0) - net-http-persistent (2.9.4) + net-http-persistent (3.0.0) + connection_pool (~> 2.2) net-http-pipeline (1.0.1) - nio4r (1.2.1) - nokogiri (1.6.8.1) - mini_portile2 (~> 2.1.0) - pg (0.19.0) - pry (0.10.4) + nio4r (2.1.0) + nokogiri (1.8.1) + mini_portile2 (~> 2.3.0) + pg (0.21.0) + pry (0.11.2) coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - pry-rails (0.3.4) - pry (>= 0.9.10) + method_source (~> 0.9.0) + pry-rails (0.3.6) + pry (>= 0.10.4) + public_suffix (3.0.0) pusher-client (0.6.2) json websocket (~> 1.0) - rack (2.0.1) + rack (2.0.3) rack-host-redirect (1.3.0) rack - rack-test (0.6.3) - rack (>= 1.0) - rails (5.0.1) - actioncable (= 5.0.1) - actionmailer (= 5.0.1) - actionpack (= 5.0.1) - actionview (= 5.0.1) - activejob (= 5.0.1) - activemodel (= 5.0.1) - activerecord (= 5.0.1) - activesupport (= 5.0.1) - bundler (>= 1.3.0, < 2.0) - railties (= 5.0.1) + rack-test (0.7.0) + rack (>= 1.0, < 3) + rails (5.1.4) + actioncable (= 5.1.4) + actionmailer (= 5.1.4) + actionpack (= 5.1.4) + actionview (= 5.1.4) + activejob (= 5.1.4) + activemodel (= 5.1.4) + activerecord (= 5.1.4) + activesupport (= 5.1.4) + bundler (>= 1.3.0) + railties (= 5.1.4) sprockets-rails (>= 2.0.0) - rails-controller-testing (1.0.1) - actionpack (~> 5.x) - actionview (~> 5.x) + 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.2) - activesupport (>= 4.2.0, < 6.0) - nokogiri (~> 1.6) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) rails-html-sanitizer (1.0.3) loofah (~> 2.0) - railties (5.0.1) - actionpack (= 5.0.1) - activesupport (= 5.0.1) + railties (5.1.4) + actionpack (= 5.1.4) + activesupport (= 5.1.4) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (12.0.0) - rspec-core (3.5.4) - rspec-support (~> 3.5.0) - rspec-expectations (3.5.0) + rake (12.2.1) + rb-fsevent (0.10.2) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) + rspec-core (3.7.0) + rspec-support (~> 3.7.0) + rspec-expectations (3.7.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) - rspec-mocks (3.5.0) + rspec-support (~> 3.7.0) + rspec-mocks (3.7.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) - rspec-rails (3.5.2) + rspec-support (~> 3.7.0) + rspec-rails (3.7.1) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 3.5.0) - rspec-expectations (~> 3.5.0) - rspec-mocks (~> 3.5.0) - rspec-support (~> 3.5.0) - rspec-retry (0.5.3) - rspec-core (> 3.3, < 3.6) - rspec-support (3.5.0) - rubyzip (1.2.0) - sass (3.4.23) + rspec-core (~> 3.7.0) + rspec-expectations (~> 3.7.0) + rspec-mocks (~> 3.7.0) + rspec-support (~> 3.7.0) + rspec-retry (0.5.0) + rspec-core (~> 3.3) + rspec-support (3.7.0) + ruby_dep (1.5.0) + rubyzip (1.2.1) + sass (3.5.3) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) sass-rails (5.0.6) railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - scrivito (1.7.0) - railties - scrivito_content_browser (= 1.7.0) - scrivito_editors (= 1.7.0) - scrivito_sdk (= 1.7.0) - scrivito_ui (= 1.7.0) - scrivito_content_browser (1.7.0) + scrivito (1.11.0) + scrivito_content_browser (= 1.11.0) + scrivito_editors (= 1.11.0) + scrivito_sdk (= 1.11.0) + scrivito_ui (= 1.11.0) + scrivito_content_browser (1.11.0) railties - scrivito_sdk (= 1.7.0) - scrivito_editors (1.7.0) + scrivito_sdk (= 1.11.0) + scrivito_editors (1.11.0) jquery-ui-rails (>= 5.0.0, < 7.0.0) railties - scrivito_content_browser (= 1.7.0) - scrivito_sdk (= 1.7.0) - scrivito_sdk (1.7.0) + scrivito_content_browser (= 1.11.0) + scrivito_sdk (= 1.11.0) + scrivito_sdk (1.11.0) addressable (~> 2.3) connection_pool (~> 2.2) diff-lcs (~> 1.2) @@ -218,38 +235,37 @@ GEM jbuilder (~> 2.0) json (>= 1.8.3) memoist (>= 0.12.0) + multi_json (~> 1.9) multipart-post (~> 2.0) nokogiri (~> 1.6) - rails (>= 4.2, < 5.1) + rails (>= 4.2, < 5.2) rake (>= 0.9.2.2) - scrivito_section_widgets (1.0.4) + scrivito_section_widgets (1.1.2) scrivito scrivito_teaser_widget (0.1.2) scrivito - scrivito_ui (1.7.0) + scrivito_ui (1.11.0) railties - secure_headers (3.6.1) - useragent - selenium-webdriver (3.0.5) + secure_headers (5.0.1) + useragent (>= 0.15.0) + selenium-webdriver (3.6.0) childprocess (~> 0.5) rubyzip (~> 1.0) - websocket (~> 1.0) simple_grid_rails (0.1.0) - slop (3.6.0) - spring (2.0.1) + spring (2.0.2) activesupport (>= 4.2) sprockets (3.7.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.0) + sprockets-rails (3.2.1) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) sqlite3 (1.3.13) - thor (0.19.4) - thread_safe (0.3.5) - tilt (2.0.5) - travis (1.8.5) + thor (0.20.0) + thread_safe (0.3.6) + tilt (2.0.8) + travis (1.8.8) backports faraday (~> 0.9) faraday_middleware (~> 0.9, >= 0.9.1) @@ -260,21 +276,21 @@ GEM typhoeus (~> 0.6, >= 0.6.8) typhoeus (0.8.0) ethon (>= 0.8.0) - tzinfo (1.2.2) + tzinfo (1.2.4) thread_safe (~> 0.1) - uglifier (3.0.4) + uglifier (3.2.0) execjs (>= 0.3.0, < 3) useragent (0.16.8) - web-console (3.4.0) + web-console (3.5.1) actionview (>= 5.0) activemodel (>= 5.0) - debug_inspector + bindex (>= 0.4.0) railties (>= 5.0) - websocket (1.2.3) + websocket (1.2.4) websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.2) - xpath (2.0.0) + xpath (2.1.0) nokogiri (~> 1.3) PLATFORMS @@ -290,11 +306,12 @@ DEPENDENCIES jbuilder jquery-rails kramdown + listen minitest-retry pg pry-rails rack-host-redirect - rails (~> 5.0) + rails (= 5.1.4) rails-controller-testing rake rspec-rails (~> 3.5) diff --git a/app/controllers/scrivito_controller.rb b/app/controllers/scrivito_controller.rb index a559904e3..f632752e3 100644 --- a/app/controllers/scrivito_controller.rb +++ b/app/controllers/scrivito_controller.rb @@ -2,9 +2,6 @@ class ScrivitoController < ApplicationController include Scrivito::ControllerActions - # TODO: There may be smarter detection - USING_SCRIVITO = true - title ||= ENV['SCRIVITO_WORKSPACE'] || 'DEFAULT_WORKSPACE' Scrivito::Workspace.create(title: title) unless Scrivito::Workspace.find_by_title(title) Scrivito::Workspace.use(title) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 958f56cda..b0768f9b3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -32,7 +32,6 @@ def kata_description end def using_scrivito? - # TODO: There may be smarter detection - USING_SCRIVITO + !@obj.nil? end end diff --git a/app/models/dojo.rb b/app/models/dojo.rb index 1a60d1464..223bfb08a 100644 --- a/app/models/dojo.rb +++ b/app/models/dojo.rb @@ -3,8 +3,8 @@ class Dojo < ApplicationRecord NUM_OF_WHOLE_DOJOS = "1,400" NUM_OF_JAPAN_DOJOS = Dojo.count.to_s - has_one :dojo_event_service - has_many :event_histories + has_one :dojo_event_service, dependent: :destroy + has_many :event_histories, dependent: :destroy serialize :tags default_scope -> { order(order: :asc) } diff --git a/bin/setup b/bin/setup index e620b4dad..78c4e861d 100755 --- a/bin/setup +++ b/bin/setup @@ -18,6 +18,10 @@ chdir APP_ROOT do system! 'gem install bundler --conservative' system('bundle check') || system!('bundle install') + # 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' diff --git a/bin/yarn b/bin/yarn new file mode 100755 index 000000000..c2bacef83 --- /dev/null +++ b/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +VENDOR_PATH = File.expand_path('..', __dir__) +Dir.chdir(VENDOR_PATH) do + begin + exec "yarnpkg #{ARGV.join(" ")}" + 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 diff --git a/config/application.rb b/config/application.rb index c8ed62753..750b16ff7 100644 --- a/config/application.rb +++ b/config/application.rb @@ -8,6 +8,9 @@ module CoderdojoJp class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.1 + # 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. diff --git a/config/cable.yml b/config/cable.yml index 0bbde6f74..2a9777c28 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -7,3 +7,4 @@ test: production: adapter: redis url: redis://localhost:6379/1 + channel_prefix: coderdojo_jp_production diff --git a/config/environments/development.rb b/config/environments/development.rb index e64889cdb..5187e2218 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -18,7 +18,7 @@ config.cache_store = :memory_store config.public_file_server.headers = { - 'Cache-Control' => 'public, max-age=172800' + 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}" } else config.action_controller.perform_caching = false @@ -50,5 +50,5 @@ # 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.file_watcher = ActiveSupport::EventedFileUpdateChecker end diff --git a/config/environments/production.rb b/config/environments/production.rb index af3396254..e83fe9553 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -14,6 +14,11 @@ config.consider_all_requests_local = false config.action_controller.perform_caching = true + # Attempt to read encrypted secrets from `config/secrets.yml.enc`. + # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or + # `config/secrets.yml.key`. + config.read_encrypted_secrets = true + # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? diff --git a/config/environments/test.rb b/config/environments/test.rb index 30587ef6d..8e5cbde53 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -15,7 +15,7 @@ # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - 'Cache-Control' => 'public, max-age=3600' + 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}" } # Show full error reports and disable caching. diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 01ef3e663..4b828e80c 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -3,9 +3,12 @@ # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' -# Add additional assets to the asset load path +# Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') # Precompile additional assets. -# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. -# Rails.application.config.assets.precompile += %w( search.js ) +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/config/initializers/csp.rb b/config/initializers/csp.rb index 2b722f709..c044a411e 100644 --- a/config/initializers/csp.rb +++ b/config/initializers/csp.rb @@ -1,13 +1,15 @@ SecureHeaders::Configuration.default do |config| + src = %w(* 'unsafe-inline' 'unsafe-eval' data: + *.google-analytics.com *.googleapis.com *.google.com *.gstatic.com + *.facebook.net *.facebook.com *.twitter.com + *.hatena.ne.jp *.st-hatena.com + *.slidesharecdn.com *.slideshare.net) config.csp = { report_only: Rails.env.production?, # default: false preserve_schemes: true, # default: false. - default_src: %w(* 'unsafe-inline' 'unsafe-eval' data: -*.google-analytics.com *.googleapis.com *.google.com *.gstatic.com -*.facebook.net *.facebook.com *.twitter.com -*.hatena.ne.jp *.st-hatena.com -*.slidesharecdn.com *.slideshare.net), + default_src: src, + script_src: src, report_uri: ["/csp_report?report_only=#{Rails.env.production?}"] } end diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb index 829206f09..b4f222bf9 100644 --- a/config/initializers/new_framework_defaults.rb +++ b/config/initializers/new_framework_defaults.rb @@ -18,6 +18,3 @@ # Require `belongs_to` associations by default. Previous versions had false. Rails.application.config.active_record.belongs_to_required_by_default = false - -# Do not halt callback chains when a callback returns false. Previous versions had true. -ActiveSupport.halt_callback_chains_on_return_false = true diff --git a/config/initializers/new_framework_defaults_5_1.rb b/config/initializers/new_framework_defaults_5_1.rb new file mode 100644 index 000000000..9010abd5c --- /dev/null +++ b/config/initializers/new_framework_defaults_5_1.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 5.1 upgrade. +# +# Once upgraded flip defaults one by one to migrate to the new default. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Make `form_with` generate non-remote forms. +Rails.application.config.action_view.form_with_generates_remote_forms = false + +# Unknown asset fallback will return the path passed in when the given +# asset is not present in the asset pipeline. +# Rails.application.config.assets.unknown_asset_fallback = false diff --git a/config/locales/en.yml b/config/locales/en.yml index 065395716..decc5a857 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -16,6 +16,16 @@ # # This would use the information in config/locales/es.yml. # +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# # To learn more, please read the Rails Internationalization guide # available at http://guides.rubyonrails.org/i18n.html. diff --git a/config/puma.rb b/config/puma.rb index c7f311f81..1e19380dc 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,13 +1,13 @@ # Puma can serve each request in a thread from an internal thread pool. -# The `threads` method setting takes two numbers a minimum and maximum. +# The `threads` method setting takes two numbers: a minimum and maximum. # Any libraries that use thread pools should be configured to match # the maximum value specified for Puma. Default is set to 5 threads for minimum -# and maximum, this matches the default thread size of Active Record. +# and maximum; this matches the default thread size of Active Record. # -threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } threads threads_count, threads_count -# Specifies the `port` that Puma will listen on to receive requests, default is 3000. +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. # port ENV.fetch("PORT") { 3000 } @@ -32,16 +32,25 @@ # # preload_app! +# If you are preloading your application and using Active Record, it's +# recommended that you close any connections to the database before workers +# are forked to prevent connection leakage. +# +# before_fork do +# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) +# end + # The code in the `on_worker_boot` will be called if you are using # clustered mode by specifying a number of `workers`. After each worker -# process is booted this block will be run, if you are using `preload_app!` -# option you will want to use this block to reconnect to any threads -# or connections that may have been created at application boot, Ruby +# process is booted, this block will be run. If you are using the `preload_app!` +# option, you will want to use this block to reconnect to any threads +# or connections that may have been created at application boot, as Ruby # cannot share connections between processes. # # on_worker_boot do # ActiveRecord::Base.establish_connection if defined?(ActiveRecord) # end +# # Allow puma to be restarted by `rails restart` command. plugin :tmp_restart diff --git a/config/routes.rb b/config/routes.rb index c1eefa2e2..ef43b4e46 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,7 @@ Rails.application.routes.draw do + # For details on the DSL available within this file, + # see http://guides.rubyonrails.org/routing.html + # Render legal documents by using Keiyaku CSS # https://github.com/cognitom/keiyaku-css resources :docs, only: [:index, :show] @@ -19,6 +22,7 @@ # Default Scrivito routes. Adapt them to change the routing of CMS objects. # See the documentation of 'scrivito_route' for a detailed description. + scrivito_route '/', using: 'homepage' scrivito_route '(/)(*slug-):id', using: 'slug_id' scrivito_route '/*permalink', using: 'permalink', format: false end diff --git a/config/secrets.yml b/config/secrets.yml index 2ab5b3eb9..ce3de6e05 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -10,13 +10,23 @@ # Make sure the secrets in this file are kept private # if you're sharing your code publicly. +# Shared secrets are available across all environments. + +# shared: +# api_key: a1B2c3D4e5F6 + +# Environmental secrets are only available for that specific environment. + development: secret_key_base: f13391f8ba6e82c764042e47b7663e9626aec759127b17c9b99a21131d44da1de8eb9e1c9c7d247cf71d5dc623824e80b7877c06bb054d147ecce7cf47fe7eb4 test: secret_key_base: 7ba3d6d2a7c7089b9ec2d21821c88cef5801cf32e4f9c4c0908456c3319d3bd651c8601b04625c2a03d3c16d1eb37833f1ae23a34586352eb6ab9d06999af583 -# Do not keep production secrets in the repository, -# instead read values from the environment. +# Do not keep production secrets in the unencrypted secrets file. +# Instead, either read values from the environment. +# Or, use `bin/rails secrets:setup` to configure encrypted secrets +# and move the `production:` environment over there. + production: secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/db/migrate/20161217063010_create_dojos.rb b/db/migrate/20161217063010_create_dojos.rb index b87846124..84687eb29 100644 --- a/db/migrate/20161217063010_create_dojos.rb +++ b/db/migrate/20161217063010_create_dojos.rb @@ -1,4 +1,4 @@ -class CreateDojos < ActiveRecord::Migration +class CreateDojos < ActiveRecord::Migration[4.2] def change create_table :dojos do |t| t.string :name diff --git a/spec/controllers/blog_post_page_controller_spec.rb b/spec/controllers/blog_post_page_controller_spec.rb index 1c2d07e66..01a2db71b 100644 --- a/spec/controllers/blog_post_page_controller_spec.rb +++ b/spec/controllers/blog_post_page_controller_spec.rb @@ -3,7 +3,7 @@ RSpec.describe BlogPostPageController, type: :controller do render_views - xdescribe "GET Blog Post Page" do + describe "GET Blog Post Page" do it "normal blog post" do obj = Obj.find_by_permalink!("news/2016/12/12/new-backend") request.for_scrivito_obj(obj) diff --git a/spec/controllers/sotechsha_overview_page_controller_spec.rb b/spec/controllers/sotechsha_overview_page_controller_spec.rb index 60ad67965..91436f82c 100644 --- a/spec/controllers/sotechsha_overview_page_controller_spec.rb +++ b/spec/controllers/sotechsha_overview_page_controller_spec.rb @@ -3,7 +3,7 @@ RSpec.describe SotechshaOverviewPageController, type: :controller do render_views - xdescribe "GET #index" do + describe "GET #index" do it "set @sts_post" do obj = Obj.find_by_permalink!("sotechsha") request.for_scrivito_obj(obj) diff --git a/spec/helpers/static_pages_helper_spec.rb b/spec/helpers/static_pages_helper_spec.rb deleted file mode 100644 index 85e454247..000000000 --- a/spec/helpers/static_pages_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the StaticPagesHelper. For example: -# -# describe StaticPagesHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe StaticPagesHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/lib/statistics/aggregation_spec.rb b/spec/lib/statistics/aggregation_spec.rb index 37a20aa23..92fa272e1 100644 --- a/spec/lib/statistics/aggregation_spec.rb +++ b/spec/lib/statistics/aggregation_spec.rb @@ -5,15 +5,11 @@ include_context 'Use stubs for Faraday' before(:all) do - Dojo.delete_all - DojoEventService.delete_all - EventHistory.delete_all + Dojo.destroy_all end after do - Dojo.delete_all - DojoEventService.delete_all - EventHistory.delete_all + Dojo.destroy_all end describe '.run' do diff --git a/spec/views/static_pages/home.html.erb_spec.rb b/spec/views/static_pages/home.html.erb_spec.rb deleted file mode 100644 index f6e388f1b..000000000 --- a/spec/views/static_pages/home.html.erb_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe "static_pages/home.html.erb", type: :view do - pending "add some examples to (or delete) #{__FILE__}" -end