1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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 (cfa22f1a4b). 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.
This commit is contained in:
Cliff Pruitt 2019-03-12 08:34:41 -04:00
parent 4948663b32
commit 44f3530274

View file

@ -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