0

I currently work in a big Rails App that sadly has no test coverage and is currently on version 3 of Rails.

What would be the best approach in order to migrate to Rails 4 ? I know it's better to migrate step by step on Rails version, but the application is very big.

Should I invest in Tests before doing so ? What kind of tests ? Unit testing ? Integration tests ?

andrefurquin
  • 502
  • 6
  • 17
  • This topic has nothing to do with how to get started with TDD – andrefurquin Feb 28 '16 at 02:11
  • You could always not update and use [Rails LTS](https://railslts.com/). – Martin Tournoij Mar 08 '16 at 06:11
  • Interesting. I didn't know there was something like that. But kinda expansive for our budget so far. Thank you anyway! :) – andrefurquin Mar 09 '16 at 18:01
  • The hardest but better path for us is to invest in test. – andrefurquin Mar 09 '16 at 18:02
  • There used to be a free version, but it looks like they changed that :-/ As for "expensive", that depends on how you look at it. I don't know the app, your company, or the requirements, so it's difficult for me to judge, but assume that a single developer costs €3000/month in total, then that's the same costs as *20 months* of Rails LTS. Writing good tests, updating to Rails 4, and shaking out the bugs will probably be more than a months work for a single dev (and that assumes there is no loss-of-income due to a bug or site outage). So if you put it like that, it's not that expensive... – Martin Tournoij Mar 09 '16 at 18:07

2 Answers2

1

I am suggesting you to have atleast rspec unit test for all models and controllers then proceed to upgrade the application.

But without tests if you upgrade then it would be a problem to find any issues inside the application, becuse we cant predict whether it's due to upgrade or issue with the written code.

If you have very complicated views like calculations or showing some important informations then it's good to write integration test as well, else that's not a necessary.

Mohanraj
  • 4,056
  • 2
  • 22
  • 24
1

Our approach looked like this (and religiously followed this guide):

  1. Make sure we have unit tests for all models/controllers
  2. Add integration tests for all business critical paths in the app
  3. Add the strong_params gem to the app, see what breaks, fix the broken things
  4. In Gemfile, for each gem with version, look at gem dependencies and attempt to upgrade to latest version possible (i.e., removing warnings, update integrations, making sure tests pass)
  5. Upgrade the rails gem -- see what breaks, fix the broken things

You'll notice that in the guide, the first thing they drill on is test coverage. It sounds like that might be the best place for you to start.