diff options
author | Cliff Pruitt <cliff.pruitt@cliffpruitt.com> | 2019-03-12 08:34:41 -0400 |
---|---|---|
committer | Cliff Pruitt <cliff.pruitt@cliffpruitt.com> | 2019-03-12 10:23:29 -0400 |
commit | 44f3530274ba0de53366cdfd8dacb373154648d0 (patch) | |
tree | 59876195416a8b67c21bace5d2bf41c30a566684 /railties/test | |
parent | 4948663b32b5222ae5dc99f2ca474baa0aa17673 (diff) | |
download | rails-44f3530274ba0de53366cdfd8dacb373154648d0.tar.gz rails-44f3530274ba0de53366cdfd8dacb373154648d0.tar.bz2 rails-44f3530274ba0de53366cdfd8dacb373154648d0.zip |
Add additional ERB DummyCompiler tests
This adds a few additional tests to the commits by eileencodes (https://github.com/rails/rails/pull/35497) and rafaelfranca (https://github.com/rails/rails/commit/cfa22f1a4b5e8b95ee01a432168de2f831b3f788). The additional tests cover several more ERB tag formatting cases such as multiline tags, conditional statements that result in duplicate keys, and multiple erb statements on a single line.
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/rake/dbs_test.rb | 54 |
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 |