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

Same DB Being Used in Development and Test Environments #3396

Open
aaronskiba opened this issue Mar 13, 2024 · 1 comment
Open

Same DB Being Used in Development and Test Environments #3396

aaronskiba opened this issue Mar 13, 2024 · 1 comment

Comments

@aaronskiba
Copy link
Contributor

Please complete the following fields as applicable:

What version of the DMPRoadmap code are you running? (e.g. v2.2.0)

  • v4.1.0

Expected behaviour:

  • Executing the rspec tests should not affect the development db.

Actual behaviour:

bundle exec rspec was executed in between the following two SELECT COUNT(*) FROM users; queries:

postgres=# \c roadmap
You are now connected to database "roadmap" as user "postgres".
roadmap=# SELECT COUNT(*) FROM users;
 count 
-------
     4
(1 row)

roadmap=# SELECT COUNT(*) FROM users;
 count 
-------
     0
(1 row)

roadmap=# 
@aaronskiba
Copy link
Contributor Author

// config/database.yml.sample

defaults: &defaults
  adapter: <%= ENV.fetch('DB_ADAPTER', 'postgresql') %>
  encoding: <%= ENV.fetch('DB_ADAPTER', 'postgresql') == 'mysql2' ? 'utf8mb4' : '' %>
  pool: <%= ENV.fetch('DB_POOL_SIZE', 16) %>
  host: <%= ENV.fetch('DB_HOST', 'localhost') %>
  port: <%= ENV.fetch('DB_PORT', '5432') %>
  database: <%= ENV.fetch('DB_NAME', 'roadmap') %>
  username: <%= ENV.fetch('DB_USERNAME', Rails.application.credentials.db_username) %>
  password: <%= ENV.fetch('DB_PASSWORD', Rails.application.credentials.db_password) %>

development:
  <<: *defaults

test:
  <<: *defaults

I think this could be resolved by specifying a different value for database: within test:.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant