thoughtbot / shoulda-matchers

Simple one-liner tests for common Rails functionality
https://matchers.shoulda.io
MIT License
3.5k stars 911 forks source link

counter_cache validation fails with Rails 7.2.beta #1638

Open jetienne opened 2 months ago

jetienne commented 2 months ago

Description

Testing counter_cache no longer works with Rails 7.2.beta.

Reproduction Steps

Define an association like this:

belongs_to :company, optional: true, counter_cache: true

The following test will fail:

it { is_expected.to belong_to(:company).optional.counter_cache(true) }

System configuration

shoulda-matchers (6.2.0)

matsales28 commented 2 months ago

Hi @jetienne, thanks for reporting that. We have a PR https://github.com/thoughtbot/shoulda-matchers/pull/1632/files that introduces compatibility between shoulda-matchers and Rails 7.2 and fixes this problem. We're waiting for the official release to merge it, to avoid any late change from the Rails team.

steveclarke commented 3 weeks ago

Thanks @matsales28 I'm attempting to upgrade to Rails 7.2 now and hitting this issue. I'll temporarily disable the counter_cache checks until the PR is merged.