From 3f1063b8fe0c5f3a80472025bf86e6a547ae232b Mon Sep 17 00:00:00 2001 From: Chris Lowis Date: Wed, 11 Dec 2024 09:45:37 -0500 Subject: [PATCH] Re-enable parallel testing (in development) This commit re-enables parallel testing. This takes advantage of the extra cores available on development machines. I've set `parallelize(workers: 1)` to retain the current behaviour in CI, but locally a developer can run `PARALLEL_WORKERS=8 bin/rails test` for example to take advantage of additional cores. I had to make CreatingAnArtistTest more deterministic - relying on finding the artist specifically rather than calling `Artist.last` to make it run alongside other tests in parallel. I also added a text assertion for good measure to ensure the Artist had been created before the `artist_path` was visited. --- test/system/creating_an_artist_test.rb | 3 ++- test/test_helper.rb | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/test/system/creating_an_artist_test.rb b/test/system/creating_an_artist_test.rb index 2263a058..bf57a158 100644 --- a/test/system/creating_an_artist_test.rb +++ b/test/system/creating_an_artist_test.rb @@ -18,8 +18,9 @@ class CreatingAnArtistTest < ApplicationSystemTestCase attach_file 'Profile picture', Rails.root.join('test/fixtures/files/cover.png') click_on 'Save' + assert_text 'Artist was successfully created' - visit artist_path(Artist.last) + visit artist_path(Artist.find_by(name: 'The Beatles')) assert_text 'The Beatles' assert_text 'Liverpool' diff --git a/test/test_helper.rb b/test/test_helper.rb index ac3ba229..a4236069 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -7,6 +7,8 @@ module ActiveSupport class TestCase + parallelize(workers: 1) + include FactoryBot::Syntax::Methods WebMock.disable_net_connect!(allow_localhost: true)