mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 02:48:28 +08:00
FEATURE: introduce dedicated storage and DB constraints for anon users
Previously we used custom fields to denote a user was anonymous, this was risky in that custom fields are prone to race conditions and are not properly dedicated, missing constraints and so on. The new table `anonymous_users` is properly protected. There is only one possible shadow account per user, which is enforced using a constraint. Every anonymous user will have a unique row in the new table.
This commit is contained in:
@ -34,6 +34,9 @@ describe AnonymousShadowCreator do
|
||||
expect(shadow.id).to eq(shadow2.id)
|
||||
create_post(user: shadow)
|
||||
|
||||
user.reload
|
||||
shadow.reload
|
||||
|
||||
freeze_time 4.minutes.from_now
|
||||
shadow3 = AnonymousShadowCreator.get(user)
|
||||
|
||||
@ -56,6 +59,7 @@ describe AnonymousShadowCreator do
|
||||
expect(shadow.created_at).not_to eq(user.created_at)
|
||||
|
||||
p = create_post
|
||||
|
||||
expect(Guardian.new(shadow).post_can_act?(p, :like)).to eq(false)
|
||||
expect(Guardian.new(user).post_can_act?(p, :like)).to eq(true)
|
||||
|
||||
|
Reference in New Issue
Block a user