diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2015-03-27 10:08:04 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2015-03-27 17:30:43 +0900 |
commit | 71c7c68e2ddaf8481157aaf70384b1bb0a8d9348 (patch) | |
tree | 92fe0c2122b140dfd61b3e0553bba1ff5e85a673 /railties/lib | |
parent | 8b451e3a315666b93da43e7b61503014661f0ac6 (diff) | |
download | rails-71c7c68e2ddaf8481157aaf70384b1bb0a8d9348.tar.gz rails-71c7c68e2ddaf8481157aaf70384b1bb0a8d9348.tar.bz2 rails-71c7c68e2ddaf8481157aaf70384b1bb0a8d9348.zip |
respect `pluralize_table_names` when generate fixture file. fixes #19519
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/generators/named_base.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/test_unit/model/model_generator.rb | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index 36456e64f5..01a8e2e9b4 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -141,6 +141,10 @@ module Rails @plural_file_name ||= file_name.pluralize end + def fixture_file_name + @fixture_file_name ||= (pluralize_table_names? ? plural_file_name : file_name) + end + def route_url @route_url ||= class_path.collect {|dname| "/" + dname }.join + "/" + plural_file_name end diff --git a/railties/lib/rails/generators/test_unit/model/model_generator.rb b/railties/lib/rails/generators/test_unit/model/model_generator.rb index 2826a3ffa1..086588750e 100644 --- a/railties/lib/rails/generators/test_unit/model/model_generator.rb +++ b/railties/lib/rails/generators/test_unit/model/model_generator.rb @@ -19,7 +19,7 @@ module TestUnit # :nodoc: def create_fixture_file if options[:fixture] && options[:fixture_replacement].nil? - template 'fixtures.yml', File.join('test/fixtures', class_path, "#{plural_file_name}.yml") + template 'fixtures.yml', File.join('test/fixtures', class_path, "#{fixture_file_name}.yml") end end |