discourse/spec
Alan Guo Xiang Tan 1510e1d1ea
DEV: Fix flaky test due to ActiveRecord query caching (#24476)
Why this change?

The test was randomly failing in
https://github.com/discourse/discourse/actions/runs/6936264158/job/18868087113
with the following failure:

```
expect do user.update_ip_address!("127.0.0.1") end.to change {
  UserIpAddressHistory.where(user_id: user.id).count
}.by(1)

expected `UserIpAddressHistory.where(user_id: user.id).count` to have changed by 1, but was changed by 0
```

This is due to the fact that ActiveRecord will actually cache the result
of `UserIpAddressHistory.where(user_id: user.id).count`. However,
`User.update_ip_address!` relies on mini_sql and does not go through
ActiveRecord. As a result, the query cache is not cleared and hence the
flakiness.

What does this change do?

This change uses the `uncached` method provided by ActiveRecord when
we are fetching the count.
2023-11-21 17:03:19 +11:00
..
fabricators DEV: Housekeeping for CleanUpUploads job (#24361) 2023-11-20 09:50:09 +10:00
fixtures FEATURE: remove category badge style options, set bullet style as default (#24198) 2023-11-13 10:46:15 -05:00
helpers DEV: Simplify ember-cli proxy strategy (#24242) 2023-11-10 11:16:06 +00:00
import_export DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
initializers DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
integration DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
integrity DEV: Modernise highlightjs loading (#24197) 2023-11-10 20:39:48 +00:00
jobs DEV: Housekeeping for CleanUpUploads job (#24361) 2023-11-20 09:50:09 +10:00
lib FEATURE: Admin plugin list redesign (#24363) 2023-11-21 09:37:11 +10:00
mailers DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
migrations DEV: Switch over category settings to new table - Part 3 (#20657) 2023-09-12 09:51:49 +08:00
models DEV: Fix flaky test due to ActiveRecord query caching (#24476) 2023-11-21 17:03:19 +11:00
multisite DEV: Add S3 upload system specs using minio (#22975) 2023-08-23 11:18:33 +10:00
requests DEV: Add support for limit in notifications index w/o recent param (#24423) 2023-11-17 08:22:18 -06:00
script/import_scripts DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
serializers DEV: Rename `experimental_passkeys` to `enable_passkeys` (#24349) 2023-11-13 15:04:15 -05:00
services DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
support DEV: Fix S3 minio specs on CI (#24426) 2023-11-17 14:28:06 +10:00
system FEATURE: Admin plugin list redesign (#24363) 2023-11-21 09:37:11 +10:00
tasks DEV: Remove the transpilation message (#23998) 2023-10-19 01:00:15 +02:00
views DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
rails_helper.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
regenerate_swagger_docs DEV: Add API docs for uploads and API doc watcher (#15387) 2021-12-23 08:40:15 +10:00
swagger_helper.rb DEV: Apply syntax_tree formatting to `spec/*` 2023-01-09 11:49:28 +00:00