aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2019-03-12 13:36:40 -0400
committerGitHub <noreply@github.com>2019-03-12 13:36:40 -0400
commit6d7c4ae6c35b5e3e7689c5a8cb549d94603467b2 (patch)
tree992a7dcfd02ede0baf9bafb6b2826ba74f8cde27
parent2fa03e62574f40a60c6e4f5720886a2877f63829 (diff)
parent44f3530274ba0de53366cdfd8dacb373154648d0 (diff)
downloadrails-6d7c4ae6c35b5e3e7689c5a8cb549d94603467b2.tar.gz
rails-6d7c4ae6c35b5e3e7689c5a8cb549d94603467b2.tar.bz2
rails-6d7c4ae6c35b5e3e7689c5a8cb549d94603467b2.zip
Merge pull request #35583 from cpruitt/add-addititonal-tests-for-dummy-erb
Add additional ERB DummyCompiler tests
-rw-r--r--railties/test/application/rake/dbs_test.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/railties/test/application/rake/dbs_test.rb b/railties/test/application/rake/dbs_test.rb
index ea7117800c..a1e237fa7b 100644
--- a/railties/test/application/rake/dbs_test.rb
+++ b/railties/test/application/rake/dbs_test.rb
@@ -68,6 +68,60 @@ module ApplicationTests
db_create_and_drop("db/development.sqlite3", environment_loaded: false)
end
+ test "db:create and db:drop don't raise errors when loading YAML with multiline ERB" do
+ app_file "config/database.yml", <<-YAML
+ development:
+ database: <%=
+ Rails.application.config.database
+ %>
+ adapter: sqlite3
+ YAML
+
+ app_file "config/environments/development.rb", <<-RUBY
+ Rails.application.configure do
+ config.database = "db/development.sqlite3"
+ end
+ RUBY
+
+ db_create_and_drop("db/development.sqlite3", environment_loaded: false)
+ end
+
+ test "db:create and db:drop don't raise errors when loading YAML containing conditional statements in ERB" do
+ app_file "config/database.yml", <<-YAML
+ development:
+ <% if Rails.application.config.database %>
+ database: <%= Rails.application.config.database %>
+ <% else %>
+ database: db/default.sqlite3
+ <% end %>
+ adapter: sqlite3
+ YAML
+
+ app_file "config/environments/development.rb", <<-RUBY
+ Rails.application.configure do
+ config.database = "db/development.sqlite3"
+ end
+ RUBY
+
+ db_create_and_drop("db/development.sqlite3", environment_loaded: false)
+ end
+
+ test "db:create and db:drop don't raise errors when loading YAML containing multiple ERB statements on the same line" do
+ app_file "config/database.yml", <<-YAML
+ development:
+ database: <% if Rails.application.config.database %><%= Rails.application.config.database %><% else %>db/default.sqlite3<% end %>
+ adapter: sqlite3
+ YAML
+
+ app_file "config/environments/development.rb", <<-RUBY
+ Rails.application.configure do
+ config.database = "db/development.sqlite3"
+ end
+ RUBY
+
+ db_create_and_drop("db/development.sqlite3", environment_loaded: false)
+ end
+
def with_database_existing
Dir.chdir(app_path) do
set_database_url