File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
lib/rails/commands/devcontainer Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -22,13 +22,18 @@ def perform(*)
22
22
def devcontainer_options
23
23
@devcontainer_options ||= {
24
24
app_name : Rails . application . railtie_name . chomp ( "_application" ) ,
25
- database : !!defined? ( ActiveRecord ) && ActiveRecord :: Base . connection_db_config . adapter ,
25
+ database : !!defined? ( ActiveRecord ) && database ,
26
26
active_storage : !!defined? ( ActiveStorage ) ,
27
27
redis : !!( defined? ( ActionCable ) || defined? ( ActiveJob ) ) ,
28
28
system_test : File . exist? ( "test/application_system_test_case.rb" ) ,
29
29
node : File . exist? ( ".node-version" ) ,
30
30
}
31
31
end
32
+
33
+ def database
34
+ adapter = ActiveRecord ::Base . connection_db_config . adapter
35
+ adapter == "mysql2" ? "mysql" : adapter
36
+ end
32
37
end
33
38
end
34
39
end
Original file line number Diff line number Diff line change @@ -20,4 +20,28 @@ class Rails::Command::DevcontainerTest < ActiveSupport::TestCase
20
20
assert_match "system_test: true" , output
21
21
assert_match "node: false" , output
22
22
end
23
+
24
+ test "generates devcontainer for using mysql2 app" do
25
+ build_app
26
+
27
+ Dir . chdir ( app_path ) do
28
+ use_mysql2
29
+
30
+ output = rails "devcontainer"
31
+
32
+ assert_match "app_name: app_template" , output
33
+ assert_match "database: mysql" , output
34
+ assert_match "active_storage: true" , output
35
+ assert_match "redis: true" , output
36
+ assert_match "system_test: true" , output
37
+ assert_match "node: false" , output
38
+
39
+ assert_match "ghcr.io/rails/devcontainer/features/mysql-client" , read_file ( ".devcontainer/devcontainer.json" )
40
+ end
41
+ end
42
+
43
+ private
44
+ def read_file ( relative )
45
+ File . read ( app_path ( relative ) )
46
+ end
23
47
end
You can’t perform that action at this time.
0 commit comments