diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-12-10 23:16:48 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-12-10 23:16:48 -0300 |
commit | 8dac9768b16c6cfaffa6c84abaaa7c4926020e0b (patch) | |
tree | c8d3b7d22a98dcb863d286aac88540d02e341fb1 | |
parent | d668544785550712677ae999dfb0644e640ec729 (diff) | |
download | rails-8dac9768b16c6cfaffa6c84abaaa7c4926020e0b.tar.gz rails-8dac9768b16c6cfaffa6c84abaaa7c4926020e0b.tar.bz2 rails-8dac9768b16c6cfaffa6c84abaaa7c4926020e0b.zip |
Make sure that no extra spaces are created with a non-polymorphic
attributes
-rw-r--r-- | railties/lib/rails/generators/test_unit/model/templates/fixtures.yml | 8 | ||||
-rw-r--r-- | railties/test/generators/model_generator_test.rb | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml b/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml index b2bcaf63be..7625ff975c 100644 --- a/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml +++ b/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml @@ -4,13 +4,17 @@ one: <% attributes.each do |attribute| -%> <%= attribute.column_name %>: <%= attribute.default %> - <%= "#{attribute.name}_type: #{attribute.human_name}" if attribute.polymorphic? %> + <%- if attribute.polymorphic? -%> + <%= "#{attribute.name}_type: #{attribute.human_name}" %> + <%- end -%> <% end -%> two: <% attributes.each do |attribute| -%> <%= attribute.column_name %>: <%= attribute.default %> - <%= "#{attribute.name}_type: #{attribute.human_name}" if attribute.polymorphic? %> + <%- if attribute.polymorphic? -%> + <%= "#{attribute.name}_type: #{attribute.human_name}" %> + <%- end -%> <% end -%> <% else -%> # This model initially had no columns defined. If you add columns to the diff --git a/railties/test/generators/model_generator_test.rb b/railties/test/generators/model_generator_test.rb index 0fbaf0c9bb..70e080a8ab 100644 --- a/railties/test/generators/model_generator_test.rb +++ b/railties/test/generators/model_generator_test.rb @@ -275,12 +275,12 @@ class ModelGeneratorTest < Rails::Generators::TestCase def test_fixtures_use_the_references_ids run_generator ["LineItem", "product:references", "cart:belongs_to"] - assert_file "test/fixtures/line_items.yml", /product_id: /, /cart_id: / + assert_file "test/fixtures/line_items.yml", /product_id: \n cart_id: / end def test_fixtures_use_the_references_ids_and_type run_generator ["LineItem", "product:references{polymorphic}", "cart:belongs_to"] - assert_file "test/fixtures/line_items.yml", /product_id: /, /product_type: Product/, /cart_id: / + assert_file "test/fixtures/line_items.yml", /product_id: \n product_type: Product\n cart_id: / end def test_fixture_is_skipped |