aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators
Commit message (Collapse)AuthorAgeFilesLines
* Clean up railties testsbogdanvlviv2018-01-102-19/+0
| | | | | | | | | | Remove `AppGeneratorTest#test_active_storage_install`. The test is added by 67db41aa7f17c2d34eb5a914ac7a6b2574930ff4, since #31534 this test doesn't test anything. Remove redundant assertions in `SharedGeneratorTests`. These assertions is added by 4a835aa3236eedb135ccf8b59ed3c03e040b8b01. Follows 67db41aa7f17c2d34eb5a914ac7a6b2574930ff4, #31534.
* Merge pull request #31534 from claudiob/kaspth-approachKasper Timm Hansen2018-01-091-2/+2
|\ | | | | Don't include Active Storage migrations in new apps
| * Don't run rails active_storage:install in new appsclaudiob2017-12-141-2/+2
| | | | | | | | See #31315 for full discussion
* | Prevent to install gems when run test (#31564)Yuji Yaginuma2017-12-262-4/+12
| | | | | | | | | | | | `invoke_all` cause `bundle install`. This will install gems actually defined in `Gemfile`. To avoid this, stubbed `bundle_command`. Fixes #31557
* | Move `test_skip_bundle` to `AppGeneratorTest`yuuji.yaginuma2017-12-242-9/+9
| | | | | | | | `skip_bundle` option was removed from plugin generator in 9b72fcc3c22a6f75f37f52dd6cb682bc00c51cf0.
* | Implicitly skip bootsnap for `rails new --dev`yuuji.yaginuma2017-12-191-0/+11
| | | | | | | | | | | | | | Specifying the `--dev` option is when want to change the codebase, as it is not necessary to cache it. Context: https://github.com/rails/rails/pull/31485#issuecomment-352452653
* | Add `skip_bootsnap` optionyuuji.yaginuma2017-12-161-0/+20
|/ | | | | | `bootsnap` is a useful gem normally. However, `bootsnap` is unnecessary when generating a Rails application to be used only for testing. So I want to control whether use this or not by option.
* Add more tests for the `--webpack` optionTsukuru Tanimichi2017-12-051-0/+19
|
* Modify `test_webpack_option`Tsukuru Tanimichi2017-12-051-3/+5
|
* Merge pull request #31279 from ttanimichi/tests-for-webpack-optionGuillermo Iguaran2017-12-041-0/+14
|\ | | | | Add tests for the `--webpack` option
| * Add tests for the `--webpack` optionTsukuru Tanimichi2017-12-041-0/+14
| | | | | | | | | | We probably don't have any tests for the `--webpack` option. related: #27288
* | Fix typo in test error messageclaudiob2017-12-021-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | With the current code, a failing test shows this error, which is missing the number of times called and has two periods at the end. ``` /railties$ be ruby -Itest test/generators/app_generator_test.rb -n test_active_storage_install Failure: AppGeneratorTest#test_active_storage_install [test/generators/app_generator_test.rb:313]: active_storage:install expected to be called once, but was called times.. Expected: 1 Actual: 2 ``` After the fix, the error message looks correct: ``` /railties$ be ruby -Itest test/generators/app_generator_test.rb -n test_active_storage_install Failure: AppGeneratorTest#test_active_storage_install [test/generators/app_generator_test.rb:313]: active_storage:install expected to be called once, but was called 2 times. Expected: 1 Actual: 2 ```
* Use same version constraint in mysql adapter and generated applicationyuuji.yaginuma2017-11-281-1/+1
| | | | Follow up of 924a368f5c654f5304e575c767eb0fc64adc8659
* Remove Content-Security-Policy initializer in API-only Applicationsyuuji.yaginuma2017-11-271-0/+2
| | | | | | Since `ContentSecurityPolicy::Middleware` is not loaded in API-only Applications, initializer is unnecessary. Ref: https://github.com/rails/rails/blob/9c10fec4c06da38f8975dfb851f4d899aa85f8b7/railties/lib/rails/application/default_middleware_stack.rb#L66..L68
* Added missing test for presence of CSP initializerPrathamesh Sonpatki2017-11-271-0/+1
| | | | - Followup of #31162
* Use Puma 3.11 in newly generated applicationsyuuji.yaginuma2017-11-271-1/+1
| | | | | | | In order to use early hints, need to use Puma 3.11.0 or higher. So, I think that should specify that version in newly generated applications. Ref: https://github.com/puma/puma/commit/f6f3892f4d82638fb7a2a57d993641b1486ee88a
* 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.
* Deprecate an `after_bundle` callback in Rails plugin templatesyuuji.yaginuma2017-11-181-0/+32
| | | | | | | | | Since fbd1e98cf983572ca9884f17f933ffe92833632a, Rails plugin does not run `bundle install` when generating. Therefore, `after_bundle` callback is not actually executed after `bundle`. Since there is a difference between the name and the actual behavior, I think that should be remove.
* Add master key to `gitignore` on `rails new`yuuji.yaginuma2017-11-161-0/+8
| | | | | | | We generate master key on `rails new`. Therefore, if do not add master key to `.gitginore` on `rails new`as well, there is a possibility that the master key will be committed accidentally.
* Merge pull request #30004 from npenzin/patch-1Yuji Yaginuma2017-11-151-1/+2
|\ | | | | Update plugin_generator.rb
| * Ensure plugin_generator adds to new line in GemfileNikita Penzin2017-11-141-1/+2
| | | | | | | | | | | | | | Ensure plugin_generator adds to new line in Gemfile, even if the Gemfile does not end with an empty line. [Lisa Ugray, Nikita Penzin]
* | Use .tt extension to all the template filesRafael Mendonça França2017-11-131-2/+2
| | | | | | | | | | | | | | | | Make clear that the files are not to be run for interpreters. Fixes #23847. Fixes #30690. Closes #23878.
* | Deprecate encrypted secrets in favor of credentials.Kasper Timm Hansen2017-11-121-44/+0
| | | | | | | | | | | | | | | | Allow edits of existing encrypted secrets generated on Rails 5.1, but refer to credentials when attempting to setup. This also removes the need for any of the setup code, so the generator can be ripped out altogether.
* | Merge pull request #30770 from ↵Kasper Timm Hansen2017-11-121-0/+2
|\ \ | | | | | | | | | | | | y-yagi/do_not_create_credential_in_dummy_application Do not create credentials in dummy application
| * | Do not create credentials in dummy applicationyuuji.yaginuma2017-10-021-0/+2
| | | | | | | | | | | | | | | Because dummy application is only for use test, so credentials is unnecessary.
* | | Remove redundant passing --skip-active-storage in test casesbogdanvlviv2017-11-085-6/+6
| | | | | | | | | | | | These were added in #30101, after #31084 it became redundant.
* | | Do not run `active_storage:install` when bundle install is skippedyuuji.yaginuma2017-11-082-2/+15
| | | | | | | | | | | | | | | | | | | | | In order to execute the `rails` command, need to run bundle install in advance. Therefore, if skipped bundle install, `rails` command may fail and should not do it.
* | | Merge pull request #30101 from bogdanvlviv/initialization-active_storageRafael França2017-11-067-18/+203
|\ \ \ | | | | | | | | Provide initialization of Active Storage
| * | | Rails::Generators::Actions#execute_command allows option `capture`bogdanvlviv2017-11-061-0/+16
| | | |
| * | | `rails new` runs `rails active_storage:install`bogdanvlviv2017-11-064-14/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Omit `rails activestorage:install` for jdbcmysql, jdbc and shebang tests AppGeneratorTest#test_config_jdbcmysql_database rails aborted! LoadError: Could not load 'active_record/connection_adapters/mysql_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile. (compressed) bin/rails:4:in `<main>' Tasks: TOP => activestorage:install => environment (See full trace by running task with --trace) AppGeneratorTest#test_config_jdbc_database rails aborted! LoadError: Could not load 'active_record/connection_adapters/jdbc_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile. (compressed) bin/rails:4:in `<main>' Tasks: TOP => activestorage:install => environment (See full trace by running task with --trace) AppGeneratorTest#test_shebang_is_added_to_rails_file /home/ubuntu/.rbenv/versions/2.4.1/bin/ruby: no Ruby script found in input (LoadError) Prevent PendingMigrationError in tests * Run `bin/rails db:migrate RAILS_ENV=test` in test_cases before start tests to prevent PendingMigrationError * FileUtils.rm_r("db/migrate") * --skip-active-storage Fix failed tests in `railties/test/railties/engine_test.rb` Related to #30111 Imporve `SharedGeneratorTests#test_default_frameworks_are_required_when_others_are_removed` - Explicitly skip active_storage - Ensure that skipped frameworks are commented - Ensure that default frameworks are not commented Fix error `Errno::ENOSPC: No space left on device - sendfile` Since `rails new` runs `rails active_storage:install` that boots an app. Since adding Bootsnap 0312a5c67e35b960e33677b5358c539f1047e4e1 during booting an app, it creates the cache: 264K tmp/cache/bootsnap-load-path-cache 27M tmp/cache/bootsnap-compile-cache * teardown_app must remove app
| * | | Add --skip-active-storage and do so automatically when --skip-active-record ↵bogdanvlviv2017-11-064-4/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | is used Closes #30102 Revert part 787fe90dc0a7c5b91bb5af51f2858ea8c4676268 --skip-active-storage pass throughs `rails plugin new` Add changelog entry about default initialization of Active Storage
* | | | Generate the correct path in nested scaffold generatoryuuji.yaginuma2017-11-052-1/+30
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Improve out-of-box experience with System tests including ↵Guillermo Iguaran2017-10-181-0/+2
| | | | | | | | | | | | chromedriver-helper by default
* | | Fix "warning: assigned but unused variable - message"yuuji.yaginuma2017-10-121-2/+1
|/ / | | | | | | Ruby 2.5 warns about this. Ref: https://travis-ci.org/rails/rails/jobs/286338999
* | Fix "warning: method redefined; discarding old test_scaffold_plural_names"yuuji.yaginuma2017-09-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Since warning was issued due to duplication of test names, fix the test name to a meaningful name. This fixes following warnings: ``` railties/test/generators/named_base_test.rb:141: warning: method redefined; discarding old test_scaffold_plural_names railties/test/generators/named_base_test.rb:62: warning: previous definition of test_scaffold_plural_names was here ```
* | scaffold nested name controller should be fine.yalab2017-09-272-0/+36
| |
* | Respect quiet option in all process of `rails new` commandyuuji.yaginuma2017-09-251-1/+6
| | | | | | | | | | If specify the `quiet` option, expect that no status will be shown. However, some process show status. This suppresses all status output.
* | Use escaped character in regexpyhirano552017-09-111-1/+1
| |
* | Add credentials using a generic EncryptedConfiguration class (#30067)David Heinemeier Hansson2017-09-113-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * WIP: Add credentials using a generic EncryptedConfiguration class This is sketch code so far. * Flesh out EncryptedConfiguration and test it * Better name * Add command and generator for credentials * Use the Pathnames * Extract EncryptedFile from EncryptedConfiguration and add serializers * Test EncryptedFile * Extract serializer validation * Stress the point about losing comments * Allow encrypted configuration to be read without parsing for display * Use credentials by default and base them on the master key * Derive secret_key_base in test/dev, source it from credentials in other envs And document the usage. * Document the new credentials setup * Stop generating the secrets.yml file now that we have credentials * Document what we should have instead Still need to make it happen, tho. * [ci skip] Keep wording to `key base`; prefer defaults. Usually we say we change defaults, not "spec" out a release. Can't use backticks in our sdoc generated documentation either. * Abstract away OpenSSL; prefer MessageEncryptor. * Spare needless new when raising. * Encrypted file test shouldn't depend on subclass. * [ci skip] Some woordings. * Ditch serializer future coding. * I said flip it. Flip it good. * [ci skip] Move require_master_key to the real production.rb. * Add require_master_key to abort the boot process. In case the master key is required in a certain environment we should inspect that the key is there and abort if it isn't. * Print missing key message and exit immediately. Spares us a lengthy backtrace and prevents further execution. I've verified the behavior in a test app, but couldn't figure the test out as loading the app just exits immediately with: ``` /Users/kasperhansen/Documents/code/rails/activesupport/lib/active_support/testing/isolation.rb:23:in `load': marshal data too short (ArgumentError) from /Users/kasperhansen/Documents/code/rails/activesupport/lib/active_support/testing/isolation.rb:23:in `run' from /Users/kasperhansen/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest.rb:830:in `run_one_method' from /Users/kasperhansen/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest/parallel.rb:32:in `block (2 levels) in start' ``` It's likely we need to capture and prevent the exit somehow. Kernel.stub(:exit) didn't work. Leaving it for tomorrow. * Fix require_master_key config test. Loading the app would trigger the `exit 1` per require_master_key's semantics, which then aborted the test. Fork and wait for the child process to finish, then inspect the exit status. Also check we aborted because of a missing master key, so something else didn't just abort the boot. Much <3 to @tenderlove for the tip. * Support reading/writing configs via methods. * Skip needless deep symbolizing. * Remove save; test config reader elsewhere. * Move secret_key_base check to when we're reading it. Otherwise we'll abort too soon since we don't assign the secret_key_base to secrets anymore. * Add missing string literal comments; require unneeded yaml require. * ya ya ya, rubocop. * Add master_key/credentials after bundle. Then we can reuse the existing message on `rails new bc4`. It'll look like: ``` Using web-console 3.5.1 from https://github.com/rails/web-console.git (at master@ce985eb) Using rails 5.2.0.alpha from source at `/Users/kasperhansen/Documents/code/rails` Using sass-rails 5.0.6 Bundle complete! 16 Gemfile dependencies, 72 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. Adding config/master.key to store the master encryption key: 97070158c44b4675b876373a6bc9d5a0 Save this in a password manager your team can access. If you lose the key, no one, including you, can access anything encrypted with it. create config/master.key ``` And that'll be executed even if `--skip-bundle` was passed. * Ensure test app has secret_key_base. * Assign secret_key_base to app or omit. * Merge noise * Split options for dynamic delegation into its own method and use deep symbols to make it work * Update error to point to credentials instead * Appease Rubocop * Validate secret_key_base when reading it. Instead of relying on the validation in key_generator move that into secret_key_base itself. * Fix generator and secrets test. Manually add config.read_encrypted_secrets since it's not there by default anymore. Move mentions of config/secrets.yml to config/credentials.yml.enc. * Remove files I have no idea how they got here. * [ci skip] swap secrets for credentials. * [ci skip] And now, changelogs are coming.
* | Explicitly require `test_unit/reporter` in test helperyuuji.yaginuma2017-09-041-0/+6
| | | | | | | | | | | | | | | | | | | | | | If the user used the `bin/test` to execute the test, this file is automatically loaded, so require is unnecessary. https://github.com/rails/rails/blob/acea68de026ba657cb65c4dd0fc1f24ba67e1cf8/railties/lib/rails/plugin/test.rb#L4 However, when using `rake test`, an explicit require is required because the above file is not loaded. Fixes #30516
* | Merge pull request #30323 from yhirano55/support_multiple_version_for_gem_methodMatthew Draper2017-08-311-4/+11
|\ \ | | | | | | Support multiple versions arguments for `gem` method of Generators
| * | Support multiple versions arguments for `gem` method of GeneratorsYoshiyuki Hirano2017-08-191-4/+11
| | |
* | | Merge pull request #30370 from ↵Kasper Timm Hansen2017-08-281-2/+2
|\ \ \ | | | | | | | | | | | | | | | | yhirano55/fix_indentation_in_secrets_yaml_template Fix indentation in the template for secrets
| * | | Fix indentation in the template for secretsYoshiyuki Hirano2017-08-231-2/+2
| |/ /
* / / Remove frozen_string_literal magic comment from templatesKoichi ITO2017-08-221-2/+0
|/ /
* | Move common tests from `AppGeneratorTest` and `PluginGeneratorTest` to ↵bogdanvlviv2017-08-173-200/+114
| | | | | | | | `SharedGeneratorTests`
* | Fix RuboCop offensesKoichi ITO2017-08-163-7/+7
| | | | | | | | And enable `context_dependent` of Style/BracesAroundHashParameters cop.
* | Add --skip-yarn option to the plugin generatorbogdanvlviv2017-08-153-26/+34
| | | | | | | | | | Add SharedGeneratorTests#application_path This method will help to DRY in files app_generator_test.rb, plugin_generator_test.rb
* | Fix typo for api_app_generator_testYoshiyuki Hirano2017-08-151-1/+1
| |
* | Merge pull request #30219 from yhirano55/fix_app_generator_api_optionsRafael França2017-08-142-22/+41
|\ \ | | | | | | Refactor `--api` option of the app generator