aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators/resource_generator_test.rb
diff options
context:
space:
mode:
authorGenadi Samokovarov <gsamokovarov@gmail.com>2016-04-27 18:30:17 +0300
committerGenadi Samokovarov <gsamokovarov@gmail.com>2016-04-28 10:12:06 +0300
commite6ed3aaf437887bc25a1f715f21c5ca3ebbc966f (patch)
tree8b24be4de8e045828209d724e1a6402028e4b907 /railties/test/generators/resource_generator_test.rb
parentabff83e60e9d91975b4788ef9cca388ab2536c10 (diff)
downloadrails-e6ed3aaf437887bc25a1f715f21c5ca3ebbc966f.tar.gz
rails-e6ed3aaf437887bc25a1f715f21c5ca3ebbc966f.tar.bz2
rails-e6ed3aaf437887bc25a1f715f21c5ca3ebbc966f.zip
Always genererate models with ApplicationRecord parent
Currently, if we generate a model while `app/model/application_record.rb` isn't present, we'll end up with a model with an `ActiveRecord::Base` parent _and_ a newly generated `app/models/application_record.rb`. While the behavior for choosing an `ActiveRecord::Base` was chosen for an easier migration math to 5.0, generating the `app/model/application_record.rb` file kinda contradicts with it. In any case, I think we should decide on a behavior and stick to it. Here, I'm changing the generated parent to always be `ApplicationRecord` and to always create `app/model/application_record.rb` if it doesn't exist.
Diffstat (limited to 'railties/test/generators/resource_generator_test.rb')
-rw-r--r--railties/test/generators/resource_generator_test.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/railties/test/generators/resource_generator_test.rb b/railties/test/generators/resource_generator_test.rb
index addaf83bc8..53dcfc4024 100644
--- a/railties/test/generators/resource_generator_test.rb
+++ b/railties/test/generators/resource_generator_test.rb
@@ -60,14 +60,14 @@ class ResourceGeneratorTest < Rails::Generators::TestCase
def test_plural_names_are_singularized
content = run_generator ["accounts".freeze]
- assert_file "app/models/account.rb", /class Account < ActiveRecord::Base/
+ assert_file "app/models/account.rb", /class Account < ApplicationRecord/
assert_file "test/models/account_test.rb", /class AccountTest/
assert_match(/\[WARNING\] The model name 'accounts' was recognized as a plural, using the singular 'account' instead\. 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
content = run_generator ["accounts", "--force-plural"]
- assert_file "app/models/accounts.rb", /class Accounts < ActiveRecord::Base/
+ assert_file "app/models/accounts.rb", /class Accounts < ApplicationRecord/
assert_file "test/models/accounts_test.rb", /class AccountsTest/
assert_no_match(/\[WARNING\]/, content)
end