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

allow_remote_database_url not working as expected

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
docker, postgres, rails, ruby

調査の方向性

support/database_cleaner.rb から始め、rspec が開発データベースをクリーンアップする Dockerized Rails セットアップを再現します。allow_remote_database_url と url_whitelist がどのように解釈されるかを追跡し、テスト環境が開発データベースから保護されていることを確認して、報告された設定の回帰テストを追加します。

索引モデルが issue の本文から書いたものです。

説明

  • ruby: 2.7.2
  • rails: 6.0.3.4
  • database_cleaner: 1.8.5
  • database_cleaner-active_record: 1.8.0

I'm running Rails in development in a Dockerized environment. One of the configured Docker Compose services is a container to run commands (e.g. rails, rake, ...) and its RAILS_ENV is development. If I accidentally run rspec in that particular container, my development database gets cleaned, which is not what I want.

I tried configuring DatabaseCleaner.url_whitelist to include the full URL to the test database. For example:

DatabaseCleaner.url_whitelist = %w[postgres://postgres:postgres@postgres:5432/my_app_test]

But it looks like only base URLs are considered.

Then I tried allowing remote URLs for the test environment alone by adding the following line at the top of support/database_cleaner.rb:

DatabaseCleaner.allow_remote_database_url = Rails.env.test?

But that's ignored for some reason. I checked if Rails.env.test? is false at that point, and it is.

So now I've replaced that line with:

raise StandardError, "Database cleaner expected 'test' environment" unless Rails.env.test?

Which works. But isn't allow_remote_database_url supposed to do the same? Or am I missing something crucial?

主要言語
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 を短くまとめたダイジェスト。