From c0928831697306c0a92d5e71f35e8e060a59907b Mon Sep 17 00:00:00 2001 From: koshigoe Date: Mon, 1 May 2017 17:05:49 +0900 Subject: CLI arg `--port` has precedence over env `PORT`. --- railties/test/commands/server_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'railties/test/commands') diff --git a/railties/test/commands/server_test.rb b/railties/test/commands/server_test.rb index 2d1f071969..7731d10d9b 100644 --- a/railties/test/commands/server_test.rb +++ b/railties/test/commands/server_test.rb @@ -140,6 +140,18 @@ class Rails::ServerTest < ActiveSupport::TestCase end def test_argument_precedence_over_environment_variable + switch_env "PORT", "1234" do + args = ["-p", "5678"] + options = parse_arguments(args) + assert_equal 5678, options[:Port] + end + + switch_env "PORT", "1234" do + args = ["-p", "3000"] + options = parse_arguments(args) + assert_equal 3000, options[:Port] + end + switch_env "HOST", "1.2.3.4" do args = ["-b", "127.0.0.1"] options = parse_arguments(args) -- cgit v1.2.3 From 7a154ab380501050e6ce20463de8f702353bceb0 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Fri, 19 May 2017 15:13:05 +0900 Subject: Correctly set user_supplied_options when there is no whitespace in option 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 --- railties/test/commands/server_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'railties/test/commands') diff --git a/railties/test/commands/server_test.rb b/railties/test/commands/server_test.rb index 7731d10d9b..722323efdc 100644 --- a/railties/test/commands/server_test.rb +++ b/railties/test/commands/server_test.rb @@ -165,6 +165,12 @@ class Rails::ServerTest < ActiveSupport::TestCase server_options = parse_arguments(["--port", 3001]) assert_equal [:Port], server_options[:user_supplied_options] + + server_options = parse_arguments(["-p3001", "-C", "--binding", "127.0.0.1"]) + assert_equal [:Port, :Host, :caching], server_options[:user_supplied_options] + + server_options = parse_arguments(["--port=3001"]) + assert_equal [:Port], server_options[:user_supplied_options] end def test_default_options -- cgit v1.2.3 From 0338c81dc2ab6ef35fe68461e39c0bad0af5bb95 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Tue, 23 May 2017 21:54:01 +0200 Subject: Reorder first secrets edit flow. Setup config/secrets.yml.enc with template contents for people to edit. Then generate encryption key and encrypt the initial secrets. --- railties/test/commands/secrets_test.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'railties/test/commands') diff --git a/railties/test/commands/secrets_test.rb b/railties/test/commands/secrets_test.rb index 00b0343397..fb8fd2325e 100644 --- a/railties/test/commands/secrets_test.rb +++ b/railties/test/commands/secrets_test.rb @@ -18,7 +18,8 @@ class Rails::Command::SecretsCommandTest < ActiveSupport::TestCase end test "edit secrets" do - run_setup_command + # Runs setup before first edit. + assert_match(/Adding config\/secrets\.yml\.key to store the encryption key/, run_edit_command) # Run twice to ensure encrypted secrets can be reread after first edit pass. 2.times do @@ -30,8 +31,4 @@ class Rails::Command::SecretsCommandTest < ActiveSupport::TestCase def run_edit_command(editor: "cat") Dir.chdir(app_path) { `EDITOR="#{editor}" bin/rails secrets:edit` } end - - def run_setup_command - Dir.chdir(app_path) { `bin/rails secrets:setup` } - end end -- cgit v1.2.3