aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/commands
Commit message (Collapse)AuthorAgeFilesLines
* Rename `connection` option to `database` in `dbconsole` commandyuuji.yaginuma2019-04-021-6/+18
| | | | | | | | | | | | | | | We introduced `connection` option for specifying spec with 1acd9a6464668d4d54ab30d016829f60b70dbbeb. But now we are using the `database` to specify the same value in other commands. * https://github.com/rails/rails/blob/0a0f115031b64b5335fa88543c40df4194dfb428/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb#L11 * https://github.com/rails/rails/blob/0a0f115031b64b5335fa88543c40df4194dfb428/activerecord/lib/rails/generators/active_record/model/model_generator.rb#L17 The options provided to the users should be uniform. Since the term "database" is used in rake task etc, So I want to be able to use it in `dbconsole` command. Also I deprecated the `connection` option because I think that it would be confusing if there are multiple options to specify a same value.
* Reword test names in credentials_test.rbSharang Dashputre2019-03-251-4/+4
|
* Merge pull request #35723 from sikachu/disable-sandbox-flagGuillermo Iguaran2019-03-241-1/+1
|\ | | | | Add config.disable_sandbox option to Rails console
| * Add config.disable_sandbox option to Rails consolePrem Sichanugrist2019-03-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | A long-running `rails console --sandbox` could cause a database server to become out-of-memory as it's holding on to changes that happen on the database. Given that it's common for Ruby on Rails application with huge traffic to have separate write database and read database, we should allow the developers to disable this sandbox option to prevent someone from accidentally causing the Denial-of-Service on their server.
* | Add `secret_key_base` when creating new credential fileyuuji.yaginuma2019-03-231-1/+12
|/ | | | | | | | Since `secret_key_base` is expected to be included in credential file, `secret_key_base` should be included even if re-create the file. This is the same behavior as creating a new app. When env is specified, it may be unnecessary, so I added it only when not specifying env.
* Add -e/--environment option to `rails initializers`yuuji.yaginuma2019-03-161-2/+18
| | | | This allows specifying the environment as would any other rails commands.
* Properly expand the environment's name in all commandsyuuji.yaginuma2019-03-152-1/+23
| | | | | | | | | | | | | Since 3777701f1380f3814bd5313b225586dec64d4104, the environment's name is automatically expanded in console and dbconsole commands. In order to match the behavior between the commands, fixes it to have the same behavior of all the commands. This behavior is defined in `EnvironmentArgument`. Since `EnvironmentArgument` also defines the environment option, it is reused. However, since desc was not content that can be used in all comments, fixed desc to be defined for each command.
* Railities typo fixes.alkesh262019-02-012-3/+3
|
* Merge pull request #34789 from christos/fix-editing-new-environment-credentialsKasper Timm Hansen2019-01-251-0/+8
|\ | | | | Don't load app environment when editing credentials
| * Don't load app environment when editing credentialsChristos Zisopoulos2018-12-261-0/+8
| | | | | | | | This avoids missing key exceptions caused by code that tries to read the credentials before they have been added to the encrypted file, for example when editing the credentials for a new environment.
* | Revert "Remove deprecated `server` argument from the rails server command"yuuji.yaginuma2019-01-181-0/+4
| | | | | | | | | | | | This reverts commit fa791fb8e2a718b5d0430c7ca5a454678dfc192d. Reason: `server` argument was deprecated in Rails 6.0. Ref: #32058.
* | Remove deprecated `server` argument from the rails server commandRafael Mendonça França2019-01-171-4/+0
| |
* | Remove deprecated `environment` argument from the rails commandsRafael Mendonça França2019-01-172-43/+4
| |
* | Merge branch 'master' into db_system_change_commandKasper Timm Hansen2019-01-161-38/+45
|\ \
| * | Add Exim and Qmail support to Action MailboxGeorge Claghorn2019-01-121-9/+7
| | |
| * | Added Postmark ingress supportTomek Maszkowski2019-01-091-33/+42
| | |
* | | Revise wording on invalid database error messagesGannon McGibbon2019-01-091-1/+1
| | |
* | | Add rails db:system:change commandGannon McGibbon2019-01-091-0/+62
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | Add `rails db:system:change` command for changing databases. ``` bin/rails db:system:change --to=postgresql force config/database.yml gsub Gemfile ``` The change command copies a template `config/database.yml` with the target database adapter into your app, and replaces your database gem with the target database gem.
* | Do not show suggestion message when not exist suggestionyuuji.yaginuma2018-12-291-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | **before** ``` $ ./bin/rails g g Could not find generator 'g'. Maybe you meant nil? Run `rails generate --help` for more options. ``` **after** ``` $ ./bin/rails g g Could not find generator 'g'. Run `rails generate --help` for more options. ```
* | Import Action MailboxGeorge Claghorn2018-12-251-112/+209
|/
* Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-212-14/+10
| | | | | | | | | | Currently we sometimes find a redundant begin block in code review (e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205). I'd like to enable `Style/RedundantBegin` cop to avoid that, since rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5 (https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with that situation than before.
* Use string for arguments in server testyuuji.yaginuma2018-12-131-2/+2
| | | | | | | | | | | When actually execute from the command, the value of ARGV is passed to the server. So they are String. So let's use the same type in the test. Also, this removes the following warning in Ruby 2.6. ``` lib/rails/commands/server/server_command.rb:195: warning: deprecated Object#=~ is called on Integer; it always returns nil ```
* Support environment specific credentials file. (#33521)Wojciech Wnętrzak2018-09-191-5/+21
| | | | | | For `production` environment look first for `config/credentials/production.yml.enc` file that can be decrypted by `ENV["RAILS_MASTER_KEY"]` or `config/credentials/production.key` master key. Edit given environment credentials file by command `rails credentials:edit --environment production`. Default behavior can be overwritten by setting `config.credentials.content_path` and `config.credentials.key_path`.
* Fix `rails routes -c` for controller name consists of multiple word.Yoshiyuki Kinjo2018-08-201-22/+64
|
* Move 'rails initializers' command to Rails::CommandAnnie-Claude Côté2018-08-161-0/+32
|
* Adds Rails:Command for `dev:cache` that has the same behaviour as the rake taskAnnie-Claude Côté2018-08-131-0/+65
|
* Merge pull request #32381 from q-centrix/update-codeclimate-configsRichard Schneeman2018-07-251-5/+2
|\ | | | | Turn on performance based cops
| * Turn on performance based copsDillon Welch2018-07-231-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use attr_reader/attr_writer instead of methods method is 12% slower Use flat_map over map.flatten(1) flatten is 66% slower Use hash[]= instead of hash.merge! with single arguments merge! is 166% slower See https://github.com/rails/rails/pull/32337 for more conversation
* | Merge pull request #33229 from ↵Matthew Draper2018-07-253-4/+4
|\ \ | |/ |/| | | | | albertoalmagro/albertoalmagro/prefer-rails-command-over-bin-rails Prefer rails command over bin/rails
| * Show rails instead of bin/rails on USAGE instructionsAlberto Almagro2018-07-061-2/+2
| | | | | | | | | | With this commit, rails commands usage instructions display now +rails+ instead of +bin/rails+ within their recommendations.
| * Recommend use of rails over bin/railsAlberto Almagro2018-07-062-2/+2
| | | | | | | | | | | | | | | | | | As discussed in #33203 rails command already looks for, and runs, bin/rails if it is present. We were mixing recommendations within guides and USAGE guidelines, in some files we recommended using rails, in others bin/rails and in some cases we even had both options mixed together.
* | Allow to explicitly specify whether to output Rails' log to stdoutMarkus Doits2018-07-081-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before Rails' logger output is mirrored to std out if: * environment is development and * the process is not daemonized It was not possible to change that behaviour, e.g. to disable log output in that case or enable it in other cases. Now you can explicitly disable or enable output with the new command line switch `--log-to-stdout`, regardless of any other circumstances. ``` // enable output in production rails server -e production --log-to-stdout // disable output in development rails server -e development --no-log-to-stdout ``` Enabling output when daemonized still makes no sense (since tty is detached), but this is ignored for now. If the command line flag is not specified, old behaviour still applies, so this change is completely backward compatible.
* | Don't show unneeded deprecation warning on server restart.Kasper Timm Hansen2018-07-071-3/+2
|/ | | | | | | | | | | | | | | | | If booting a server via `rails s -u puma`, we'd convert the option to a `using` positional. When using `rails restart` our `restart_command` would the option converted to the using positional and put that in the restart command. Thus we'd show users deprecation warnings for our own code. Fix that by converting a passed positional to an option instead. Also: fix initialize method signature. The local_options are an array, not a hash. But don't even bother assigning defaults as Thor passes them in.
* Make NotesCommand tests more performant by getting rid of unecessary mapAnnie-Claude Côté2018-07-051-12/+12
| | | | | | | * Get rid of map and replace it with a multiplication of "\n" to generate document with multiple line preceding the annotation * Reduce number from 1000 to 100 since it achieves the same goal * Only keep one test for the multiple lines document since it's unecessary to test multiple times * Update some language in tests names to make it clearer what we are testing
* Merge pull request #33220 from anniecodes/notes-commandKasper Timm Hansen2018-07-051-0/+128
|\ | | | | Adds `Rails::Command::NotesCommand` and makes `rake notes` use it under the hood
| * Adds support to register directories and extensions to NotesCommandAnnie-Claude Côté2018-07-041-0/+44
| | | | | | | | | | * Require the application and environnement in the notes command in order to load the config files * Adds tests for both register_directories and register_extensions added to a config file
| * Adds a Rails::Command for NotesAnnie-Claude Côté2018-07-041-0/+84
| | | | | | | | | | | | | | | | * It is called with `rails notes` * It defaults to displaying [OPTIMIZE, FIXME and TODO] annotations * It accepts custom annotations by using `rails notes -a CUSTOM_ANNOTATION OTHER_ANNOTATION` * It defaults to look for annotations in [app config db lib test] as dictated by SourceAnnotationExtractor * It supports ENV["SOURCE_ANNOTATION_DIRECTORIES"] but adds a deprecation warning and recommends using register_directories instead
* | Add an assertion that `credentials:edit` works when `RAILS_MASTER_KEY` env ↵yuuji.yaginuma2018-06-241-1/+1
|/ | | | is specified
* Replace `assert !` with `assert_not`Daniel Colson2018-04-191-12/+12
| | | | | This autocorrects the violations after adding a custom cop in 3305c78dcd.
* Deprecate support for using `HOST` environment to specify server IP (#32540)Yuji Yaginuma2018-04-161-1/+15
| | | | | | | | | | | | At SuSE, `$HOST` is set by default and is equal to `$HOSTNAME`. https://www.suse.com/documentation/sled11/book_sle_admin/data/sec_adm_variables.html Therefore, by default, it binds to hostname instead of `localhost`. This seems not to be appropriate as default behavior. In order to avoid the name of the environment variable being used, I changed the environment variable from `HOST` to `BINDING`. Fixes #29516.
* Use `did_you_mean` spell checker for option suggestionsGenadi Samokovarov2018-03-231-1/+1
| | | | | | | | | | | Now that we require Ruby over `2.3`, we can replace the current suggestion methods we have with tooling from the `did_you_mean` gem. There is a small user visible change and this is that we now offer a single suggestion for misspelled options. We are suggesting fixes during generator invocation and during a mistyped rails server rack handler. In both cases, if we don't make a proper prediction on the first match, we won't do so in the second or third one, so in my mind, this is okay.
* Rely on Rails::Command's help output.Kasper Timm Hansen2018-03-131-57/+58
| | | | | | | | | | | | | | | | | | | | | We end up with: ``` Usage: bin/rails routes [options] Options: -c, [--controller=CONTROLLER] # Filter by a specific controller, e.g. PostsController or Admin::PostsController. -g, [--grep=GREP] # Grep routes by a specific pattern. -E, [--expanded], [--no-expanded] # Print routes expanded vertically with parts explained. ``` which does miss the bit about routes being printed in order. Also: * Renames options to ease help output readability, then clarifies each option. * Fixes a bunch of indentation.
* Merge pull request #32160 from bogdanvlviv/improve-rails-routes-expandedKasper Timm Hansen2018-03-111-38/+47
|\ | | | | Draw line of a route name to the end of row console on `rails routes --expanded`
| * Draw line of a route name to the end of row console on `rails routes --expanded`bogdanvlviv2018-03-051-38/+47
| | | | | | | | | | | | | | In order to get width of console use `IO::console_size`, See https://ruby-doc.org/stdlib-2.4.1/libdoc/io/console/rdoc/IO.html#method-c-console_size Related to #32130
* | Remove extra arg passed to `Rails::Command::RoutesTest#run_routes_command`bogdanvlviv2018-03-051-1/+1
|/ | | | Related to 6bd33d66dde015a55912af20b469788ba20ddb4e
* Fix "NameError: undefined local variable or method `host'"yuuji.yaginuma2018-03-051-0/+6
| | | | The `host` and `port` can't use this context.
* Merge pull request #32058 from gsamokovarov/rails-server-x-optionKasper Timm Hansen2018-03-041-4/+29
|\ | | | | Introduce explicit rails server handler option
| * Introduce explicit rails server handler optionGenadi Samokovarov2018-03-041-4/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I mistype `rails server production` instead of `rails server -e production` expecting to lunch a server in the production environment all the time. However, the signature of `rails server --help` is: ``` Usage: rails server [puma, thin etc] [options] ``` This means that the `production` argument is being interpreted as a Rack server handler like Puma, Thin or Unicorn. Should we argue for the `rails server production`? I'm not sure of the reasons, but the `rails console production` behavior was deprecated in: https://github.com/rails/rails/pull/29358, so parity with the existing `rails console production` usage may not hold anymore. In any case, this PR introduces an explicit option for the Rack servers configuration. The option is called `--using` (or `-u` for short) to avoid the `rails server --server` tantrum. The new interface of `rails server` is: ``` Usage: rails server [using] [options] Options: -p, [--port=port] # Runs Rails on the specified port - defaults to 3000. -b, [--binding=IP] # Binds Rails to the specified IP - defaults to 'localhost' in development and '0.0.0.0' in other environments'. -c, [--config=file] # Uses a custom rackup configuration. # Default: config.ru -d, [--daemon], [--no-daemon] # Runs server as a Daemon. -e, [--environment=name] # Specifies the environment to run this server under (development/test/production). -u, [--using=name] # Specifies the Rack server used to run the application (thin/puma/webrick). -P, [--pid=PID] # Specifies the PID file. # Default: tmp/pids/server.pid -C, [--dev-caching], [--no-dev-caching] # Specifies whether to perform caching in development. [--early-hints], [--no-early-hints] # Enables HTTP/2 early hints. ``` As a bonus, if you mistype the server to use, you'll get an auto-correction message: ``` $ rails s tin Could not find handler "tin". Maybe you meant "thin" or "cgi"? Run `rails server --help` for more options. ```
* | Fix routes command tests broken in e137831726.Kasper Timm Hansen2018-03-041-23/+16
|/
* Clean up `RoutesTest` a bityuuji.yaginuma2018-03-011-8/+6
| | | | | | * Remove unused require * Remove redundant `test` * Change `rake` to `rails`