Skip to content

Commit bae2ac1

Browse files
Merge pull request #4349 from alphagov/upgrade-to-rails-6
Upgrade to rails 6
2 parents cfbbefc + 78b6a4a commit bae2ac1

20 files changed

+143
-99
lines changed

Gemfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ source "https://rubygems.org"
22

33
ruby File.read(".ruby-version").chomp
44

5-
gem "rails", "~> 5"
5+
gem "rails", "~> 6.0.2"
66
gem "railties"
77
gem "sprockets-rails"
88

@@ -19,7 +19,7 @@ gem "method_source"
1919
gem "parser"
2020
gem "plek", "3.0.0"
2121
gem "rack_strip_client_ip"
22-
gem "rails-i18n"
22+
gem "rails-i18n", "~> 6.0.0"
2323
gem "rails_stdout_logging"
2424
gem "sass-rails", "~> 5.0.7"
2525
gem "slimmer", "~> 13.2.2"

Gemfile.lock

+63-47
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,63 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
actioncable (5.2.4.1)
5-
actionpack (= 5.2.4.1)
4+
actioncable (6.0.2.1)
5+
actionpack (= 6.0.2.1)
66
nio4r (~> 2.0)
77
websocket-driver (>= 0.6.1)
8-
actionmailer (5.2.4.1)
9-
actionpack (= 5.2.4.1)
10-
actionview (= 5.2.4.1)
11-
activejob (= 5.2.4.1)
8+
actionmailbox (6.0.2.1)
9+
actionpack (= 6.0.2.1)
10+
activejob (= 6.0.2.1)
11+
activerecord (= 6.0.2.1)
12+
activestorage (= 6.0.2.1)
13+
activesupport (= 6.0.2.1)
14+
mail (>= 2.7.1)
15+
actionmailer (6.0.2.1)
16+
actionpack (= 6.0.2.1)
17+
actionview (= 6.0.2.1)
18+
activejob (= 6.0.2.1)
1219
mail (~> 2.5, >= 2.5.4)
1320
rails-dom-testing (~> 2.0)
14-
actionpack (5.2.4.1)
15-
actionview (= 5.2.4.1)
16-
activesupport (= 5.2.4.1)
21+
actionpack (6.0.2.1)
22+
actionview (= 6.0.2.1)
23+
activesupport (= 6.0.2.1)
1724
rack (~> 2.0, >= 2.0.8)
1825
rack-test (>= 0.6.3)
1926
rails-dom-testing (~> 2.0)
20-
rails-html-sanitizer (~> 1.0, >= 1.0.2)
21-
actionview (5.2.4.1)
22-
activesupport (= 5.2.4.1)
27+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
28+
actiontext (6.0.2.1)
29+
actionpack (= 6.0.2.1)
30+
activerecord (= 6.0.2.1)
31+
activestorage (= 6.0.2.1)
32+
activesupport (= 6.0.2.1)
33+
nokogiri (>= 1.8.5)
34+
actionview (6.0.2.1)
35+
activesupport (= 6.0.2.1)
2336
builder (~> 3.1)
2437
erubi (~> 1.4)
2538
rails-dom-testing (~> 2.0)
26-
rails-html-sanitizer (~> 1.0, >= 1.0.3)
27-
activejob (5.2.4.1)
28-
activesupport (= 5.2.4.1)
39+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
40+
activejob (6.0.2.1)
41+
activesupport (= 6.0.2.1)
2942
globalid (>= 0.3.6)
30-
activemodel (5.2.4.1)
31-
activesupport (= 5.2.4.1)
32-
activerecord (5.2.4.1)
33-
activemodel (= 5.2.4.1)
34-
activesupport (= 5.2.4.1)
35-
arel (>= 9.0)
36-
activestorage (5.2.4.1)
37-
actionpack (= 5.2.4.1)
38-
activerecord (= 5.2.4.1)
43+
activemodel (6.0.2.1)
44+
activesupport (= 6.0.2.1)
45+
activerecord (6.0.2.1)
46+
activemodel (= 6.0.2.1)
47+
activesupport (= 6.0.2.1)
48+
activestorage (6.0.2.1)
49+
actionpack (= 6.0.2.1)
50+
activejob (= 6.0.2.1)
51+
activerecord (= 6.0.2.1)
3952
marcel (~> 0.3.1)
40-
activesupport (5.2.4.1)
53+
activesupport (6.0.2.1)
4154
concurrent-ruby (~> 1.0, >= 1.0.2)
4255
i18n (>= 0.7, < 2)
4356
minitest (~> 5.1)
4457
tzinfo (~> 1.1)
58+
zeitwerk (~> 2.2)
4559
addressable (2.7.0)
4660
public_suffix (>= 2.0.2, < 5.0)
47-
arel (9.0.0)
4861
ast (2.4.0)
4962
better_errors (2.6.0)
5063
coderay (>= 1.0.0)
@@ -186,18 +199,20 @@ GEM
186199
rack-test (1.1.0)
187200
rack (>= 1.0, < 3)
188201
rack_strip_client_ip (0.0.2)
189-
rails (5.2.4.1)
190-
actioncable (= 5.2.4.1)
191-
actionmailer (= 5.2.4.1)
192-
actionpack (= 5.2.4.1)
193-
actionview (= 5.2.4.1)
194-
activejob (= 5.2.4.1)
195-
activemodel (= 5.2.4.1)
196-
activerecord (= 5.2.4.1)
197-
activestorage (= 5.2.4.1)
198-
activesupport (= 5.2.4.1)
202+
rails (6.0.2.1)
203+
actioncable (= 6.0.2.1)
204+
actionmailbox (= 6.0.2.1)
205+
actionmailer (= 6.0.2.1)
206+
actionpack (= 6.0.2.1)
207+
actiontext (= 6.0.2.1)
208+
actionview (= 6.0.2.1)
209+
activejob (= 6.0.2.1)
210+
activemodel (= 6.0.2.1)
211+
activerecord (= 6.0.2.1)
212+
activestorage (= 6.0.2.1)
213+
activesupport (= 6.0.2.1)
199214
bundler (>= 1.3.0)
200-
railties (= 5.2.4.1)
215+
railties (= 6.0.2.1)
201216
sprockets-rails (>= 2.0.0)
202217
rails-controller-testing (1.0.4)
203218
actionpack (>= 5.0.1.x)
@@ -208,16 +223,16 @@ GEM
208223
nokogiri (>= 1.6)
209224
rails-html-sanitizer (1.3.0)
210225
loofah (~> 2.3)
211-
rails-i18n (5.1.3)
226+
rails-i18n (6.0.0)
212227
i18n (>= 0.7, < 2)
213-
railties (>= 5.0, < 6)
228+
railties (>= 6.0.0, < 7)
214229
rails_stdout_logging (0.0.5)
215-
railties (5.2.4.1)
216-
actionpack (= 5.2.4.1)
217-
activesupport (= 5.2.4.1)
230+
railties (6.0.2.1)
231+
actionpack (= 6.0.2.1)
232+
activesupport (= 6.0.2.1)
218233
method_source
219234
rake (>= 0.8.7)
220-
thor (>= 0.19.0, < 2.0)
235+
thor (>= 0.20.3, < 2.0)
221236
rainbow (3.0.0)
222237
raindrops (0.19.1)
223238
rake (13.0.1)
@@ -237,7 +252,7 @@ GEM
237252
rouge (3.17.0)
238253
rspec-core (3.9.1)
239254
rspec-support (~> 3.9.1)
240-
rspec-expectations (3.9.0)
255+
rspec-expectations (3.9.1)
241256
diff-lcs (>= 1.2.0, < 2.0)
242257
rspec-support (~> 3.9.0)
243258
rspec-mocks (3.9.1)
@@ -260,7 +275,7 @@ GEM
260275
rexml
261276
ruby-progressbar (~> 1.7)
262277
unicode-display_width (>= 1.4.0, < 1.7)
263-
rubocop-govuk (3.1.0)
278+
rubocop-govuk (3.3.0)
264279
rubocop (= 0.80.1)
265280
rubocop-rails (~> 2)
266281
rubocop-rspec (~> 1.28)
@@ -357,6 +372,7 @@ GEM
357372
websocket-extensions (0.1.4)
358373
xpath (3.2.0)
359374
nokogiri (~> 1.8)
375+
zeitwerk (2.3.0)
360376

