allow_remote_database_url not working as expected
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
調査の方向性
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 ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
DatabaseCleaner/database_cleaner のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 67/100
-
Cleaning of dev DBオープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
Cannot truncate a table referenced in a foreign key constraint (ActiveRecord::StatementInvalid)オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
DatabaseCleaner/database_cleaner#717 · コメント 5 件 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
DatabaseCleaner/database_cleaner#716 · コメント 2 件 ·
DatabaseCleaner/database_cleaner の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
rubys/roundhouse#444 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
sclorg/s2i-ruby-container#656 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
request
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
endoflife-date/endoflife.date#11277 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
yegor256/rubocop-elegant#92 ·