aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/generators')
-rw-r--r--railties/test/generators/rails_scaffold_generator_test.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/railties/test/generators/rails_scaffold_generator_test.rb b/railties/test/generators/rails_scaffold_generator_test.rb
index 220f9e372e..de6b38dafe 100644
--- a/railties/test/generators/rails_scaffold_generator_test.rb
+++ b/railties/test/generators/rails_scaffold_generator_test.rb
@@ -1,4 +1,5 @@
require 'generators/generator_test_helper'
+require 'abstract_unit'
class RailsScaffoldGeneratorTest < GeneratorTestCase
@@ -104,4 +105,45 @@ class RailsScaffoldGeneratorTest < GeneratorTestCase
assert_added_route_for :products
end
+ uses_mocha("scaffold_force_plural_names") do
+ def test_scaffolded_plural_names
+ Rails::Generator::Base.logger.expects(:warning)
+ g = Rails::Generator::Base.instance('scaffold', %w(ProductLines))
+ assert_equal "ProductLines", g.controller_name
+ assert_equal "ProductLines", g.controller_class_name
+ assert_equal "ProductLine", g.controller_singular_name
+ assert_equal "product_lines", g.controller_plural_name
+ assert_equal "product_lines", g.controller_file_name
+ assert_equal "product_lines", g.controller_table_name
+ end
+ end
+
+ def test_scaffold_plural_model_name_without_force_plural_generates_singular_model
+ run_generator('scaffold', %w(Products name:string))
+
+ assert_generated_model_for :product
+ assert_generated_functional_test_for :products
+ assert_generated_unit_test_for :product
+ assert_generated_fixtures_for :products
+ assert_generated_helper_for :products
+ assert_generated_stylesheet :scaffold
+ assert_generated_views_for :products, "index.html.erb","new.html.erb","edit.html.erb","show.html.erb"
+ assert_skipped_migration :create_products
+ assert_added_route_for :products
+ end
+
+ def test_scaffold_plural_model_name_with_force_plural_forces_plural_model
+ run_generator('scaffold', %w(Products name:string --force-plural))
+
+ assert_generated_model_for :products
+ assert_generated_functional_test_for :products
+ assert_generated_unit_test_for :products
+ assert_generated_fixtures_for :products
+ assert_generated_helper_for :products
+ assert_generated_stylesheet :scaffold
+ assert_generated_views_for :products, "index.html.erb","new.html.erb","edit.html.erb","show.html.erb"
+ assert_skipped_migration :create_products
+ assert_added_route_for :products
+ end
+
end