Skip to content

Commit fdead5a

Browse files
committed
Upgrade bundled dummy app to Rails 5.2
1 parent 38c5690 commit fdead5a

14 files changed

Lines changed: 160 additions & 28 deletions

spec/dummy/bin/setup

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#!/usr/bin/env ruby
2-
require 'pathname'
32
require 'fileutils'
43
include FileUtils
54

65
# path to your application root.
7-
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6+
APP_ROOT = File.expand_path('..', __dir__)
87

98
def system!(*args)
109
system(*args) || abort("\n== Command #{args} failed ==")
@@ -18,6 +17,9 @@ chdir APP_ROOT do
1817
system! 'gem install bundler --conservative'
1918
system('bundle check') || system!('bundle install')
2019

20+
# Install JavaScript dependencies if using Yarn
21+
# system('bin/yarn')
22+
2123
# puts "\n== Copying sample files =="
2224
# unless File.exist?('config/database.yml')
2325
# cp 'config/database.yml.sample', 'config/database.yml'

spec/dummy/bin/update

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#!/usr/bin/env ruby
2-
require 'pathname'
32
require 'fileutils'
43
include FileUtils
54

65
# path to your application root.
7-
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6+
APP_ROOT = File.expand_path('..', __dir__)
87

98
def system!(*args)
109
system(*args) || abort("\n== Command #{args} failed ==")
@@ -18,6 +17,9 @@ chdir APP_ROOT do
1817
system! 'gem install bundler --conservative'
1918
system('bundle check') || system!('bundle install')
2019

20+
# Install JavaScript dependencies if using Yarn
21+
# system('bin/yarn')
22+
2123
puts "\n== Updating database =="
2224
system! 'bin/rails db:migrate'
2325

spec/dummy/config/application.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
require_relative 'boot'
22

3+
require "rails"
34
# Pick the frameworks you want:
5+
require "active_model/railtie"
6+
# require "active_job/railtie"
47
require "active_record/railtie"
8+
# require "active_storage/engine"
59
require "action_controller/railtie"
610
require "action_mailer/railtie"
711
require "action_view/railtie"
8-
require "sprockets/railtie"
9-
# require "active_job/railtie"
1012
# require "action_cable/engine"
13+
require "sprockets/railtie"
1114
# require "rails/test_unit/railtie"
1215

1316
# Require the gems listed in Gemfile, including any gems
@@ -21,7 +24,8 @@ class Application < Rails::Application
2124
config.load_defaults 5.1
2225

2326
# Settings in config/environments/* take precedence over those specified here.
24-
# Application configuration should go into files in config/initializers
25-
# -- all .rb files in that directory are automatically loaded.
27+
# Application configuration can go into files in config/initializers
28+
# -- all .rb files in that directory are automatically loaded after loading
29+
# the framework and any gems in your application.
2630
end
2731
end

spec/dummy/config/boot.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Set up gems listed in the Gemfile.
21
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
32

4-
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5-
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
3+
require 'bundler/setup' # Set up gems listed in the Gemfile.

spec/dummy/config/environments/development.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,23 @@
1313
config.consider_all_requests_local = true
1414

1515
# Enable/disable caching. By default caching is disabled.
16-
if Rails.root.join('tmp/caching-dev.txt').exist?
16+
# Run rails dev:cache to toggle caching.
17+
if Rails.root.join('tmp', 'caching-dev.txt').exist?
1718
config.action_controller.perform_caching = true
1819

1920
config.cache_store = :memory_store
2021
config.public_file_server.headers = {
21-
'Cache-Control' => 'public, max-age=172800'
22+
'Cache-Control' => "public, max-age=#{2.days.to_i}"
2223
}
2324
else
2425
config.action_controller.perform_caching = false
2526

2627
config.cache_store = :null_store
2728
end
2829

30+
# Store uploaded files on the local file system (see config/storage.yml for options)
31+
# config.active_storage.service = :local
32+
2933
# Don't care if the mailer can't send.
3034
config.action_mailer.raise_delivery_errors = false
3135

@@ -37,6 +41,9 @@
3741
# Raise an error on page load if there are pending migrations.
3842
config.active_record.migration_error = :page_load
3943

44+
# Highlight code that triggered database queries in logs.
45+
config.active_record.verbose_query_logs = true
46+
4047
# Debug mode disables concatenation and preprocessing of assets.
4148
# This option may cause significant delays in view rendering with a large
4249
# number of complex assets.
@@ -50,5 +57,5 @@
5057

