Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade ruby and rails #868

Merged
merged 8 commits into from
Jun 26, 2020
Merged

Upgrade ruby and rails #868

merged 8 commits into from
Jun 26, 2020

Conversation

cintamani
Copy link
Contributor

From: https://eaflood.atlassian.net/browse/RUBY-1061

This PR contails all the changes necessary to upgrade the Ruby version from 2.4 to 2.7.1 and Rails version from 4.2 to 6.0.3.1

Some notes about the updates:

  • Request tests syntax for params and headers to send along with a get, put or post request have changed. Now the params are into a key-value format with the key specifying what are params and what are headers
  • With Rails 6, the rake command is not invoked directly any more. Instead, we now use bin/rails.
  • Since Rails 6 was built with the. intent to leave the assets work to. NodeJs, we had to require the sassc-rails gem on top of the rest of the gems in order for the old way of dealing with assets still works.
  • POST request that do not specify a render will redirected to a GET automatically, hence we have to explicitly raise errors now if we want them not to be reachable
  • Inherithance and scoping are something we must make more attention too. We used to define stuff like:
module WasteCarriersEngine
  class ErrorsController < ApplicationController

and trust that ruby would resolve the ApplicationController to be the module-scoped definition of it. We can't trust that any more, hence we have to be specific and do stuff like:

module WasteCarriersEngine
  class ErrorsController < ::WasteCarriersEngine::ApplicationController
  • Parameters on controller coming from a request are not any more instances of the Hash class, but instances of the ActionController::Parameters class
  • The test suite will run in :random mode by default
  • Many of the spec matches we were used to in request tests have been externalised to a gem rails-controller-testing

@cintamani cintamani added the enhancement New feature or request label Jun 17, 2020
@cintamani cintamani self-assigned this Jun 17, 2020
From: https://eaflood.atlassian.net/browse/RUBY-1061

This PR contails all the changes necessary to upgrade the Ruby version from 2.4 to 2.7.1 and Rails version from 4.2 to 6.0.3.1

Some notes about the updates:
- Request tests syntax for params and headers to send along with a `get`, `put` or `post` request have changed. Now the params are into a key-value format with the key specifying what are `params` and what are `headers`
- With Rails 6, the `rake` command is not invoked directly any more. Instead, we now use `bin/rails`.
- Since Rails 6 was built with the. intent to leave the assets work to. NodeJs, we had to require the `sassc-rails` gem on top of the rest of the gems in order for the old way of dealing with assets still works.
- `POST` request that do not specify a render will redirected to a `GET` automatically, hence we have to explicitly raise errors now if we want them not to be reachable
- Inherithance and scoping are something we must make more attention too. We used to define stuff like:
```
module WasteCarriersEngine
  class ErrorsController < ApplicationController
```
and trust that ruby would resolve the `ApplicationController` to be the module-scoped definition of it. We can't trust that any more, hence we have to be specific and do stuff like:
```
module WasteCarriersEngine
  class ErrorsController < ::WasteCarriersEngine::ApplicationController
```
- Parameters on controller coming from a request are not any more instances of the Hash class, but instances of the `ActionController::Parameters` class
- The test suite will run in `:random` mode by default
- Many of the spec matches we were used to in request tests have been externalised to a gem `rails-controller-testing`
@cintamani cintamani marked this pull request as ready for review June 17, 2020 12:55
irisfaraway
irisfaraway previously approved these changes Jun 18, 2020
Copy link
Member

@irisfaraway irisfaraway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 👏 👏

Also happy to ignore Sonarcloud on this one!

irisfaraway
irisfaraway previously approved these changes Jun 18, 2020
irisfaraway
irisfaraway previously approved these changes Jun 18, 2020
Copy link
Member

@Cruikshanks Cruikshanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to start merging when ready

@irisfaraway irisfaraway merged commit 41a1997 into master Jun 26, 2020
@irisfaraway irisfaraway deleted the rails-upgrade branch June 26, 2020 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants