Make references and belongs_to attributes to generate the _id column in

fixtures
This commit is contained in:
Rafael Mendonça França 2012-12-09 14:34:26 -03:00
parent 3d8fcdd3bf
commit 4a487f94b9
2 changed files with 7 additions and 2 deletions

@ -3,12 +3,12 @@
<% unless attributes.empty? -%>
one:
<% attributes.each do |attribute| -%>
<%= attribute.name %>: <%= attribute.default %>
<%= attribute.reference? ? "#{attribute.name}_id" : attribute.name %>: <%= attribute.default %>
<% end -%>
two:
<% attributes.each do |attribute| -%>
<%= attribute.name %>: <%= attribute.default %>
<%= attribute.reference? ? "#{attribute.name}_id" : attribute.name %>: <%= attribute.default %>
<% end -%>
<% else -%>
# This model initially had no columns defined. If you add columns to the

@ -273,6 +273,11 @@ def test_invokes_default_test_framework
assert_file "test/fixtures/accounts.yml", /name: MyString/, /age: 1/
end
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: /
end
def test_fixture_is_skipped
run_generator ["account", "--skip-fixture"]
assert_no_file "test/fixtures/accounts.yml"