DEV: trigger :username_changed when a user is renamed (#9301)
This commit is contained in:
parent
6c2717eda0
commit
96e841a635
|
@ -34,6 +34,8 @@ module Jobs
|
|||
update_revisions
|
||||
update_notifications
|
||||
update_post_custom_fields
|
||||
|
||||
DiscourseEvent.trigger(:username_changed, @old_username, @new_username)
|
||||
end
|
||||
|
||||
def update_posts
|
||||
|
|
|
@ -11,13 +11,20 @@ describe UsernameChanger do
|
|||
let(:user) { Fabricate(:user) }
|
||||
|
||||
context 'success' do
|
||||
let!(:old_username) { user.username }
|
||||
let(:new_username) { "#{user.username}1234" }
|
||||
|
||||
it 'should change the username' do
|
||||
@result = UsernameChanger.change(user, new_username)
|
||||
event = DiscourseEvent.track_events {
|
||||
@result = UsernameChanger.change(user, new_username)
|
||||
}.last
|
||||
|
||||
expect(@result).to eq(true)
|
||||
|
||||
expect(event[:event_name]).to eq(:username_changed)
|
||||
expect(event[:params].first).to eq(old_username)
|
||||
expect(event[:params].second).to eq(new_username)
|
||||
|
||||
user.reload
|
||||
expect(user.username).to eq(new_username)
|
||||
expect(user.username_lower).to eq(new_username.downcase)
|
||||
|
|
Loading…
Reference in New Issue