5158
# Use an evented file watcher to asynchronously detect changes in source code,
5259
# routes, locales, etc. This feature depends on the listen gem.
53-
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
60+
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
5461
end

spec/dummy/config/environments/production.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
config.consider_all_requests_local = false
1515
config.action_controller.perform_caching = true
1616

17+
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
18+
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
19+
# config.require_master_key = true
20+
1721
# Disable serving static files from the `/public` folder by default since
1822
# Apache or NGINX already handles this.
1923
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
@@ -34,10 +38,8 @@
3438
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
3539
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
3640

37-
# Mount Action Cable outside main process or domain
38-
# config.action_cable.mount_path = nil
39-
# config.action_cable.url = 'wss://example.com/cable'
40-
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
41+
# Store uploaded files on the local file system (see config/storage.yml for options)
42+
# config.active_storage.service = :local
4143

4244
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
4345
# config.force_ssl = true
@@ -55,6 +57,7 @@
5557
# Use a real queuing backend for Active Job (and separate queues per environment)
5658
# config.active_job.queue_adapter = :resque
5759
# config.active_job.queue_name_prefix = "dummy_#{Rails.env}"
60+
5861
config.action_mailer.perform_caching = false
5962

6063
# Ignore bad email addresses and do not raise email delivery errors.
@@ -78,7 +81,7 @@
7881
if ENV["RAILS_LOG_TO_STDOUT"].present?
7982
logger = ActiveSupport::Logger.new(STDOUT)
8083
logger.formatter = config.log_formatter
81-
config.logger = ActiveSupport::TaggedLogging.new(logger)
84+
config.logger = ActiveSupport::TaggedLogging.new(logger)
8285
end
8386

8487
# Do not dump schema after migrations.

spec/dummy/config/environments/test.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Configure public file server for tests with Cache-Control for performance.
1616
config.public_file_server.enabled = true
1717
config.public_file_server.headers = {
18-
'Cache-Control' => 'public, max-age=3600'
18+
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
1919
}
2020

2121
# Show full error reports and disable caching.
@@ -27,6 +27,10 @@
2727

2828
# Disable request forgery protection in test environment.
2929
config.action_controller.allow_forgery_protection = false
30+
31+
# Store uploaded files on the local file system in a temporary directory
32+
# config.active_storage.service = :test
33+
3034
config.action_mailer.perform_caching = false
3135

3236
# Tell Action Mailer not to deliver emails to the real world.
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Be sure to restart your server when you modify this file.
22

3-
# ApplicationController.renderer.defaults.merge!(
4-
# http_host: 'example.org',
5-
# https: false
6-
# )
3+
# ActiveSupport::Reloader.to_prepare do
4+
# ApplicationController.renderer.defaults.merge!(
5+
# http_host: 'example.org',
6+
# https: false
7+
# )
8+
# end

spec/dummy/config/initializers/assets.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
# Version of your assets, change this if you want to expire all your assets.
44
Rails.application.config.assets.version = '1.0'
55

6-
# Add additional assets to the asset load path
6+
# Add additional assets to the asset load path.
77
# Rails.application.config.assets.paths << Emoji.images_path
8+
# Add Yarn node_modules folder to the asset load path.
9+
Rails.application.config.assets.paths << Rails.root.join('node_modules')
810

911
# Precompile additional assets.
10-
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11-
# Rails.application.config.assets.precompile += %w( search.js )
12+
# application.js, application.css, and all non-JS/CSS in the app/assets
13+
# folder are already added.
14+
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Be sure to restart your server when you modify this file.
2+
3+
# Define an application-wide content security policy
4+
# For further information see the following documentation
5+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
6+
7+
# Rails.application.config.content_security_policy do |policy|
8+
# policy.default_src :self, :https
9+
# policy.font_src :self, :https, :data
10+
# policy.img_src :self, :https, :data
11+
# policy.object_src :none
12+
# policy.script_src :self, :https
13+
# policy.style_src :self, :https
14+
15+
# # Specify URI for violation reports
16+
# # policy.report_uri "/csp-violation-report-endpoint"
17+
# end
18+
19+
# If you are using UJS then enable automatic nonce generation
20+
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
21+
22+
# Report CSP violations to a specified URI
23+
# For further information see the following documentation:
24+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
25+
# Rails.application.config.content_security_policy_report_only = true

0 commit comments

Comments
 (0)