aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators/model_generator_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Remove duplicated testyuuji.yaginuma2019-04-201-12/+1
| | | | | | | With 8b4d344815655027d9f7584c0a59271dce8f1d5a, `test_required_polymorphic_belongs_to_generates_correct_model` and `test_required_and_polymorphic_are_order_independent` are completely same. Also, remove `required` from test name because that not passed to generator.
* Add `null: false` constraint by default for `belongs_to` associationsPrathamesh Sonpatki2019-04-191-4/+46
| | | | | | - Also deprecate passing {required} to the model generator. - Also made sure the global config `belongs_to_required_by_default` is applied correctly to the model generator for `null: false` option.
* Fix typo in test description from generages -> generatesAbhay Nikam2019-04-171-1/+1
|
* Remove `required: true` from the model generator templatePrathamesh Sonpatki2019-04-151-13/+2
| | | | | | | | `belongs_to` association have `required: true` by default https://github.com/rails/rails/pull/18937 onwards so we don't need it in the generator template. We still need the code for required in the command line generator as it adds `null: false` in the migration.
* Add attachment and attachments field generatorsChris Oliver2019-03-301-1/+21
|
* Add rich_text field to model generatorsChris Oliver2019-03-281-0/+17
|
* Make aliases of `database` option in generators workyuuji.yaginuma2019-03-201-0/+11
| | | | | | | | | | | Thor automatically adds `-` if aliases do not start with `-`. https://github.com/erikhuda/thor/blob/0879c1773d188902d54f95174f33961ac33111f8/lib/thor/parser/options.rb#L53 But Thor follows a convention of one-dash-one-letter options. So, even if `-` is added to `db`, it does not work. https://github.com/erikhuda/thor/blob/0879c1773d188902d54f95174f33961ac33111f8/lib/thor/parser/options.rb#L4 Follow up #34021.
* Railities typo fixes.alkesh262019-02-011-1/+1
|
* Refactor migrations_path command option to databaseGannon McGibbon2018-09-281-5/+7
|
* Add migrations_paths option to model generatorGannon McGibbon2018-09-271-0/+9
|
* Emit warning for unknown inflection rule when generating model.Yoshiyuki Kinjo2018-08-311-1/+18
| | | | | | For words like "abuse", Rails cannot derive its singular form from plural form "abuses" without defining custom inflection rule. `rails generate model` and its families now emit warning for this case.
* Remove usage of strip_heredoc in the framework in favor of <<~Rafael Mendonça França2018-02-161-18/+17
| | | | | Some places we can't remove because Ruby still don't have a method equivalent to strip_heredoc to be called in an already existent string.
* Adding frozen_string_literal pragma to Railties.Pat Allan2017-08-141-0/+2
|
* Stop creating ApplicationRecord on model generationLisa Ugray2017-07-241-19/+0
| | | | | | | | | | | | | | When generating models, we created ApplicationRecord in the default location if no file existed there. That was annoying for people who moved it to somewhere else in the autoload path. At this point, the vast majority of apps should have either run the upgrade script or generated a model since upgrading. For those that haven't the error message after generating a new model should be helpful: NameError: uninitialized constant ApplicationRecord To ease friction in that case, this also adds a generator for ApplicationRecord.
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Should escape meta characters in regexpRyuta Kamizono2017-05-071-6/+6
|
* Move config reset to ensure blockAndrew White2017-01-171-1/+2
| | | | We don't want to leak the extra migration path to other railties tests.
* Generate migrations at path set by `config.paths["db/migrate"]`Kevin Glowacz2017-01-161-0/+10
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-8/+8
|
* Add three new rubocop rulesRafael Mendonça França2016-08-161-8/+8
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-7/+7
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-6/+6
|
* applies new string literal convention in railties/testXavier Noria2016-08-061-3/+3
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Generate application_record.rb file before model fileWojciech Wnętrzak2016-06-081-7/+7
| | | | | | Previously model file was generated first, which resulted in inheriting from `ActiveRecord::Base`, but since application_record.rb is generated as well, it should already be used.
* Generate ApplicationRecord if it does not already existJon Moss2016-02-221-0/+8
|
* set association name to generated fixtures if attribute is referenceyuuji.yaginuma2016-02-061-5/+5
| | | | | | | 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
* Pare back default `index` option for the migration generatorPrathamesh Sonpatki2016-01-241-20/+0
| | | | | | | | | | - Using `references` or `belongs_to` in migrations will always add index for the referenced column by default, without adding `index:true` option to generated migration file. - Users can opt out of this by passing `index: false`. - Legacy migrations won't be affected by this change. They will continue to run as they were before. - Fixes #18146
* Introduce ApplicationRecord, an Active Record layer supertypeGenadi Samokovarov2015-12-161-0/+11
| | | | | | | | | | | | | | | | It's pretty common for folks to monkey patch `ActiveRecord::Base` to work around an issue or introduce extra functionality. Instead of shoving even more stuff in `ActiveRecord::Base`, `ApplicationRecord` can hold all those custom work the apps may need. Now, we don't wanna encourage all of the application models to inherit from `ActiveRecord::Base`, but we can encourage all the models that do, to inherit from `ApplicationRecord`. Newly generated applications have `app/models/application_record.rb` present by default. The model generators are smart enough to recognize that newly generated models have to inherit from `ApplicationRecord`, but only if it's present.
* Ensure generated migrations include a version numberMatthew Draper2015-12-151-8/+8
|
* Use thor class_option to make the primary_key_type option workRafael Mendonça França2015-10-231-0/+9
| | | | Also move the method to the right class
* respect `pluralize_table_names` when generate fixture file. fixes #19519yuuji.yaginuma2015-03-271-0/+10
|
* Add Secure Token Generatorrobertomiranda2015-01-111-0/+11
|
* Change the default `null` value for `timestamps` to `false`Rafael Mendonça França2015-01-041-1/+1
|
* Generated fixtures won't use parent_id when generated with parent:referencesPablo Olmos de Aguilera Corradini2015-01-021-5/+5
| | | | Fix #18301
* Use the new `foreign_key` option on `references` in generatorsSean Griffin2014-12-221-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes `rails g model Post user:references` from def change create_table :posts do |t| t.references :user, index: true end add_foreign_key :posts, :users end to def change create_table :posts do |t| t.references :user, index: true, foreign_key: true end end Changes `rails g migration add_user_to_posts user:references` from def change add_reference :posts, :users, index: true add_foreign_key :posts, :users end to def change add_reference :posts, :users, index: true, foreign_key: true end
* Generators add foreign keys on referencesDerek Prior2014-11-251-0/+21
| | | | | | | | | | | If you run a generator such as: ``` rails generate model accounts supplier:references ``` The resulting migration will now add the corresponding foreign key constraint unless the reference was specified to be polymorphic.
* Merge pull request #16062 from sgrif/sg-required-generatorsRafael Mendonça França2014-08-171-0/+44
|\ | | | | Add a `required` option to the model generator
| * Add a `required` option to the model generatorSean Griffin2014-08-081-0/+44
| | | | | | | | | | | | | | | | | | | | | | Syntax was chosen to follow the passing of multiple options to decimal/numeric types. Curly braces, and allowing any of `,`, `.`, or `-` to be used as a separator to avoid the need for shell quoting. (I'm intending to expand this to all columns, but that's another PR. The `required` option will cause 2 things to change. `required: true` will be added to the association. `null: false` will be added to the column in the migration.
* | Change the default `null` value for timestampsSean Griffin2014-08-121-1/+1
|/ | | | | | | As per discussion, this changes the model generators to specify `null: false` for timestamp columns. A warning is now emitted if `timestamps` is called without a `null` option specified, so we can safely change the behavior when no option is specified in Rails 5.
* modify model generator warning message. refs [#174c9f0]Kuldeep Aggarwal2014-02-271-1/+1
|
* include names in model generator warning message. refs #13515.Yves Senn2014-02-241-1/+1
| | | | | | This is a follow up to #13515. It includes the name given and the singularized version in the warning message. This will aide the user to see wether the detected singular was right or not.
* Add warning when user tried to create model with pluralize name.Kuldeep Aggarwal2014-02-231-0/+7
| | | | | 1. Generate model with correct_name. 2. It will help new users to avoid mistakes when tried to create model with wrong name.
* Consistent use of single and double quotesRafael Mendonça França2012-12-261-10/+10
|
* quote column names in generated fixture filesYves Senn2012-12-261-3/+26
|
* Make sure that no extra spaces are created with a non-polymorphicRafael Mendonça França2012-12-101-2/+2
| | | | attributes
* Deal with polymorphic attributes correctly in the generatorsRafael Mendonça França2012-12-101-0/+5
|
* Make references and belongs_to attributes to generate the _id column inRafael Mendonça França2012-12-101-0/+5
| | | | fixtures
* Use Ruby 1.9 Hash syntax in railtiesRobin Dupret2012-10-141-3/+3
|
* Update test locationsMike Moore2012-10-091-3/+3
| | | | | | | | | | | | | | Change the default test locations to avoid confusion around the common testing terms "unit" and "functional". Add new rake tasks for the new locations, while maintaining backwards compatibility with the old rake tasks. New testing locations are as follows: app/models -> test/models (was test/units) app/helpers -> test/helpers (was test/units/helpers) app/controllers -> test/controllers (was test/functional) app/mailers -> test/mailers (was test/functional)