Skip to content

Commit

Permalink
Merge pull request #52992 from excid3/fix-ci-railtie-test-command
Browse files Browse the repository at this point in the history
Generate the correct bin/test command for railtie CI config
  • Loading branch information
rafaelfranca committed Sep 20, 2024
1 parent 64a64fd commit ec73277
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,11 @@ def relative_path

def test_command
if engine? && !options[:skip_active_record] && with_dummy_app?
"db:test:prepare test"
"bin/rails db:test:prepare test"
elsif engine?
"bin/rails test"
else
"test"
"bin/test"
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
DATABASE_URL: postgres://postgres:postgres@localhost:5432
<%- end -%>
# REDIS_URL: redis://localhost:6379/0
run: bin/rails <%= test_command %>
run: <%= test_command %>

- name: Keep screenshots from failed system tests
uses: actions/upload-artifact@v4
Expand Down
15 changes: 15 additions & 0 deletions railties/test/generators/plugin_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,21 @@ def test_app_update_generates_bin_file
Object.send(:remove_const, "ENGINE_ROOT")
end

def test_railtie_test_command
run_generator [destination_root]
assert_file ".github/workflows/ci.yml", /run: bin\/test/
end

def test_engine_test_command
run_generator [destination_root, "--full"]
assert_file ".github/workflows/ci.yml", /run: bin\/rails db:test:prepare test/
end

def test_engine_without_active_record_test_command
run_generator [destination_root, "--full", "--skip-active-record"]
assert_file ".github/workflows/ci.yml", /run: bin\/rails test/
end

private
def action(*args, &block)
silence(:stdout) { generator.send(*args, &block) }
Expand Down

0 comments on commit ec73277

Please sign in to comment.