Use Precomputed Hashes Instead of BCrypt in Test
I asked Claude to find the slowest test file again after my success earlier today and Claude found a call to BCrypt in my fixtures that was gobbling up time.
I need user records all over the place in my test and each new user is a new call to encrypt a password.
Here is Claude’s summary, with my Grammarly edits:
Problem: ThePreviewsControllerTest#test_should_show_preview_for_own_unpublished_posttest was taking 2.95 seconds due to BCrypt password hashing being computed dynamically in fixtures with<%= BCrypt::Password.create("password") %>.
Solution: Replaced the dynamic BCrypt computation with a pre-computed hash$2a$12$dapdHZiOTxAL8OT9yNI6e.hhTjRhWgXq7kx737/xf8tBfQbMD2bifor all user fixtures.
Result: The slowest test now runs in ~0.25-0.52 seconds (82% improvement) and all tests pass. The overall test suite performance has been significantly improved, as this optimization affects all tests that use user fixtures.