Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

allow_remote_database_url not working as expected

Đang mở
#668 2 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
docker, postgres, rails, ruby
Lĩnh vực
backend, databases, testing

Hướng nghiên cứu

Bắt đầu với support/database_cleaner.rb và tái hiện thiết lập Dockerized Rails trong đó rspec dọn dẹp cơ sở dữ liệu phát triển. Theo dõi cách allow_remote_database_url và url_whitelist được diễn giải, sau đó xác minh rằng môi trường kiểm thử được bảo vệ khỏi cơ sở dữ liệu phát triển và thêm một bài kiểm thử hồi quy cho cấu hình đã được báo cáo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

  • 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?

Ngôn ngữ chính
Ruby
Star
3k
Fork
485
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của DatabaseCleaner/database_cleaner

Tất cả issue của DatabaseCleaner/database_cleaner

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.