Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Add modular safeguard support

オープン
#659 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
rails, ruby
領域
databases, testing

調査の方向性

Issue で説明されている DatabaseCleaner::Safeguard::CHECKS と既存の ActiveRecord::Tasks::DatabaseTasks.check_protected_environments! メカニズムから始めます。テストスイートを確認し、bin/rspec を実行して現在の safeguard の動作を理解します。safeguard をモジュール化し、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
フォーク
485
PR マージ指標
30日以内にマージされた PR はありません

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

DatabaseCleaner/database_cleaner のほかの issue

DatabaseCleaner/database_cleaner の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。