aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators
diff options
context:
space:
mode:
authorKuldeep Aggarwal <kd.engineer@yahoo.co.in>2014-02-23 13:10:41 +0530
committerKuldeep Aggarwal <kd.engineer@yahoo.co.in>2014-02-23 13:10:41 +0530
commitde8bef98785a78332db037b1cd6f602b2a30026d (patch)
treecfa7e92be5ec569a38e1044063e9b2c292845616 /railties/test/generators
parent020c78341897afc170041eac1e57801f0d78ce90 (diff)
downloadrails-de8bef98785a78332db037b1cd6f602b2a30026d.tar.gz
rails-de8bef98785a78332db037b1cd6f602b2a30026d.tar.bz2
rails-de8bef98785a78332db037b1cd6f602b2a30026d.zip
Add warning when user tried to create model with pluralize name.
1. Generate model with correct_name. 2. It will help new users to avoid mistakes when tried to create model with wrong name.
Diffstat (limited to 'railties/test/generators')
-rw-r--r--railties/test/generators/model_generator_test.rb7
-rw-r--r--railties/test/generators/resource_generator_test.rb2
2 files changed, 8 insertions, 1 deletions
diff --git a/railties/test/generators/model_generator_test.rb b/railties/test/generators/model_generator_test.rb
index 01ab77ee20..cf307d23e1 100644
--- a/railties/test/generators/model_generator_test.rb
+++ b/railties/test/generators/model_generator_test.rb
@@ -34,6 +34,13 @@ class ModelGeneratorTest < Rails::Generators::TestCase
assert_no_migration "db/migrate/create_accounts.rb"
end
+ def test_plural_names_are_singularized
+ content = run_generator ["accounts".freeze]
+ assert_file "app/models/account.rb", /class Account < ActiveRecord::Base/
+ assert_file "test/models/account_test.rb", /class AccountTest/
+ assert_match(/Plural version of the model detected, using singularized version. Override with --force-plural or setup custom inflection rules for this noun before running the generator./, content)
+ end
+
def test_model_with_underscored_parent_option
run_generator ["account", "--parent", "admin/account"]
assert_file "app/models/account.rb", /class Account < Admin::Account/
diff --git a/railties/test/generators/resource_generator_test.rb b/railties/test/generators/resource_generator_test.rb
index 3d4e694361..297cf99998 100644
--- a/railties/test/generators/resource_generator_test.rb
+++ b/railties/test/generators/resource_generator_test.rb
@@ -63,7 +63,7 @@ class ResourceGeneratorTest < Rails::Generators::TestCase
content = run_generator ["accounts".freeze]
assert_file "app/models/account.rb", /class Account < ActiveRecord::Base/
assert_file "test/models/account_test.rb", /class AccountTest/
- assert_match(/Plural version of the model detected, using singularized version. Override with --force-plural./, content)
+ assert_match(/Plural version of the model detected, using singularized version. Override with --force-plural or setup custom inflection rules for this noun before running the generator./, content)
end
def test_plural_names_can_be_forced