Make references and belongs_to attributes to generate the _id column in
fixtures
This commit is contained in:
parent
3d8fcdd3bf
commit
4a487f94b9
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user