361377
PLATFORMS
362378
ruby
@@ -384,9 +400,9 @@ DEPENDENCIES
384400
plek (= 3.0.0)
385401
pry
386402
rack_strip_client_ip
387-
rails (~> 5)
403+
rails (~> 6.0.2)
388404
rails-controller-testing
389-
rails-i18n
405+
rails-i18n (~> 6.0.0)
390406
rails_stdout_logging
391407
railties
392408
rspec-rails (~> 3.9.1)

app/helpers/layouts_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module LayoutsHelper
1111
#
1212
def parent_layout(layout)
1313
@view_flow.set(:layout, output_buffer)
14-
output = render(file: "layouts/#{layout}")
14+
output = render(template: "layouts/#{layout}")
1515
self.output_buffer = ActionView::OutputBuffer.new(output)
1616
end
1717
end

app/presenters/start_page_content_item.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ def payload
1616
introductory_paragraph: [
1717
{
1818
content: flow_presenter.start_page_body,
19-
content_type: "text/govspeak",
19+
content_type: "text/govspeak; charset=utf-8",
2020
},
2121
],
2222
more_information: [
2323
content: flow_presenter.start_page_post_body,
24-
content_type: "text/govspeak",
24+
content_type: "text/govspeak; charset=utf-8",
2525
],
2626
transaction_start_link: base_path + "/y",
2727
start_button_text: flow_presenter.start_page_button_text,

