mirror of
https://github.com/discourse/discourse.git
synced 2025-01-30 05:34:03 +08:00
FEATURE: trigger user_updated
event if username is changed.
This commit is contained in:
parent
de243426c4
commit
9426d12c1d
|
@ -36,6 +36,7 @@ module Jobs
|
|||
update_post_custom_fields
|
||||
|
||||
DiscourseEvent.trigger(:username_changed, @old_username, @new_username)
|
||||
DiscourseEvent.trigger(:user_updated, User.find_by(id: @user_id))
|
||||
end
|
||||
|
||||
def update_posts
|
||||
|
|
|
@ -15,16 +15,21 @@ describe UsernameChanger do
|
|||
let(:new_username) { "#{user.username}1234" }
|
||||
|
||||
it 'should change the username' do
|
||||
event = DiscourseEvent.track_events {
|
||||
events = DiscourseEvent.track_events {
|
||||
@result = UsernameChanger.change(user, new_username)
|
||||
}.last
|
||||
}.last(2)
|
||||
|
||||
expect(@result).to eq(true)
|
||||
|
||||
event = events.first
|
||||
expect(event[:event_name]).to eq(:username_changed)
|
||||
expect(event[:params].first).to eq(old_username)
|
||||
expect(event[:params].second).to eq(new_username)
|
||||
|
||||
event = events.last
|
||||
expect(event[:event_name]).to eq(:user_updated)
|
||||
expect(event[:params].first).to eq(user)
|
||||
|
||||
user.reload
|
||||
expect(user.username).to eq(new_username)
|
||||
expect(user.username_lower).to eq(new_username.downcase)
|
||||
|
|
Loading…
Reference in New Issue
Block a user