From 60aeb6a8f9f1fc161a921c2219650c19b6e753e7 Mon Sep 17 00:00:00 2001
From: "yuuji.yaginuma" <yuuji.yaginuma@gmail.com>
Date: Mon, 27 Feb 2017 17:29:16 +0900
Subject: Set correct host except development environment

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
---
 railties/test/commands/server_test.rb | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

(limited to 'railties/test')

diff --git a/railties/test/commands/server_test.rb b/railties/test/commands/server_test.rb
index 0f236ff463..d21a80982b 100644
--- a/railties/test/commands/server_test.rb
+++ b/railties/test/commands/server_test.rb
@@ -121,6 +121,24 @@ class Rails::ServerTest < ActiveSupport::TestCase
     end
   end
 
+  def test_host
+    with_rails_env "development" do
+      options = parse_arguments([])
+      assert_equal "localhost", options[:Host]
+    end
+
+    with_rails_env "production" do
+      options = parse_arguments([])
+      assert_equal "0.0.0.0", options[:Host]
+    end
+
+    with_rails_env "development" do
+      args = ["-b", "127.0.0.1"]
+      options = parse_arguments(args)
+      assert_equal "127.0.0.1", options[:Host]
+    end
+  end
+
   def test_records_user_supplied_options
     server_options = parse_arguments(["-p", 3001])
     assert_equal [:Port], server_options[:user_supplied_options]
-- 
cgit v1.2.3