Add modular safeguard support
還沒有人認領這個 Issue。
評估
研究方向
從 issue 中描述的 DatabaseCleaner::Safeguard::CHECKS 和現有的 ActiveRecord::Tasks::DatabaseTasks.check_protected_environments! 機制開始。檢查測試套件並執行 bin/rspec,以了解目前的 safeguard 行為;當 safeguards 可以模組化,從而無需僅依賴 ENV 變數即可提供 ORM 專用的 checks 時,即可視為完成。
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- Ruby
- 星號
- 3k
- 分支
- 486
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 沒有貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
DatabaseCleaner/database_cleaner 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 67/100
-
難度 4/5 3-5 天 新手友好度 25/100
-
難度 3/5 1-2 天 新手友好度 45/100
-
難度 4/5 3-5 天 新手友好度 35/100
DatabaseCleaner/database_cleaner#717 · 5 則留言 · 1 個 reaction ·
-
難度 4/5 3-5 天 新手友好度 25/100
DatabaseCleaner/database_cleaner#716 · 2 則留言 ·
查看 DatabaseCleaner/database_cleaner 的全部 Issue
相似的 Issue
-
internal product:ai-gateway size: S
難度 2/5 1-3 小時 新手友好度 67/100
Kong/developer.konghq.com#7931 ·
維護者通常 1 天內回覆
-
難度 1/5 1-3 小時 新手友好度 78/100
partiql/partiql-lang#105 ·
-
難度 2/5 1-3 小時 新手友好度 70/100
rails/rails-dom-testing#136 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
nesquena/steward-os#79 ·
維護者通常 1 天內回覆
-
area/tech debt
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