diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2019-03-22 08:31:36 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2019-04-02 13:15:55 +0900 |
commit | 29b16d3ff87a3da4ec4ac33a17ad9fd9540284c8 (patch) | |
tree | 994efb34ace203e85f774fdd744513932cc0af02 /railties/test | |
parent | 16912db8fd36927cc15f7ea5dcf1816ca6f0270c (diff) | |
download | rails-29b16d3ff87a3da4ec4ac33a17ad9fd9540284c8.tar.gz rails-29b16d3ff87a3da4ec4ac33a17ad9fd9540284c8.tar.bz2 rails-29b16d3ff87a3da4ec4ac33a17ad9fd9540284c8.zip |
Rename `connection` option to `database` in `dbconsole` command
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.
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/commands/dbconsole_test.rb | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/railties/test/commands/dbconsole_test.rb b/railties/test/commands/dbconsole_test.rb index 65f6916acb..76a7cd055f 100644 --- a/railties/test/commands/dbconsole_test.rb +++ b/railties/test/commands/dbconsole_test.rb @@ -216,22 +216,22 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase end end - def test_specifying_a_custom_connection_and_environment + def test_specifying_a_custom_database_and_environment stub_available_environments(["development"]) do - dbconsole = parse_arguments(["-c", "custom", "-e", "development"]) + dbconsole = parse_arguments(["--db", "custom", "-e", "development"]) assert_equal "development", dbconsole[:environment] - assert_equal "custom", dbconsole.connection + assert_equal "custom", dbconsole.database end end - def test_specifying_a_missing_connection + def test_specifying_a_missing_database app_db_config({}) do e = assert_raises(ActiveRecord::AdapterNotSpecified) do - Rails::Command.invoke(:dbconsole, ["-c", "i_do_not_exist"]) + Rails::Command.invoke(:dbconsole, ["--db", "i_do_not_exist"]) end - assert_includes e.message, "'i_do_not_exist' connection is not configured." + assert_includes e.message, "'i_do_not_exist' database is not configured." end end @@ -245,6 +245,18 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase end end + def test_connection_options_is_deprecate + command = Rails::Command::DbconsoleCommand.new([], ["-c", "custom"]) + Rails::DBConsole.stub(:start, nil) do + assert_deprecated("`connection` option is deprecated") do + command.perform + end + end + + assert_equal "custom", command.options["connection"] + assert_equal "custom", command.options["database"] + end + def test_print_help_short stdout = capture(:stdout) do Rails::Command.invoke(:dbconsole, ["-h"]) |