diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2016-02-06 12:15:28 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2016-02-06 22:41:10 +0900 |
commit | 00c64e8ae2c312139e5a242331d3919fe139b87c (patch) | |
tree | bb288cd407edc377251f51bbb467662fe9639aed /railties/lib/rails/generators/test_unit | |
parent | c909a0060795716c745a3aa23d5297ac69da3e6f (diff) | |
download | rails-00c64e8ae2c312139e5a242331d3919fe139b87c.tar.gz rails-00c64e8ae2c312139e5a242331d3919fe139b87c.tar.bz2 rails-00c64e8ae2c312139e5a242331d3919fe139b87c.zip |
set association name to generated fixtures if attribute is reference
It has been changed to require `belongs_to` by default in Rails 5.
Therefore in order to pass the controller test, have association of set to fixtures.
Fixes #23384
Diffstat (limited to 'railties/lib/rails/generators/test_unit')
-rw-r--r-- | railties/lib/rails/generators/test_unit/model/templates/fixtures.yml | 2 |
1 files changed, 1 insertions, 1 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 2656767eb4..0681780c97 100644 --- a/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml +++ b/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml @@ -6,7 +6,7 @@ <%- if attribute.password_digest? -%> password_digest: <%%= BCrypt::Password.create('secret') %> <%- elsif attribute.reference? -%> - <%= yaml_key_value(attribute.column_name.sub(/_id$/, ''), attribute.default) %> + <%= yaml_key_value(attribute.column_name.sub(/_id$/, ''), attribute.default || name) %> <%- else -%> <%= yaml_key_value(attribute.column_name, attribute.default) %> <%- end -%> |