FEATURE: trigger `user_updated` event if username is changed.

FEATURE: trigger user_updated event if username is changed.

diff --git a/app/jobs/regular/update_username.rb b/app/jobs/regular/update_username.rb
index 5a067af..ea4985d 100644
--- a/app/jobs/regular/update_username.rb
+++ b/app/jobs/regular/update_username.rb
@@ -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
diff --git a/spec/services/username_changer_spec.rb b/spec/services/username_changer_spec.rb
index 9b6a1a1..a860ac7 100644
--- a/spec/services/username_changer_spec.rb
+++ b/spec/services/username_changer_spec.rb
@@ -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)

GitHub sha: 9426d12c

This commit has been mentioned on Discourse Meta. There might be relevant details there: