Skip to content

Commit dd3f743

Browse files
authoredSep 3, 2024
Use 127.0.0.1 instead of localhost so Docker DB can be easily used (rails#52778)
* Use 127.0.0.1 instead of localhost so Docker DB can be easily used * Fix tests
1 parent 66a9d11 commit dd3f743

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed
 

‎railties/lib/rails/generators/database.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def socket
4242
end
4343

4444
def host
45-
"localhost"
45+
"127.0.0.1"
4646
end
4747
end
4848

‎railties/test/generators/app_generator_test.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ def test_devcontainer_mysql
13651365
assert_includes content["forwardPorts"], 3306
13661366
end
13671367
assert_file("config/database.yml") do |content|
1368-
assert_match(/host: <%= ENV.fetch\("DB_HOST"\) \{ "localhost" } %>/, content)
1368+
assert_match(/host: <%= ENV.fetch\("DB_HOST"\) \{ "127.0.0.1" } %>/, content)
13691369
end
13701370
end
13711371

@@ -1393,7 +1393,7 @@ def test_devcontainer_trilogy
13931393
assert_includes(content["forwardPorts"], 3306)
13941394
end
13951395
assert_file("config/database.yml") do |content|
1396-
assert_match(/host: <%= ENV.fetch\("DB_HOST"\) \{ "localhost" } %>/, content)
1396+
assert_match(/host: <%= ENV.fetch\("DB_HOST"\) \{ "127.0.0.1" } %>/, content)
13971397
end
13981398
end
13991399

@@ -1421,7 +1421,7 @@ def test_devcontainer_mariadb_mysql
14211421
assert_includes(content["forwardPorts"], 3306)
14221422
end
14231423
assert_file("config/database.yml") do |content|
1424-
assert_match(/host: <%= ENV.fetch\("DB_HOST"\) \{ "localhost" } %>/, content)
1424+
assert_match(/host: <%= ENV.fetch\("DB_HOST"\) \{ "127.0.0.1" } %>/, content)
14251425
end
14261426
end
14271427

@@ -1448,7 +1448,7 @@ def test_devcontainer_mariadb_trilogy
14481448
assert_includes(content["forwardPorts"], 3306)
14491449
end
14501450
assert_file("config/database.yml") do |content|
1451-
assert_match(/host: <%= ENV.fetch\("DB_HOST"\) \{ "localhost" } %>/, content)
1451+
assert_match(/host: <%= ENV.fetch\("DB_HOST"\) \{ "127.0.0.1" } %>/, content)
14521452
end
14531453
end
14541454

0 commit comments

Comments
 (0)
Please sign in to comment.