aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators/scaffold_generator_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Make generated test work even when using virtual attributesyuuji.yaginuma2019-05-051-0/+30
| | | | | | | | | The virtual attributes(`attachment` and `rich_text`) can't set value with `fill_in`. So avoid using it. Once #35885 is merged, will be modified to use it. Also, add checking attachment attached or not for avoiding `DelegationError` when attachment didn't attach.
* Add attachment and attachments field generatorsChris Oliver2019-03-301-0/+18
|
* Make aliases of `database` option in generators workyuuji.yaginuma2019-03-201-0/+8
| | | | | | | | | | | 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.
* Fix boolean interaction in scaffold system testsGannon McGibbon2018-12-121-3/+5
|
* Show object ids in scaffold pages when displaying referenced objectsRasesh Patel2018-10-141-3/+13
| | | | | | | | | | | | Resolve Issue#29200 When scaffolding a model that references another model the generated show and index html pages display the object directly on the page. Basically, it just shows a memory address. That is not very helpful. In this commit we show the object's id rather than the memory address. This updates the scaffold templates and the json builder files.
* Make Webpacker the default JavaScript compiler for Rails 6 (#33079)David Heinemeier Hansson2018-09-301-19/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Use Webpacker by default on new apps * Stop including coffee-rails by default * Drop using a js_compressor by default * Drop extra test for coffeescript inclusion by default * Stick with skip_javascript to signify skipping webpack * Don't install a JS runtime by default any more * app/javascript will be the new default directory for JS * Make it clear that this is just for configuring the default Webpack framework setup now * Start using the Webpack tag in the default layout * Irrelevant test * jQuery is long gone * Stop having asset pipeline compile default application.js * Add rails-ujs by default to the Webpack setup * Add Active Storage JavaScript to application.js pack by default * Consistent quoting * Add Turbolinks to default pack * Add Action Cable to default pack Need some work on how to set the global consumer that channels will work with. @javan? * Require all channels by default and use a separate consumer stub * Channel generator now targets Webpack style * Update task docs to match new generator style * Use uniform import style * Drop the JS assets generator It was barely helpful as it was. It’s no longer helpful in a Webpacked world. Sayonara! * Add app/javascript to the stats directories * Simpler import style Which match the other imports. * Address test failures from dropping JS compilation (and compression) * webpacker-default: Modify `AssetsGeneratorTest` Before: ``` $ bin/test test/generators/assets_generator_test.rb Run options: --seed 46201 F Failure: AssetsGeneratorTest#test_assets [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/assets_generator_test.rb:12]: Expected file "app/assets/javascripts/posts.js" to exist, but does not bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/assets_generator_test.rb:10 . Finished in 0.031343s, 63.8101 runs/s, 95.7152 assertions/s. 2 runs, 3 assertions, 1 failures, 0 errors, 0 skips ``` After: ``` $ bin/test test/generators/assets_generator_test.rb Run options: --seed 43571 .. Finished in 0.030370s, 65.8545 runs/s, 65.8545 assertions/s. 2 runs, 2 assertions, 0 failures, 0 errors, 0 skips ``` * webpacker-default: Modify `ChannelGeneratorTest` Before: ``` $ bin/test test/generators/channel_generator_test.rb Run options: --seed 8986 .F Failure: ChannelGeneratorTest#test_channel_with_multiple_actions_is_created [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:43]: Expected file "app/assets/javascripts/channels/chat.js" to exist, but does not bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:34 .F Failure: ChannelGeneratorTest#test_channel_is_created [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:29]: Expected file "app/assets/javascripts/channels/chat.js" to exist, but does not bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:22 E Error: ChannelGeneratorTest#test_cable_js_is_created_if_not_present_already: Errno::ENOENT: No such file or directory @ apply2files - /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/fixtures/tmp/app/assets/javascripts/cable.js bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:60 F Failure: ChannelGeneratorTest#test_channel_suffix_is_not_duplicated [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:87]: Expected file "app/assets/javascripts/channels/chat.js" to exist, but does not bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:80 F Failure: ChannelGeneratorTest#test_channel_on_revoke [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:77]: Expected file "app/assets/javascripts/cable.js" to exist, but does not bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:68 Finished in 0.064384s, 108.7227 runs/s, 481.4861 assertions/s. 7 runs, 31 assertions, 4 failures, 1 errors, 0 skips ``` After: ``` $ bin/test test/generators/channel_generator_test.rb Run options: --seed 44857 ....... Finished in 0.060243s, 116.1961 runs/s, 697.1764 assertions/s. 7 runs, 42 assertions, 0 failures, 0 errors, 0 skips ``` * Fix shared generator tests. * webpacker-default: Modify `ControllerGeneratorTest` The JS assets generator was dropped. ref. https://github.com/rails/rails/commit/46215b179483d3e4d264555f5a4952f43eb8142a * Revert "Simpler import style". It's currently failing with an error of "TypeError: undefined is not an object (evaluating '__WEBPACK_IMPORTED_MODULE_2_activestorage___default.a.start')". Waiting for @javan to have a look. This reverts commit 5d3ebb71059f635d3756cbda4ab9752027e09256. * require webpacker in test app * Add webpacker without making the build hang/timeout. (#33640) * use yarn workspaces to allow for installing unreleased packages and only generate js/bootsnap when required * no longer need to have webpacker in env templates as webpacker moved this config to yml file * Fix rubocop violation * Got the test passing for the running scaffold * update expected lines of code * update middleware tests to account for webpacker * disable js in plugins be default to get the tests passing (#34009) * clear codeclimate report issues * Anything newer than currently released is good * Use Webpacker development version during development of Rails * Edge should get development webpacker as well * Add changelog entry for Webpacker change
* Refactor migrations_path command option to databaseGannon McGibbon2018-09-281-3/+5
|
* Add migrations_paths option to model generatorGannon McGibbon2018-09-271-0/+6
|
* Generate the same value as a label of view in system test templateyuuji.yaginuma2018-08-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | In the system test template, enter a value based on label. However, since `label` method does not use `titleize` by default. If generate a value including underscore, cannot find a label and the test will fail. ``` $ ./bin/rails g scaffold user name:string phone_number:string $ ./bin/rails t test/system/users_test.rb E Error: UsersTest#test_creating_a_User: Capybara::ElementNotFound: Unable to find field "Phone Number" test/system/users_test.rb:18:in `block in <class:UsersTest>' ``` This removes unnecessary `titleize` so that the generated file will pass even if the attribute contains an underscore.
* prefer File.write for bulk writesXavier Noria2018-05-051-2/+2
| | | | | | | | | | | | | | | | | | I saw these ones while working on #32362. File.write was introduced in Ruby 1.9.3 and it is the most concise way to perform bulk writes (as File.read is for bulk reading). The existing flags enabled binmode, but we are dumping text here. The portable way to dump text is text mode. The only difference is newlines, and portable code should in particular emit portable newlines. Please note the hard-coded \ns are still correct. In languages with C semantics for newlines like Ruby, Python, Perl, and others, "\n" is a portable newline. Both when writing and when reading. On Windows, the I/O layer is responsible for prepending a CR before each LF on writing, and removing CRs followed by LFs on reading. On Unix, binmode is a no-op.
* Remove field ids from scaffold formyuuji.yaginuma2017-11-261-4/+4
| | | | | | This was added with 27f103fc7e3260efe0b8dde66bf5354f2202ee32 for link labels and fields. However, `form_with` changed to generates ids by default with d3893ec38ec61282c2598b01a298124356d6b35a. So I think that adding an explicit ids is unnecessary.
* Generate the correct path in nested scaffold generatoryuuji.yaginuma2017-11-051-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, namespaced scaffold generator will generate an incorrect path and the generated file will not work properly. ``` $ ./bin/rails g scaffold admin/user $ ./bin/rails db:migrate $ ./bin/rails t test/controllers # Running: E Error: Admin::UsersControllerTest#test_should_create_admin_user: NameError: undefined local variable or method `admin_admin_users_url' for #<Admin::UsersControllerTest:0x000055a59f25ff68> Did you mean? admin_users test/controllers/admin/users_controller_test.rb:20:in `block (2 levels) in <class:UsersControllerTest>' test/controllers/admin/users_controller_test.rb:19:in `block in <class:UsersControllerTest>' bin/rails test test/controllers/admin/users_controller_test.rb:18 ``` This is because combine `controller_class_path` and `singular_table_name` to generate route. https://github.com/rails/rails/blob/360698aa245b45349d1d1b12e1afb34759515e69/railties/lib/rails/generators/named_base.rb#L172 Normally, if using namspaced generator, table name already contains namespace. Therefore, adding `controller_class_path` adds extra namespace. Since it is special only when explicitly specifying `model-name`, it is modified to change the value only when `model-name`is specified. Follow up of #30729
* Adding frozen_string_literal pragma to Railties.Pat Allan2017-08-141-0/+2
|
* 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.
* Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-021-0/+1
|\ | | | | | | Enforce frozen string in Rubocop
| * Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
| |
* | Add system tests to generate scaffoldDinah Shi2017-06-301-0/+34
|/
* add field ids when generating a scaffold form.Yves Senn2017-03-261-4/+4
| | | | | | This is a follow up to a6d065e. When using `form_with` you must supply field ids manually. Since the scaffold generator is using labels we need to make sure that they are linked up properly.
* Default to yielding a `form` variable.Kasper Timm Hansen2017-03-201-4/+4
| | | | More intention revealing and means `f` can go F itself 😋
* Make destroy command work within enginesyuuji.yaginuma2017-03-141-0/+55
| | | | | Instead of calling methods of Rails.application directly, we need to use a method that is considered for the rails engine.
* Move and rename system testseileencodes2017-02-201-1/+1
| | | | | | | | | | * Move system tests back into Action Pack * Rename `ActionSystemTest` to `ActionDispatch::SystemTestCase` * Remove private base module and only make file for public `SystemTestCase` class, name private module `SystemTesting` * Rename `ActionSystemTestCase` to `ApplicationSystemTestCase` * Update corresponding documentation and guides * Delete old `ActionSystemTest` files
* Turn system testing into it's own gem and renameeileencodes2017-02-201-1/+1
| | | | | | | | | | Renames `Rails::SystemTestCase` to `ActionSystemTest` and moves it to a gem under the Rails name. We need to name the class `ActionSystemTestCase` because the gem expects a module but tests themselves expect a class. Adds MIT-LICENSE, CHANGELOG, and README for the future.
* Add tests for system testingeileencodes2017-02-201-0/+5
| | | | | | | | | | * Adds test case test * Adds driver adapter test * Adds tests for capybara seleium driver (testing the settings not actually opening the browser to test capybara w/ selenium because that would so so so slow) * Adds tests for rack test driver * Adds tests for generators
* Fix generator command for nested (namespaced) rails engine (take 2)Fumiaki MATSUSHIMA2017-01-071-0/+20
| | | | | | | | | | | | | | | | | | | Rewrite https://github.com/rails/rails/pull/27550 085546df45 was reverted (b6ffb5efcb) because it change the return of `namespaced_path` from String to Array. ---------------- If we create nested (namespaced) rails engine such like bukkits-admin, `bin/rails g scaffold User name:string age:integer` will create `bukkits-admin/app/controllers/bukkits/users_controller.rb` but it should create `bukkits-admin/app/controllers/bukkits/admin/users_controller.rb`. In #6643, we changed `namespaced_path` as root path because we supposed application_controller is always in root but nested rails engine's application_controller will not.
* Revert "Merge pull request #27550 from ↵Rafael Mendonça França2017-01-031-20/+0
| | | | | | | | | mtsmfm/fix-generator-command-for-nested-rails-engine" This reverts commit 1e969bfb98b88799e2c759fce25a1d8cf00d7ce7, reversing changes made to a5041f267ded119c2d00b8786c2f2c1e3f93c8a1. Reason: It breaks the public API
* Fix generator command for nested (namespaced) rails engineFumiaki MATSUSHIMA2017-01-031-0/+20
| | | | | | | | | | | | | If we create nested (namespaced) rails engine such like bukkits-admin, `bin/rails g scaffold User name:string age:integer` will create `bukkits-admin/app/controllers/bukkits/users_controller.rb` but it should create `bukkits-admin/app/controllers/bukkits/admin/users_controller.rb`. In #6643, we changed `namespaced_path` as root path because we supposed application_controller is always in root but nested rails engine's application_controller will not.
* modernizes hash syntax in railtiesXavier Noria2016-08-061-3/+3
|
* applies new string literal convention in railties/testXavier Noria2016-08-061-6/+6
| | | | | 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-3/+3
| | | | | | 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.
* Fix more assertion counts.Kasper Timm Hansen2016-05-281-2/+2
| | | | Follow up to e45f388.
* make rake proxy work in rails enginesyuuji.yaginuma2016-01-311-4/+4
|
* Pare back default `index` option for the migration generatorPrathamesh Sonpatki2016-01-241-4/+4
| | | | | | | | | | - 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
* Update test generators to use ActionDispatch::IntegrationTestAbdelkader Boudih2015-12-151-10/+10
| | | | | | | | | | | | In Rails 5.1 `ActionController::TestCase` will be moved out of Rails into it's own gem. Please use `ActionDispatch::IntegrationTest` going forward. This changes the generators to use `ActionDispatch::IntegrationTest` and the required URL setup (rather than symbols) for each of the controller actions. Updated fix to #22076.
* Revert "Merge pull request #22569 from seuros/remove-test-case"eileencodes2015-12-131-4/+4
| | | | | | | | | This reverts commit 9712a7a12b7f9e4dcef751ceda8a73c3f4beb11f, reversing changes made to 3e65c3d3886336e9145438cdeacaf4ebec6a48b8. Reverting because this caused test failures and while we have a followup branch there is still one failure that happens randomly and isn't straight forward to fix.
* Controller generators should be creating IntegrationTest stubs instead of ↵Abdelkader Boudih2015-12-131-4/+4
| | | | ControllerTest
* make generated scaffold functional tests work inside API enginesyuuji.yaginuma2015-08-091-0/+28
| | | | | * set engine's route in setup * use fixture with engine namespace
* make test runner work correctly inside engineyuuji.yaginuma2015-07-121-2/+2
|
* fix NoMethodError that occurs when generating scaffold inside full mode engineyuuji.yaginuma2015-06-281-0/+14
|
* Fix scaffold generator test for resource routesSantiago Pastorino2015-06-111-1/+1
|
* Api apps scaffold does not generate assetsSantiago Pastorino2015-06-111-1/+6
|
* Api apps scaffold does not generate helpersSantiago Pastorino2015-06-111-1/+4
|
* Api apps scaffold does not generate viewsSantiago Pastorino2015-06-111-1/+8
|
* Add api scaffold test for route, controller and its testsSantiago Pastorino2015-06-111-0/+55
|
* add option to avoid generating scaffold.cssmasarakki2015-06-091-0/+14
|
* add test to run generated test files inside mountable engineyuuji.yaginuma2015-06-021-0/+14
|
* Force generated route to be insertedAndrew White2015-02-051-0/+5
| | | | | | | Thor isn't very discerning over whether some content is present when passed to `inject_into_file`, e.g. a commented out route is detected as being present. So to prevent people scratching their heads as to why a route hasn't appeared it's better to fall on the side of having duplicate routes.
* Don't remove all line endings from routes.rbAndrew White2015-02-031-0/+18
| | | | | | | | | | | | When there is a single scaffold in the routes.rb with no other lines then revoking/destroying it will create a routes.rb file with a syntax error. This is because the sentinel for the Thor `route` action didn't include the newline but the logged route code did. The fix is to add the newline to the sentinel and remove it from the the logged route code. Fixes #15913.
* build fix II, adjust broken tests as a consequence of 670ac73126.Yves Senn2015-01-301-4/+4
|
* Improve the matches on the scaffold generator testsCarlos Antonio da Silva2015-01-031-9/+8
| | | | Related to #13434.
* Merge pull request #13434 from tanraya/local_variablesCarlos Antonio da Silva2015-01-031-0/+11
|\ | | | | | | | | | | | | Use local variables in _form.html.erb generated by scaffold. Conflicts: railties/CHANGELOG.md