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
..
2023-11-10 00:44:05 +04:00
2023-11-13 10:46:15 -05:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-01-09 11:49:28 +00:00
2023-05-15 09:54:54 +02:00
2023-06-01 10:00:01 +10:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-03-10 13:45:01 +08:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-01-09 11:49:28 +00:00
2023-02-06 18:24:12 +00:00
2022-07-28 10:27:38 +08:00
2023-01-09 11:49:28 +00:00
2023-01-09 11:49:28 +00:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-04-13 15:38:54 +08:00
2023-08-29 18:41:33 -03:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2022-07-28 10:27:38 +08:00
2023-11-09 16:47:59 -06:00
2023-05-24 09:57:46 +02:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-01-09 11:49:28 +00:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-06-26 11:41:52 +02:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-01-09 11:49:28 +00:00
2022-07-28 10:27:38 +08:00
2023-11-13 11:06:25 +08:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-11-13 11:06:25 +08:00
2023-11-08 23:13:25 +04:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-08-01 00:48:40 +02:00
2023-11-02 08:10:15 +03:00
2023-06-26 11:41:52 +02:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-06-26 11:41:52 +02:00
2023-08-17 12:33:52 +10:00
2023-06-26 11:41:52 +02:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-08-17 14:46:24 +10:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-14 19:53:27 +00:00
2023-01-09 11:49:28 +00:00
2023-11-02 08:10:15 +03:00
2023-11-02 08:10:15 +03:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2022-07-28 10:27:38 +08:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-05-31 19:32:06 +05:30
2023-01-09 11:49:28 +00:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-06-13 22:02:21 +02:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-07-14 16:52:39 +08:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-10-17 14:08:21 +10:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2022-07-28 10:27:38 +08:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-06-26 11:41:52 +02:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-11-21 17:03:19 +11:00
2023-11-09 16:47:59 -06:00
2023-11-09 16:47:59 -06:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00
2023-08-15 12:12:22 -03:00
2023-01-09 11:49:28 +00:00
2023-05-06 07:15:33 +10:00
2023-01-09 11:49:28 +00:00
2023-11-09 16:47:59 -06:00