Add modular safeguard support
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia con DatabaseCleaner::Safeguard::CHECKS e con il meccanismo esistente ActiveRecord::Tasks::DatabaseTasks.check_protected_environments!, descritto nell'issue. Esamina la suite di test ed esegui bin/rspec per comprendere il comportamento attuale dei safeguards; il lavoro è completo quando i safeguards possono essere modularizzati in modo da fornire checks specifici per l'ORM senza dipendere esclusivamente dalle variabili ENV.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
My team recently came across a really nasty issue where spring kept our ActiveRecord::Base.connection_config cached. In that case, the current ENV var based safeguards failed us (luckily nobody was seriously injured).
For example,
# First, let's run a console
> DATABASE_URL=$(heroku config:get DATABASE_URL -a my-prod-app) bin/rails console
# :tada: we're running tests against the old DATABASE_URL even though it's not set
> bin/rspec
There are lots of different ways to get into this scenario (like other code loaders or multiple ORMs that use other variables). While checking for the ENV vars works for some low hanging fruit, it doesn't let ORMs (or maybe even other app/test frameworks) make more intelligent decisions.
We actually just added this to our test suite and it works great (based on the idea in https://github.com/DatabaseCleaner/database_cleaner/pull/521#issuecomment-380757595)
# Simplified version
DatabaseCleaner::Safeguard::CHECKS << Class.new do
def run
# Prevent running tests against protected environments
# - This is the same mechanism that the `rake` tasks use so you can't
# run destructive operations like `db:reset` against production
::ActiveRecord::Tasks::DatabaseTasks.check_protected_environments!
end
end
I think it could be very useful to modularize the concept of a Safeguard so that various ORM modules could provide their own (the above case could something like DatabaseCleaner::ActiveRecord::Safeguard::ProtectedEnvironment).
I would be more than willing to work on this, but wanted to gauge interest and possibly talk about some design decisions before going ahead with it.
- Lingua principale
- Ruby
- Stelle
- 3k
- Fork
- 485
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di DatabaseCleaner/database_cleaner
-
:transaction strategy: uncommitted data disappears after perform_enqueued_jobs on Rails ≥ 7.2Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 67/100
-
Cleaning of dev DBAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
Cannot truncate a table referenced in a foreign key constraint (ActiveRecord::StatementInvalid)Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
DatabaseCleaner/database_cleaner#717 · 5 commenti · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
DatabaseCleaner/database_cleaner#716 · 2 commenti ·
Tutte le issue di DatabaseCleaner/database_cleaner
Issue simili
-
Použiť Redis pre ActionCableAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
slovensko-digital/autogram-portal#392 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
voxpupuli/puppet-quadlets#122 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
TheOdinProject/curriculum#31452 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
revoir les metions de la DGEAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
betagouv/conseillers-entreprises#4720 ·
I maintainer di solito rispondono entro 3 giorni