提交 a699f5d3 编写于 作者: R Rafael Mendonça França

Merge pull request #18309 from PaBLoX-CL/fix-fixtures-references

Generated fixtures won't use parent_id when generated with
parent:references
* Generated fixtures won't use the id when generated with references attributes.
*Pablo Olmos de Aguilera Corradini*
* Add `--skip-action-mailer` option to the app generator.
*claudiob*
......
......@@ -5,6 +5,8 @@
<% attributes.each do |attribute| -%>
<%- if attribute.password_digest? -%>
password_digest: <%%= BCrypt::Password.create('secret') %>
<%- elsif attribute.reference? -%>
<%= yaml_key_value(attribute.column_name.sub(/_id$/, ''), attribute.default) %>
<%- else -%>
<%= yaml_key_value(attribute.column_name, attribute.default) %>
<%- end -%>
......
......@@ -287,18 +287,18 @@ def test_invokes_default_test_framework
def test_fixtures_use_the_references_ids
run_generator ["LineItem", "product:references", "cart:belongs_to"]
assert_file "test/fixtures/line_items.yml", /product_id: \n cart_id: /
assert_file "test/fixtures/line_items.yml", /product: \n cart: /
assert_generated_fixture("test/fixtures/line_items.yml",
{"one"=>{"product_id"=>nil, "cart_id"=>nil}, "two"=>{"product_id"=>nil, "cart_id"=>nil}})
{"one"=>{"product"=>nil, "cart"=>nil}, "two"=>{"product"=>nil, "cart"=>nil}})
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: \n product_type: Product\n cart_id: /
assert_file "test/fixtures/line_items.yml", /product: \n product_type: Product\n cart: /
assert_generated_fixture("test/fixtures/line_items.yml",
{"one"=>{"product_id"=>nil, "product_type"=>"Product", "cart_id"=>nil},
"two"=>{"product_id"=>nil, "product_type"=>"Product", "cart_id"=>nil}})
{"one"=>{"product"=>nil, "product_type"=>"Product", "cart"=>nil},
"two"=>{"product"=>nil, "product_type"=>"Product", "cart"=>nil}})
end
def test_fixtures_respect_reserved_yml_keywords
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册