ActiveRecord connection leaking to other envs

Open
#558 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
ruby
Domain
backend, databases

Research direction

Start by reproducing the DATABASE_URL=$PSQL_REMOTE rails c and rspec-with-Spring scenario described in the issue. Read rails_spec.rb and the ActiveRecord::Tasks::DatabaseTasks.check_protected_environments! entry point, then determine whether the safeguard belongs in Spring or rspec-rails. Done means test execution cannot reuse the remote ActiveRecord connection in this setup, with coverage for the reported reproduction.

Written by the indexing model from the issue text.

Description

bug

Hi,
I'm posting this here, but I'm unsure which component is directly responsible for that problem.
I guess that it would be nice to have some guard to prevent this inside rspec-rails/rails itself.

REPLICATION
run console attaching it to remote DB like this:
DATABASE_URL=$PSQL_REMOTE rails c (development env)
then I'm using rspec for running specs, now rspec (using spring) when executing tests is already connected to remote DB instead of local one. Add sth like database cleaner to the stack and you have just wiped remote database.

One safeguard for that could be adding inside rails_spec.rb following line:
ActiveRecord::Tasks::DatabaseTasks.check_protected_environments!
but I imagine that check as something internal to ... (rails? rspec-rails?) so we do not have to add it to all projects.
I'm waiting for your comments here, please point me in the right direction.

Dominant language
Ruby
Stars
2.8k
Forks
342
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rails/spring

All issues in rails/spring

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.