The Rails upgrade is approved, the new version is picked, and then someone runs the test suite. It has 40 tests, half of them skipped, and nothing that touches billing. The team now has to ship a framework upgrade with almost no safety net.
This is a common spot for older Rails applications. You can’t pause the upgrade until coverage is perfect, and you can’t ship blind either. The workable path sits between the two: add targeted tests where failure would hurt, upgrade in small steps, and make every release easy to undo. This guide covers how to do that.
Why thin coverage turns upgrades into guesswork
A Rails upgrade changes behavior in places you didn’t touch. Deprecated methods disappear, defaults change, and gems that hooked into old internals stop working. The Rails team says it plainly in the official upgrade guide: the best way to be sure the application still works afterwards is to have good test coverage before you start.
Without that coverage, you find out what broke from your users. A background job that silently stops enqueueing, a date format that shifts in an invoice, a permission check that now behaves differently. None of these throw an error on boot.
Low coverage also hides which parts of the app matter. Teams often discover mid-upgrade that a rarely discussed admin screen drives most of the company’s revenue operations.
Decide what must not break
You don’t need coverage everywhere. You need it on the paths where a defect costs real money or trust.
Sit down with product and support and list the five to ten journeys the business can’t lose. For a SaaS product that might be sign-in, subscription billing, the main data import, a key report and the public API. Rank them by damage if they fail, not by how easy they are to test.
That list becomes your upgrade test scope. Everything else is secondary, and you can add coverage later.
Add tests that describe today’s behavior
When the code has no tests, you don’t write ideal tests. You write characterization tests: tests that record what the application does right now, even where the behavior is odd.
The approach is simple. Call the endpoint or run the job, capture the output, and assert that it stays the same. If an old calculation returns a strange rounding, the test records the strange rounding. You can decide later whether that’s a bug. For the upgrade, you only need to know whether the behavior changed.
Good starting points include:
- Request-level tests for the critical routes, checking status codes, key response fields and redirects.
- Tests for money, dates, time zones and permissions, which are the places where Rails and Ruby behavior changes hurt most.
- Job tests that confirm each critical background job runs end to end and writes the expected records.
- A basic browser test for the main user journey, kept small so it stays reliable.
Write these tests against the current Rails version first, and make sure they pass there. A test that fails before the upgrade tells you nothing about the upgrade.
Upgrade one minor version at a time
The Rails guide recommends moving one minor version at a time so the deprecation warnings guide you. Skipping versions removes those warnings, and with thin tests the warnings are your main early signal.
The sequence the guide describes works well here:
- Get the existing tests and your new characterization tests passing on the current version.
- Move to the latest patch release of your current minor version and fix any failures and deprecation warnings.
- Move to the latest patch of the next minor version, then repeat the cycle.
Treat Ruby as a separate step. Newer Rails releases raise the minimum Ruby version. The guide states that Rails 8.0 and 8.1 require Ruby 3.2.0 or newer, so an application on an older Ruby needs a Ruby upgrade in its own release. Combining the two makes it hard to tell which change caused a problem.
Before choosing a target, check the Rails maintenance policy. It says minor releases receive bug fixes for one year and security fixes for two years after the first release in the series. Work out where your current version sits against those windows, so you know how much time you have.
Use deprecation warnings and logs as a free test suite
If tests are thin, other signals can fill part of the gap.
Run the app in a staging environment with deprecation warnings turned on and read them. Each warning points to code that will break in a later version. Fix them while you’re still on the old version, where the change is easy to verify.
Then compare error rates. Record your error tracker’s normal baseline for a week before the release, and compare it against the first hours after the release. New error types are often the first sign of a missed behavior change.
Dependencies need their own review. Check each gem for a version that supports your target Rails release. A gem that’s abandoned and incompatible is a project decision: replace it, fork it or remove the feature. Find these early, because they set the real size of the upgrade.
Release in a way you can undo
With limited tests, the release method does a lot of the risk reduction.
Deploy to a production-like staging environment with a copy of anonymized production data, and have someone walk through the critical journeys by hand using a short written checklist. It’s slow, but it catches what the automated tests can’t.
Where your infrastructure allows it, send a small share of traffic to the upgraded version first, then widen it. If that isn’t possible, release at a quiet time with the engineers who know the code on hand.
Plan the rollback before the release, not during it. Check that the previous version can be redeployed quickly, and look closely at database migrations. A migration that drops or rewrites data can make a rollback impossible. Split risky schema changes into separate releases, so the code change can be reversed even when the data change can’t.
Mistakes that make low-coverage upgrades riskier
- Trying to reach full coverage first. The upgrade stalls for months, and the version falls further behind.
- Skipping minor versions to save time. You lose the deprecation warnings and get one large failure instead of several small ones.
- Writing tests that need heavy rework to pass on the new version. Tests should describe behavior, not internal details.
- Upgrading Ruby, Rails and several gems in one release. A failure then has too many possible causes.
- Releasing without an owner. Someone has to watch errors and make the rollback call after deploy.
An example plan, with made-up numbers
This is a hypothetical illustration, not a RailsCarma quotation or a client result. Suppose a subscription product has 60 tests and no coverage on invoicing. The team spends the first stretch adding characterization tests for sign-in, invoice generation and the data import. They then upgrade Ruby alone, release it, and watch the error tracker. After that they move through two Rails minor versions in separate releases, each with a staging walkthrough and a rollback check.
No part of this plan is fast. Each release is small, and that’s what keeps a surprise cheap.
Where RailsCarma fits
Teams often struggle with the first step, which is working out what the application actually does and what the upgrade will touch. RailsCarma offers Rails upgrade services that begin with an audit of the application before the upgrade work, and general Conseil Ruby on Rails for teams that want an outside review of risk, dependencies and test strategy.
What to decide before you start
Pick the journeys the business can’t afford to lose, cover them with tests that record current behavior, and refuse to ship any upgrade step you can’t roll back. Those three rules matter more than a coverage percentage.
Speak with RailsCarma’s team to assess your application’s upgrade requirements and define a practical, low-risk migration scope.