roadmap
roadmap copied to clipboard
Same DB Being Used in Development and Test Environments
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=#
// 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:
.