allow_remote_database_url not working as expected
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
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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của DatabaseCleaner/database_cleaner
-
:transaction strategy: uncommitted data disappears after perform_enqueued_jobs on Rails ≥ 7.2Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 67/100
-
Cleaning of dev DBĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
Cannot truncate a table referenced in a foreign key constraint (ActiveRecord::StatementInvalid)Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
DatabaseCleaner/database_cleaner#717 · 5 bình luận · 1 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
DatabaseCleaner/database_cleaner#716 · 2 bình luận ·
Tất cả issue của DatabaseCleaner/database_cleaner
Issue tương tự
-
Add Catalan (ca) translationĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
eurosky-social/eu-haul#32 ·
-
README configuration examples use the wrong module name and describe removed Bootstrap assetsĐang mởgood first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
benbalter/add-to-org#17 ·
-
good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
benbalter/change_agent#11 ·
-
good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
benbalter/count-org-loc#20 ·
-
good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
benbalter/sitemap-parser#33 ·