mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: trigger :username_changed when a user is renamed (#9301)
This commit is contained in:
@@ -34,6 +34,8 @@ module Jobs
|
|||||||
update_revisions
|
update_revisions
|
||||||
update_notifications
|
update_notifications
|
||||||
update_post_custom_fields
|
update_post_custom_fields
|
||||||
|
|
||||||
|
DiscourseEvent.trigger(:username_changed, @old_username, @new_username)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_posts
|
def update_posts
|
||||||
|
|||||||
@@ -11,13 +11,20 @@ describe UsernameChanger do
|
|||||||
let(:user) { Fabricate(:user) }
|
let(:user) { Fabricate(:user) }
|
||||||
|
|
||||||
context 'success' do
|
context 'success' do
|
||||||
|
let!(:old_username) { user.username }
|
||||||
let(:new_username) { "#{user.username}1234" }
|
let(:new_username) { "#{user.username}1234" }
|
||||||
|
|
||||||
it 'should change the username' do
|
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(@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
|
user.reload
|
||||||
expect(user.username).to eq(new_username)
|
expect(user.username).to eq(new_username)
|
||||||
expect(user.username_lower).to eq(new_username.downcase)
|
expect(user.username_lower).to eq(new_username.downcase)
|
||||||
|
|||||||
Reference in New Issue
Block a user