Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Flaky ActiveStorage test (rails#41225)
Fixes a flaky Active Storage test introduced by [rails#41065][], and improves the documentation. It seems that the test is covering the backwards compatibility of an older interface for retrieving records through `ActiveStorage::Record#find_signed!`. The test itself would pass unpredictably. To isolate the failure and reproduce it consistently, a see value was found after some trial and error: ``` SEED=59729 bin/test test/fixture_set_test.rb test/models/attachment_test.rb ``` This _used_ to pass consistently because [rails/rails][rails#41065] introduced a call to `fixtures :all`, which introduces more variation in the database's ID generation sequence. Without that line, `id` values start at `1`, so the fact that calls to `ActiveStorage::Attached::One#id` and `ActiveStorage::Blob#id` **both return `1`** is purely coincidence. The proposed resolution changes the test slightly. Prior to this change, the identifier used during retrieval and verification fetched from `@user.avatar.id`, where `@user.avatar` is an instance of `ActiveStorage::Attached::One`. The verifier/retriever combination in that test expected a signed identifier for an `ActiveStorage::Blob` instance. The change involved retrieving an instance through `@user.avatar.blob`. To better emphasize how global the `fixtures :all` declaration is, move it from the `test/fixture_set_test.rb` file to the `test/test_helper.rb` file. [rails#41065]: rails#41065
- Loading branch information