Skip to content

Commit

Permalink
upgrade rails to 5.1 and run app:update
Browse files Browse the repository at this point in the history
Signed-off-by: Robb Kidd <rkidd@chef.io>
  • Loading branch information
robbkidd committed Jun 23, 2020
1 parent e6ec493 commit 773c483
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 68 deletions.
2 changes: 1 addition & 1 deletion src/supermarket/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source 'https://rubygems.org'
# https://github.com/chef/omnibus-supermarket/blob/master/config/projects/supermarket.rb

gem 'fieri', path: 'engines/fieri'
gem 'rails', '~> 5.0.0'
gem 'rails', '~> 5.1.0'

gem 'omniauth'
gem 'omniauth-chef-oauth2'
Expand Down
91 changes: 46 additions & 45 deletions src/supermarket/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,39 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actioncable (5.0.7.2)
actionpack (= 5.0.7.2)
nio4r (>= 1.2, < 3.0)
actioncable (5.1.7)
actionpack (= 5.1.7)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.7.2)
actionpack (= 5.0.7.2)
actionview (= 5.0.7.2)
activejob (= 5.0.7.2)
actionmailer (5.1.7)
actionpack (= 5.1.7)
actionview (= 5.1.7)
activejob (= 5.1.7)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.7.2)
actionview (= 5.0.7.2)
activesupport (= 5.0.7.2)
actionpack (5.1.7)
actionview (= 5.1.7)
activesupport (= 5.1.7)
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.7.2)
activesupport (= 5.0.7.2)
actionview (5.1.7)
activesupport (= 5.1.7)
builder (~> 3.1)
erubis (~> 2.7.0)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.0.7.2)
activesupport (= 5.0.7.2)
activejob (5.1.7)
activesupport (= 5.1.7)
globalid (>= 0.3.6)
activemodel (5.0.7.2)
activesupport (= 5.0.7.2)
activerecord (5.0.7.2)
activemodel (= 5.0.7.2)
activesupport (= 5.0.7.2)
arel (~> 7.0)
activesupport (5.0.7.2)
activemodel (5.1.7)
activesupport (= 5.1.7)
activerecord (5.1.7)
activemodel (= 5.1.7)
activesupport (= 5.1.7)
arel (~> 8.0)
activesupport (5.1.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
Expand All @@ -54,7 +54,7 @@ GEM
public_suffix (>= 2.0.2, < 4.0)
and_feathers (1.0.0.pre.2)
and_feathers-gzipped_tarball (1.0.0.pre)
arel (7.1.4)
arel (8.0.0)
ast (2.4.0)
aws-sdk (2.9.17)
aws-sdk-resources (= 2.9.17)
Expand Down Expand Up @@ -172,6 +172,7 @@ GEM
dotenv (= 2.2.1)
railties (>= 3.2, < 5.2)
equalizer (0.0.11)
erubi (1.9.0)
erubis (2.7.0)
et-orbi (1.1.5)
tzinfo
Expand Down Expand Up @@ -268,7 +269,7 @@ GEM
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.5.0)
loofah (2.6.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lumberjack (1.0.12)
Expand All @@ -281,7 +282,7 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
mimemagic (0.3.2)
mini_mime (1.0.1)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.1)
mixlib-archive (0.4.18)
Expand Down Expand Up @@ -309,7 +310,7 @@ GEM
net-ssh-gateway (>= 1.2.0)
net-telnet (0.1.1)
newrelic_rpm (4.1.0.333)
nio4r (2.3.1)
nio4r (2.5.2)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
notiffany (0.1.1)
Expand Down Expand Up @@ -390,22 +391,22 @@ GEM
pundit (1.1.0)
activesupport (>= 3.0.0)
raabro (1.1.6)
rack (2.2.2)
rack (2.2.3)
rack-protection (2.0.1)
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.7.2)
actioncable (= 5.0.7.2)
actionmailer (= 5.0.7.2)
actionpack (= 5.0.7.2)
actionview (= 5.0.7.2)
activejob (= 5.0.7.2)
activemodel (= 5.0.7.2)
activerecord (= 5.0.7.2)
activesupport (= 5.0.7.2)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.1.7)
actioncable (= 5.1.7)
actionmailer (= 5.1.7)
actionpack (= 5.1.7)
actionview (= 5.1.7)
activejob (= 5.1.7)
activemodel (= 5.1.7)
activerecord (= 5.1.7)
activesupport (= 5.1.7)
bundler (>= 1.3.0)
railties (= 5.0.7.2)
railties (= 5.1.7)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.1)
actionpack (~> 5.x)
Expand All @@ -416,9 +417,9 @@ GEM
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (5.0.7.2)
actionpack (= 5.0.7.2)
activesupport (= 5.0.7.2)
railties (5.1.7)
actionpack (= 5.1.7)
activesupport (= 5.1.7)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
Expand Down Expand Up @@ -579,7 +580,7 @@ GEM
hashdiff (>= 0.4.0, < 2.0.0)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
websocket-extensions (0.1.5)
with_env (1.1.0)
wmi-lite (1.0.0)
xml-simple (1.1.5)
Expand Down Expand Up @@ -634,7 +635,7 @@ DEPENDENCIES
premailer-rails
pry-rails
pundit
rails (~> 5.0.0)
rails (~> 5.1.0)
rails-controller-testing
rb-readline
redcarpet
Expand Down
3 changes: 3 additions & 0 deletions src/supermarket/bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ 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'
Expand Down
11 changes: 11 additions & 0 deletions src/supermarket/bin/yarn
Original file line number Diff line number Diff line change
@@ -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
warn "Yarn executable was not detected in the system."
warn "Download Yarn at https://yarnpkg.com/en/docs/install"
exit 1
end
end
3 changes: 3 additions & 0 deletions src/supermarket/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

