FIX: Update search index after renaming user within posts

This commit is contained in:
Gerhard Schlager 2018-05-14 13:20:15 +02:00
parent 02cb84847c
commit 8232aba743
2 changed files with 10 additions and 0 deletions

View File

@ -24,6 +24,8 @@ module Jobs
# update without running validations and hooks
post.update_columns(raw: post.raw, cooked: post.cooked)
SearchIndexer.index(post, force: true)
end
end

View File

@ -120,6 +120,14 @@ describe UsernameChanger do
expect(post.cooked).to eq(%Q(<p>Hello <a class="mention" href="/u/bar">@bar</a></p>))
end
it 'removes the username from the search index' do
SearchIndexer.enable
create_post_and_change_username(raw: "Hello @foo")
results = Search.execute('foo', min_search_term_length: 1)
expect(results.posts).to be_empty
end
it 'ignores case when replacing mentions' do
post = create_post_and_change_username(raw: "There's no difference between @foo and @Foo")