app/services/content_item_publisher.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def publish_answer_via_publishing_api(base_path, publishing_app:, title:, conten
106106
body: [
107107
{
108108
content: content,
109-
content_type: "text/govspeak",
109+
content_type: "text/govspeak; charset=utf-8",
110110
},
111111
],
112112
},
@@ -134,7 +134,7 @@ def publish_transaction_via_publishing_api(base_path, publishing_app:, title:, c
134134
introductory_paragraph: [
135135
{
136136
content: content,
137-
content_type: "text/govspeak",
137+
content_type: "text/govspeak; charset=utf-8",
138138
},
139139
],
140140
transaction_start_link: link,

bin/setup

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env ruby
22
require "fileutils"
3-
include FileUtils
43

54
# path to your application root.
65
APP_ROOT = File.expand_path("..", __dir__)
@@ -9,15 +8,16 @@ def system!(*args)
98
system(*args) || abort("\n== Command #{args} failed ==")
109
end
1110

12-
chdir APP_ROOT do
13-
# This script is a starting point to setup your application.
11+
FileUtils.chdir APP_ROOT do
12+
# This script is a way to setup or update your development environment automatically.
13+
# This script is idempotent, so that you can run it at anytime and get an expectable outcome.
1414
# Add necessary setup steps to this file.
1515

1616
puts "== Installing dependencies =="
1717
system! "gem install bundler --conservative"
1818
system("bundle check") || system!("bundle install")
1919

20-
# Install JavaScript dependencies if using Yarn
20+
# Install JavaScript dependencies
2121
# system("bin/yarn")
2222

2323
puts "\n== Preparing database =="

config/application.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
module SmartAnswers
1414
class Application < Rails::Application
1515
# Initialize configuration defaults for originally generated Rails version.
16-
config.load_defaults 5.2
16+
config.load_defaults 6.0
1717

1818
# Settings in config/environments/* take precedence over those specified here.
1919
# Application configuration should go into files in config/initializers

config/environment.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Load the rails application
1+
# Load the Rails application.
22
require_relative "application"
33

44
# Initialize the Rails application.

config/environments/development.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# Run rails dev:cache to toggle caching.
1717
if Rails.root.join("tmp/caching-dev.txt").exist?
1818
config.action_controller.perform_caching = true
19+
config.action_controller.enable_fragment_cache_logging = true
1920

2021
config.cache_store = :memory_store
2122
config.public_file_server.headers = {
@@ -42,7 +43,7 @@
4243
# Suppress logger output for asset requests.
4344
config.assets.quiet = true
4445

45-
# Raises error for missing translations
46+
# Raises error for missing translations.
4647
# config.action_view.raise_on_missing_translations = true
4748

4849
# Use an evented file watcher to asynchronously detect changes in source code,

config/environments/production.rb

+9-10
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,20 @@
2222
# Apache or NGINX already handles this.
2323
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
2424

25-
# Compress JavaScripts and CSS.
25+
# Compress JavaScripts.
2626
config.assets.js_compressor = :uglifier
27+
# Compress CSS using a preprocessor.
2728
# config.assets.css_compressor = :sass
2829

2930
# Do not fallback to assets pipeline if a precompiled asset is missed.
3031
config.assets.compile = false
3132

32-
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
33-
3433
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
35-
# config.action_controller.asset_host = 'http://assets.example.com'
34+
# config.action_controller.asset_host = "http://assets.example.com"
3635

3736
# Specifies the header that your server uses for sending files.
38-
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
39-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
37+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
38+
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
4039

4140
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
4241
# config.force_ssl = true
@@ -51,9 +50,9 @@
5150
# Use a different cache store in production.
5251
# config.cache_store = :mem_cache_store
5352

54-
# Use a real queuing backend for Active Job (and separate queues per environment)
53+
# Use a real queuing backend for Active Job (and separate queues per environment).
5554
# config.active_job.queue_adapter = :resque
56-
# config.active_job.queue_name_prefix = "smart_answers_#{Rails.env}"
55+
# config.active_job.queue_name_prefix = "smart_answers_production"
5756

5857
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
5958
# the I18n.default_locale when a translation cannot be found).
@@ -77,8 +76,8 @@
7776
config.log_formatter = ::Logger::Formatter.new
7877

7978
# Use a different logger for distributed setups.
80-
# require 'syslog/logger'
81-
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
79+
# require "syslog/logger"
80+
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
8281

8382
if ENV["RAILS_LOG_TO_STDOUT"].present?
8483
logger = ActiveSupport::Logger.new(STDOUT)

config/environments/test.rb

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
# The test environment is used exclusively to run your application's
2+
# test suite. You never need to work with it otherwise. Remember that
3+
# your test database is "scratch space" for the test suite and is wiped
4+
# and recreated between test runs. Don't rely on the data there!
5+
16
Rails.application.configure do
27
# Settings specified here will take precedence over those in config/application.rb.
38

4-
# The test environment is used exclusively to run your application's
5-
# test suite. You never need to work with it otherwise. Remember that
6-
# your test database is "scratch space" for the test suite and is wiped
7-
# and recreated between test runs. Don't rely on the data there!
89
config.cache_classes = true
910

1011
# Do not eager load code on boot. This avoids loading your whole application
@@ -21,6 +22,7 @@
2122
# Show full error reports and disable caching.
2223
config.consider_all_requests_local = true
2324
config.action_controller.perform_caching = false
25+
config.cache_store = :null_store
2426

2527
# Raise exceptions instead of rendering exception templates.
2628
config.action_dispatch.show_exceptions = false
@@ -31,7 +33,7 @@
3133
# Print deprecation notices to the stderr.
3234
config.active_support.deprecation = :stderr
3335

34-
# Raises error for missing translations
36+
# Raises error for missing translations.
3537
# config.action_view.raise_on_missing_translations = true
3638

3739
# Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets

0 commit comments

Comments
 (0)