diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2017-12-03 18:12:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-03 18:12:40 +0100 |
commit | dde620ac6e959c32a6dc8e59911e8f6ffa088321 (patch) | |
tree | 9b8c3a18d74a32290f45e2d68d8b657a0313f951 /railties/test | |
parent | 7609ca08ce5000689838eeb04ed37084bf364f78 (diff) | |
parent | dbee80bca0ef504120219e6c7686437456511060 (diff) | |
download | rails-dde620ac6e959c32a6dc8e59911e8f6ffa088321.tar.gz rails-dde620ac6e959c32a6dc8e59911e8f6ffa088321.tar.bz2 rails-dde620ac6e959c32a6dc8e59911e8f6ffa088321.zip |
Merge pull request #31311 from y-yagi/ignore_no_database_error_when_loading_schema_cache
Ignore `NoDatabaseError` when loading schema cache
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/rake/dbs_test.rb | 14 | ||||
-rw-r--r-- | railties/test/isolation/abstract_unit.rb | 15 |
2 files changed, 29 insertions, 0 deletions
diff --git a/railties/test/application/rake/dbs_test.rb b/railties/test/application/rake/dbs_test.rb index 0235210fdd..2082e9fa9f 100644 --- a/railties/test/application/rake/dbs_test.rb +++ b/railties/test/application/rake/dbs_test.rb @@ -98,6 +98,20 @@ module ApplicationTests end end + test "db:create works when schema cache exists and database does not exist" do + use_postgresql + + begin + rails %w(db:create db:migrate db:schema:cache:dump) + + rails "db:drop" + rails "db:create" + assert_equal 0, $?.exitstatus + ensure + rails "db:drop" rescue nil + end + end + test "db:drop failure because database does not exist" do output = rails("db:drop:_unsafe", "--trace") assert_match(/does not exist/, output) diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 7522237a38..5b1c06d4e5 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -381,6 +381,21 @@ module TestHelpers $:.reject! { |path| path =~ %r'/(#{to_remove.join('|')})/' } end + + def use_postgresql + File.open("#{app_path}/config/database.yml", "w") do |f| + f.puts <<-YAML + default: &default + adapter: postgresql + pool: 5 + database: railties_test + development: + <<: *default + test: + <<: *default + YAML + end + end end end |