module Supermarket
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.
Expand Down
1 change: 1 addition & 0 deletions src/supermarket/config/cable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ test:
production:
adapter: redis
url: redis://localhost:6379/1
channel_prefix: supermarket_production
4 changes: 2 additions & 2 deletions src/supermarket/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
14 changes: 9 additions & 5 deletions src/supermarket/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -42,10 +47,9 @@
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true

# default production log level has historically been WARN
# TODO: consider setting to DEBUG so that the default provides
# maximum diagnostic information after ensuring log rotation
# schedule handles the increased output
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
# config.log_level = :debug
config.log_level = (ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].downcase : 'warn').to_sym

# Prepend all log lines with the following tags.
Expand Down Expand Up @@ -97,7 +101,7 @@
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
config.logger = ActiveSupport::TaggedLogging.new(logger)
end

# Do not dump schema after migrations.
Expand Down
2 changes: 1 addition & 1 deletion src/supermarket/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 6 additions & 3 deletions src/supermarket/config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
14 changes: 14 additions & 0 deletions src/supermarket/config/initializers/new_framework_defaults_5_1.rb
Original file line number Diff line number Diff line change
@@ -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
23 changes: 16 additions & 7 deletions src/supermarket/config/puma.rb
Original file line number Diff line number Diff line change
@@ -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 }

Expand All @@ -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
18 changes: 14 additions & 4 deletions src/supermarket/config/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: b46c1e102a9a4046db1fc7b2f54a7ee7e94e06e74ec495a2f66521eb962c123bce344d295ac7a941b3d3e37e57d35d95616fc9f60588216142c0738ba52e0965
secret_key_base: f513fa8b54e0465a5b141d4fb0a126f858c2e0de2544ab82a05770ba80a56450a45464d268e1b84fc1ed7d34945f8941a3e008fd184ba94d061e8a6f61aa7447

test:
secret_key_base: 7c9419d67a6e9c6a22f1e44f7bf3d412d9dd5aa02811e3ac3221f415eacc461a048b9d582edb7e808350e8d3350476599431f2d647980f86d88dc99c7bf90d71
secret_key_base: d86f4771cd60b31e9e2a20759e5569c5d514981d27adcd6d73cce35ff723a3bb4dc8e611a59215021462b98b7732850f3319fa2e549826491a9424edde0df49f

# 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.

# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

0 comments on commit 773c483

Please sign in to comment.