aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/commands
Commit message (Collapse)AuthorAgeFilesLines
...
| * 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`
* Add --expanded option to "rails routes"Benoit Tigeot2018-02-281-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | When using rails routes with small terminal or complicated routes it can be very difficult to understand where is the element listed in header. psql had the same issue, that's why they created "expanded mode" you can switch using `\x` or by starting psql with ``` -x --expanded Turn on the expanded table formatting mode. This is equivalent to the \x command. ``` The output is similar to one implemented here for rails routes: db_user-# \du List of roles -[ RECORD 1 ]---------------------------------------------- Role name | super Attributes | Superuser, Create role, Create DB Member of | {} -[ RECORD 2 ]---------------------------------------------- Role name | role Attributes | Superuser, Create role, Create DB, Replication Member of | {}
* Move rake routes task to rails commandBenoit Tigeot2018-02-271-0/+127
| | | | | | After a discussion with matthewd. It was mentioned that rake tasks need to be moved to rails command. See: https://github.com/rails/rails/issues/32117
* Do not add master key when `RAILS_MASTER_KEY` env specified (#31922)Yuji Yaginuma2018-02-082-0/+24
| | | Fixes #31917
* Use assert_predicate and assert_not_predicateDaniel Colson2018-01-251-5/+5
|
* Raise an error only when `require_master_key` is specifiedyuuji.yaginuma2017-12-182-8/+36
| | | | | | | | | To prevent errors from being raise in environments where credentials is unnecessary. Context: https://github.com/rails/rails/issues/31283#issuecomment-348801489 Fixes #31283
* Do not overwrite by default if credentials already existsyuuji.yaginuma2017-11-301-0/+8
| | | | Fixes #31286
* Add CLI to manage encrypted files/configs.Wojciech Wnętrzak2017-11-152-1/+84
| | | | | | | | | | | | | | | | | | To edit/show encrypted file: ``` bin/rails encrypted:edit config/staging_tokens.yml.enc bin/rails encrypted:edit config/staging_tokens.yml.enc --key config/staging.key bin/rails encrypted:show config/staging_tokens.yml.enc ``` Also provides a backing Rails.application.encrypted API for Ruby access: ```ruby Rails.application.encrypted("config/staging_tokens.yml.enc").read Rails.application.encrypted("config/staging_tokens.yml.enc").config Rails.application.encrypted("config/staging_tokens.yml.enc", key: "config/staging.key") ```
* Deprecate encrypted secrets in favor of credentials.Kasper Timm Hansen2017-11-121-12/+37
| | | | | | | | 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.
* Fix test name for daemon option testyuuji.yaginuma2017-10-141-2/+2
| | | | | | | In this test file, "server option" refers to the server used to start Rails(e.g. `puma`, `thin`). But this test, "server option" is not specified. Therefore, I think that it is incorrect that `server_option` is included in the test name.
* Added test case for starting rails with daemon option, this should set the ↵Pierre Hedkvist2017-10-131-0/+12
| | | | option[:daemonize] to true, otherwise the option[:daemonize] will be set to false
* Simplify parse arguments in `ConsoleTest`yuuji.yaginuma2017-10-081-16/+3
| | | | | If need a parse result of arguments, can obtain it by creating an instance of the command.
* Implement H2 Early Hints for Railseileencodes2017-10-041-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When puma/puma#1403 is merged Puma will support the Early Hints status code for sending assets before a request has finished. While the Early Hints spec is still in draft, this PR prepares Rails to allowing this status code. If the proxy server supports Early Hints, it will send H2 pushes to the client. This PR adds a method for setting Early Hints Link headers via Rails, and also automatically sends Early Hints if supported from the `stylesheet_link_tag` and the `javascript_include_tag`. Once puma supports Early Hints the `--early-hints` argument can be passed to the server to enable this or set in the puma config with `early_hints(true)`. Note that for Early Hints to work in the browser the requirements are 1) a proxy that can handle H2, and 2) HTTPS. To start the server with Early Hints enabled pass `--early-hints` to `rails s`. This has been verified to work with h2o, Puma, and Rails with Chrome. The commit adds a new option to the rails server to enable early hints for Puma. Early Hints spec: https://tools.ietf.org/html/draft-ietf-httpbis-early-hints-04 [Eileen M. Uchitelle, Aaron Patterson]
* Add tests for credentials commandyuuji.yaginuma2017-09-151-0/+19
|
* Make master key added to gitignore the same value as when creating appplicationyuuji.yaginuma2017-09-141-0/+30
| | | | | | | | | For gitignore generated by `rails new`, key with a leading slash is specified. https://github.com/rails/rails/blob/69f976b859cae7f9d050152103da018b7f5dda6d/railties/lib/rails/generators/rails/app/templates/gitignore#L11 Therefore, when executing `credentials:edit`, also need leading slack. In order to avoid such a difference, fixed to use same method for `rails new` and `credentials:edit`.
* Run in-app rails commands via fork+load where possibleMatthew Draper2017-09-041-4/+7
| | | | | While this avoids shell argument parsing, we still pass through everything in our stack.
* Fix `can't modify frozen String` error in `DBConsole`yuuji.yaginuma2017-08-291-0/+6
| | | | | | | | | Without this, `dbconsole` raises an error as follwing: ``` RuntimeError: can't modify frozen String railties/lib/rails/commands/dbconsole/dbconsole_command.rb:79:in `start' ```
* Make `restart` and `dev:cache` tasks work when customizing pid file pathyuuji.yaginuma2017-08-211-1/+1
| | | | | | | | | | Originally, it hard-coded pid file path. It can not be removed when customizing pid file path. But rake task can not get pid file path. Therefore, do not remove file in rake task, makes it possible to judge whether it is restart from the argument of the command and removes the file in server command. Fixes #29306
* Adding frozen_string_literal pragma to Railties.Pat Allan2017-08-144-0/+8
|
* Properly expand the environment's nameRobin Dupret2017-07-162-0/+11
| | | | | | | | | Running the `console` and `dbconsole` commands with a regular argument as the environment's name automatically expand it to match an existing environment (e.g. dev for development). This feature wasn't available using the `--environment` (a.k.a `-e`) option.
* Deprecate environment as an argument for dbconsole and consoleRobin Dupret2017-07-162-12/+24
| | | | | | People should rather rely on the `-e` or `--environment` options to specify in which environment they want to work. This will allow us to specify the connection to pick as a regular argument in the future.
* Allow to pass a connection to the `dbconsole` commandRobin Dupret2017-07-161-0/+43
| | | | | | | | | | | Since 0a4f6009, it's possible to specify a 3-level database configuration to gather connections by environment. The `dbconsole` command will try to look for a database configuration which points to the current environment but with such flavour, the environment key is flushed out so let's add the ability to specify the connection and pick `primary` by default to be consistent with Active Record.
* Add `rails secrets:show` commandyuuji.yaginuma2017-07-071-0/+13
| | | | | | | | | | | When secrets confirmed with the `secrets:edit` command, `secrets.yml.enc` will change without updating the secrets. Therefore, even if only want to check secrets, the difference will come out. This is a little inconvenient. In order to solve this problem, added the `secrets:show` command. If just want to check secrets, no difference will occur use this command.
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-024-4/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-014-0/+4
|
* Do not use UTF8 in test SecretsCommandTest#test_edit_secretsPavel Valena2017-05-301-1/+1
|
* Merge pull request #29146 from y-yagi/fix_29138Kasper Timm Hansen2017-05-281-0/+6
|\ | | | | Correctly set user_supplied_options when there is no whitespace in option specification
| * Correctly set user_supplied_options when there is no whitespace in option ↵yuuji.yaginuma2017-05-241-0/+6
| | | | | | | | | | | | | | | | | | | | specification Current `user_supplied_options` method can not set the value correctly if there is no space between option and value (e.g., `-p9000`). This makes it possible to set the value correctly in the case like the above. Fixes #29138
* | Reorder first secrets edit flow.Kasper Timm Hansen2017-05-251-5/+2
|/ | | | | | Setup config/secrets.yml.enc with template contents for people to edit. Then generate encryption key and encrypt the initial secrets.
* CLI arg `--port` has precedence over env `PORT`.koshigoe2017-05-011-0/+12
|
* CLI arg "host" has precedence over ENV var "host"Jon Moss2017-03-211-0/+8
| | | | | | | This is a regression from when the server command switched to its own argument parser, as opposed to Rack's. Rack's argument parser, when provided with a "host" argument, gives that value precedence over environment variables.
* Add secrets edit testyuuji.yaginuma2017-03-121-0/+13
|
* Tell users how to assign a $EDITOR.Kasper Timm Hansen2017-03-011-0/+24
| | | | | | | | | | | | | | | In case there's no $EDITOR assigned users would see a cryptic: ``` % EDITOR= bin/rails secrets:edit Waiting for secrets file to be saved. Abort with Ctrl-C. sh: /var/folders/wd/xnncwqp96rj0v1y2nms64mq80000gn/T/secrets.yml.enc: Permission denied New secrets encrypted and saved. ``` That error is misleading, so give a hint in this easily detectable case. Fixes #28143.
* Set correct host except development environmentyuuji.yaginuma2017-02-271-0/+18
| | | | | | | | Currently `localhost` is used for the default host in all environments. But up to Rails 5.0, `0.0.0.0` is used except for development. So fixed to use the same value as 5.0. Fixes #28184
* [close #24435] Send user_supplied_options to serverschneems2017-02-241-0/+8
| | | | | | | | | | | | | | | | | | Currently when Puma gets a `:Port` it doesn't know if it is Rails' default port or if it is one that is specified by a user. Because of this it assumes that the port passed in is always a user defined port and therefor 3000 always "wins" even if you specify `port` inside of the `config/puma.rb` file when booting your server with `rails s`. The fix is to record the options that are explicitly passed in from the user and pass those to the Puma server (or all servers really). Puma then has enough information to know when `:Port` is the default and when it is user defined. I went ahead and did this for all values rails server exposes as server side options for completeness. The hardest thing was converting the input say `-p` or `--port` into the appropriate "name", in this case `Port`. There may be a more straightforward way to do this with Thor, but I'm not an expert here. Move logic for parsing user options to method Better variable name for iteration Explicitly test `--port` user input ✂️ Update array if environment variables are used
* improve server default options testyuuji.yaginuma2017-01-091-3/+3
| | | | | | | This test was added in 221b4ae. 221b4ae modified to return the same result even if `Rails::Server#default_options` is called more than once. Therefore, also use `Rails::Server#default_options` instead of `ServerCommand#default_options` in test.
* Merge branch 'master' into fix_26964Kasper Timm Hansen2016-12-291-1/+1
|\
| * "Use assert_nil if expecting nil. This will fail in minitest 6."Akira Matsuda2016-12-251-1/+1
| |
* | use Thor option parser in server commands parseyuuji.yaginuma2016-12-241-36/+43
|/ | | | | | | | | | The `ServerCommand` inherits Thor, but currently does not use Thor option parser. Therefore, if leave the argument of Thor as it is, it becomes an error by the argument checking of Thor. To avoid it, to use the Thor option parser instead of reimplementing it. Fixes #26964
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-9/+9
|
* Fix server command tests.Kasper Timm Hansen2016-09-251-1/+2
|
* Fix dbconsole tests.Kasper Timm Hansen2016-09-251-22/+55
|
* Fix console tests.Kasper Timm Hansen2016-09-251-6/+30
|
* Add three new rubocop rulesRafael Mendonça França2016-08-161-6/+6
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.