mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 13:43:16 +08:00
1510e1d1ea
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. |
||
---|---|---|
.. | ||
fabricators | ||
fixtures | ||
helpers | ||
import_export | ||
initializers | ||
integration | ||
integrity | ||
jobs | ||
lib | ||
mailers | ||
migrations | ||
models | ||
multisite | ||
requests | ||
script/import_scripts | ||
serializers | ||
services | ||
support | ||
system | ||
tasks | ||
views | ||
rails_helper.rb | ||
regenerate_swagger_docs | ||
swagger_helper.rb |