mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 21:31:04 +08:00
FIX: Remove all notifications of staged user during sign-up
This commit is contained in:
@ -235,6 +235,7 @@ class User < ActiveRecord::Base
|
|||||||
user.staged = false
|
user.staged = false
|
||||||
user.active = false
|
user.active = false
|
||||||
user.custom_fields[FROM_STAGED] = true
|
user.custom_fields[FROM_STAGED] = true
|
||||||
|
user.notifications.destroy_all
|
||||||
|
|
||||||
DiscourseEvent.trigger(:user_unstaged, user)
|
DiscourseEvent.trigger(:user_unstaged, user)
|
||||||
end
|
end
|
||||||
|
@ -1600,6 +1600,16 @@ describe User do
|
|||||||
expect(User.unstage(email: 'no@account.com')).to be_nil
|
expect(User.unstage(email: 'no@account.com')).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "removes all previous notifications during unstaging" do
|
||||||
|
Fabricate(:notification, user: user)
|
||||||
|
Fabricate(:private_message_notification, user: user)
|
||||||
|
user.reload
|
||||||
|
|
||||||
|
expect(user.total_unread_notifications).to eq(2)
|
||||||
|
user = User.unstage(params)
|
||||||
|
expect(user.total_unread_notifications).to eq(0)
|
||||||
|
end
|
||||||
|
|
||||||
it "triggers an event" do
|
it "triggers an event" do
|
||||||
unstaged_user = nil
|
unstaged_user = nil
|
||||||
event = DiscourseEvent.track_events { unstaged_user = User.unstage(params) }.first
|
event = DiscourseEvent.track_events { unstaged_user = User.unstage(params) }.first
|
||||||
|
Reference in New Issue
Block a user