diff options
author | Eileen M. Uchitelle <eileencodes@users.noreply.github.com> | 2019-05-16 10:26:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-16 10:26:58 +0300 |
commit | 9c87d2316adf36cf33b1b7afe8d779bf420c52a7 (patch) | |
tree | d2fc009dce367df6d3b110df2a87eef2e836400d /railties | |
parent | 3d70e9609760cb3046cf219cd49f3e9a838a0291 (diff) | |
parent | ae9be137133530913d4ee13980eabc2577de317f (diff) | |
download | rails-9c87d2316adf36cf33b1b7afe8d779bf420c52a7.tar.gz rails-9c87d2316adf36cf33b1b7afe8d779bf420c52a7.tar.bz2 rails-9c87d2316adf36cf33b1b7afe8d779bf420c52a7.zip |
Merge pull request #36286 from vishaltelangre/dummy-erb-compiler-fix
Fix: DummyCompiler embeds invalid YAML content
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/application/dummy_erb_compiler.rb | 10 | ||||
-rw-r--r-- | railties/test/application/rake/dbs_test.rb | 17 |
2 files changed, 19 insertions, 8 deletions
diff --git a/railties/lib/rails/application/dummy_erb_compiler.rb b/railties/lib/rails/application/dummy_erb_compiler.rb index 086b9e76f4..028e790292 100644 --- a/railties/lib/rails/application/dummy_erb_compiler.rb +++ b/railties/lib/rails/application/dummy_erb_compiler.rb @@ -11,14 +11,8 @@ end class DummyCompiler < ERB::Compiler # :nodoc: def compile_content(stag, out) - case stag - when "<%=" - content = out.instance_variable_get(:@compiler).instance_variable_get(:@content) - if content.include?("?") && content.include?(":") - out.push "_erbout << 'dummy_key: dummy_value'" - else - out.push "_erbout << 'dummy_value'" - end + if stag == "<%=" + out.push "_erbout << ''" end end end diff --git a/railties/test/application/rake/dbs_test.rb b/railties/test/application/rake/dbs_test.rb index ca2d45b1c9..e08cd09abd 100644 --- a/railties/test/application/rake/dbs_test.rb +++ b/railties/test/application/rake/dbs_test.rb @@ -138,6 +138,23 @@ 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 which contains a key's value as an ERB statement" do + app_file "config/database.yml", <<-YAML + development: + database: <%= Rails.application.config.database ? 'db/development.sqlite3' : 'db/development.sqlite3' %> + custom_option: <%= ENV['CUSTOM_OPTION'] %> + 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 |