Closed briri closed 4 years ago
Estimating 3+ days of work.
Work will be done in the rails5
branch which will be kept up to date with the changes made to the development
branch for our remaining tickets this sprint.
Here's a list of the things done to get from 4.2 to 5.0
bundle exec rake rails:update
and diff changes to config files, splicing in any changes necessaryApplicationRecord
base Model class and updated all models to inherit from it instead of directly from ActiveRecord::Base
. Added some of the generic include
statements to this new base classapp/jobs
folder and the new ApplicationJob
base class:assigns
in controller tests RDoc
config from Rakefile, Gavin had left a note to drop this in favor Yard DocsVALIDATION_MESSAGES
to the new ApplicationRecord
before_filter
callbacks in controllers with before_action
Here are a list of tasks done to get from 5.0 to 5.2 (including the step to 5.1):
bundle update
::HashWithIndifferentAccess
to ActiveSupport::HashWithIndifferentAccess
rake app:update
add diffed changes to splice our custom config back inconfig/initializers/constants.rb
and branding.yml.sample
into config/initializers/dmproadmap.rb
to group them all together (and get them out of the base Rails config) and to use the newer Rails.configuration.x.
formatbundle exec rails app:update:bin
to regenerate all of the binstubsbundle exec rails db:schema:dump
to rebuild the schema.rb
fileoptional: true
to Region -> Super Region, Phase -> Plan, Section -> Org relationships just to get the db/seeds.rb
working to run testslib/
into a app/services/locale_service.rb
file and updated FastGettext initializer which was having trouble initializing after the upgrade. NOTE Cookie serialization has changed in Rails 5.2. This will cause issues for uses that have cookies that have not expired when then go to the newly upgrade site. We should be able to deal with this through messaging to the user community.
Next steps:
Ensure all tests are running. It looks like we will need to add optional: true
to many of the belongs_to
rellationships
Ran through and got all but 2 tests passing. Needed to make the following adjustments:
requests
and controller
tests. Rspec switched to named arguments for http requests. (e.g. went from get :index, org: { id: 123 }
to get :index, params: { org: { id: 123 } }
optional: true
on belongs_to
relationshipshash_with_indifferent_access
since Request params are no longer a Hash and allow both string and symbol access #fuzzy
lines so that warning messages stopped appearing in rspec outputlatest?
method to specify which ':id' to pluckguidance_group_options
scope because uniq
returns an Array not an ActiveRecord Relation so switch to use distinct
other_organisation
text field and instead deals with the Org relationship in the callbacksredirect_back
method instead of the now defunct redirect_to :back
each_key
method on strong params to keys.each
in QuestionsController since Params is no longer a Hashpluck
calls on scopes to specify the table. (e.g. user.org.plans.pluck(:id)
to user.org.plans.pluck("plans.id")
NOTE: that the way Rails handles app credentials has changed in 5.2. There is no longer a config/secrets.yml
file. It has been replaced by a config/credentials.yml.enc
file and a config/master.key
file.
Everyone should read this blog post: https://medium.com/cedarcode/rails-5-2-credentials-9b3324851336
We can check in the defaultcredentials.yml.enc
generated for this open source project. We will need to update all of our individual deployment strategies to use our own copies of both files.
To generate these files in your own instances, you will need to run EDITOR=vim rails credentials:edit
(swap in your favorite editor)
master.key
andcredentials.yml.enc
Gemfile
andyarn.lock
to unpeg dependencies and set new Ruby version.config.server_static_files
toconfig.public_file_server.enabled
config.static_cache_control
toconfig.public_file_server.headers
rake
command to userails
instead. For example userails test
instead ofrake test
controller#action
string