Skip to content

Commit 4d591da

Browse files
committed
Generate the correct bin/test command for railtie CI config
1 parent 9716991 commit 4d591da

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

railties/lib/rails/generators/rails/plugin/plugin_generator.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,11 @@ def relative_path
489489

490490
def test_command
491491
if engine? && !options[:skip_active_record] && with_dummy_app?
492-
"db:test:prepare test"
492+
"bin/rails db:test:prepare test"
493+
elsif engine?
494+
"bin/rails test"
493495
else
494-
"test"
496+
"bin/test"
495497
end
496498
end
497499
end

railties/lib/rails/generators/rails/plugin/templates/github/ci.yml.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
DATABASE_URL: postgres://postgres:postgres@localhost:5432
9191
<%- end -%>
9292
# REDIS_URL: redis://localhost:6379/0
93-
run: bin/rails <%= test_command %>
93+
run: <%= test_command %>
9494

9595
- name: Keep screenshots from failed system tests
9696
uses: actions/upload-artifact@v4

railties/test/generators/plugin_generator_test.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,21 @@ def test_app_update_generates_bin_file
915915
Object.send(:remove_const, "ENGINE_ROOT")
916916
end
917917

918+
def test_railtie_test_command
919+
run_generator [destination_root]
920+
assert_file ".github/workflows/ci.yml", /run: bin\/test/
921+
end
922+
923+
def test_engine_test_command
924+
run_generator [destination_root, "--full"]
925+
assert_file ".github/workflows/ci.yml", /run: bin\/rails db:test:prepare test/
926+
end
927+
928+
def test_engine_without_active_record_test_command
929+
run_generator [destination_root, "--full", "--skip-active-record"]
930+
assert_file ".github/workflows/ci.yml", /run: bin\/rails test/
931+
end
932+
918933
private
919934
def action(*args, &block)
920935
silence(:stdout) { generator.send(*args, &block) }

0 commit comments

Comments
 (0)