mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
alert_words: Fix case-sensitivity of alert words.
Previously, alert words were case-insensitive in practice, by which I mean the Markdown logic had always been case-insensitive; but the data model was not, so you could create "duplicate" alert words with the same words in different cases. We fix this inconsistency by making the database model case-insensitive. I'd prefer to be using the Postgres `citext` extension to have postgres take care of case-insensitive logic for us, but that requires installing a postgres extension as root on the postgres server, which is a pain and perhaps not worth the effort to arrange given that we can achieve our goals with transaction when adding alert words. We take advantage of the migrate_alert_words migration we're already doing for all users to effect this transition. Fixes #12563.
This commit is contained in:
@@ -56,6 +56,16 @@ class AlertWordTests(ZulipTestCase):
|
||||
words = user_alert_words(user)
|
||||
self.assertEqual(set(words), set(self.interesting_alert_word_list))
|
||||
|
||||
# Test the case-insensitivity of adding words
|
||||
add_user_alert_words(user, set(["ALert", "ALERT"]))
|
||||
words = user_alert_words(user)
|
||||
self.assertEqual(set(words), set(self.interesting_alert_word_list))
|
||||
|
||||
# Test the case-insensitivity of removing words
|
||||
remove_user_alert_words(user, set(["ALert"]))
|
||||
words = user_alert_words(user)
|
||||
self.assertEqual(set(words), set(self.interesting_alert_word_list) - {'alert'})
|
||||
|
||||
def test_remove_word(self) -> None:
|
||||
"""
|
||||
Removing alert words works via remove_user_alert_words, even
|
||||
|
||||
Reference in New Issue
Block a user