mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Make sure that no extra spaces are created with a non-polymorphic
attributes
This commit is contained in:
parent
d668544785
commit
8dac9768b1
2 changed files with 8 additions and 4 deletions
|
@ -4,13 +4,17 @@
|
||||||
one:
|
one:
|
||||||
<% attributes.each do |attribute| -%>
|
<% attributes.each do |attribute| -%>
|
||||||
<%= attribute.column_name %>: <%= attribute.default %>
|
<%= 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 -%>
|
<% end -%>
|
||||||
|
|
||||||
two:
|
two:
|
||||||
<% attributes.each do |attribute| -%>
|
<% attributes.each do |attribute| -%>
|
||||||
<%= attribute.column_name %>: <%= attribute.default %>
|
<%= 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 -%>
|
<% end -%>
|
||||||
<% else -%>
|
<% else -%>
|
||||||
# This model initially had no columns defined. If you add columns to the
|
# This model initially had no columns defined. If you add columns to the
|
||||||
|
|
|
@ -275,12 +275,12 @@ class ModelGeneratorTest < Rails::Generators::TestCase
|
||||||
|
|
||||||
def test_fixtures_use_the_references_ids
|
def test_fixtures_use_the_references_ids
|
||||||
run_generator ["LineItem", "product:references", "cart:belongs_to"]
|
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
|
end
|
||||||
|
|
||||||
def test_fixtures_use_the_references_ids_and_type
|
def test_fixtures_use_the_references_ids_and_type
|
||||||
run_generator ["LineItem", "product:references{polymorphic}", "cart:belongs_to"]
|
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
|
end
|
||||||
|
|
||||||
def test_fixture_is_skipped
|
def test_fixture_is_skipped
|
||||||
|
|
Loading…
Reference in a new issue