discourse/spec/models
Selase Krakani 862007fb18
FEATURE: Add support for case-sensitive Watched Words (#17445)
* FEATURE: Add case-sensitivity flag to watched_words

Currently, all watched words are matched case-insensitively. This flag
allows a watched word to be flagged for case-sensitive matching.
To allow allow for backwards compatibility the flag is set to false by
default.

* FEATURE: Support case-sensitive creation of Watched Words via API

Extend admin creation and upload of Watched Words to support case
sensitive flag. This lays the ground work for supporting
case-insensitive matching of Watched Words.

Support for an extra column has also been introduced for the Watched
Words upload CSV file. The new column structure is as follows:

 word,replacement,case_sentive

* FEATURE: Enable case-sensitive matching of Watched Words

WordWatcher's word_matcher_regexp now returns a list of regular
expressions instead of one case-insensitive regular expression.

With the ability to flag a Watched Word as case-sensitive, an action
can have words of both sensitivities.This makes the use of the global
Regexp::IGNORECASE flag added to all words problematic.

To get around platform limitations around the use of subexpression level
switches/flags, a list of regular expressions is returned instead, one for each
case sensitivity.

Word matching has also been updated to use this list of regular expressions
instead of one.

* FEATURE: Use case-sensitive regular expressions for Watched Words

Update Watched Words regular expressions matching and processing to handle
the extra metadata which comes along with the introduction of
case-sensitive Watched Words.

This allows case-sensitive Watched Words to matched as such.

* DEV: Simplify type casting of case-sensitive flag from uploads

Use builtin semantics instead of a custom method for converting
string case flags in uploaded Watched Words to boolean.

* UX: Add case-sensitivity details to Admin Watched Words UI

Update Watched Word form to include a toggle for case-sensitivity.
This also adds support for, case-sensitive testing and matching of  Watched Word
in the admin UI.

* DEV: Code improvements from review feedback

 - Extract watched word regex creation out to a utility function
 - Make JS array presence check more explicit and readable

* DEV: Extract Watched Word regex creation to utility function

Clean-up work from review feedback. Reduce code duplication.

* DEV: Rename word_matcher_regexp to word_matcher_regexp_list

Since a list is returned now instead of a single regular expression,
change `word_matcher_regexp` to `word_matcher_regexp_list` to better communicate
this change.

* DEV:  Incorporate WordWatcher updates from upstream

Resolve conflicts and ensure apply_to_text does not remove non-word characters in matches
that aren't at the beginning of the line.
2022-08-02 10:06:03 +02:00
..
about_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
admin_dashboard_data_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
api_key_scope_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
api_key_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
application_request_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
associated_group_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
badge_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
badge_type_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
bookmark_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
category_featured_topic_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
category_group_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
category_list_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
category_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
category_user_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
child_theme_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
color_scheme_color_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
color_scheme_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
developer_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
digest_email_site_setting_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
directory_item_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
discourse_connect_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
do_not_disturb_timing_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
draft_sequence_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
draft_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
email_change_request_spec.rb DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
email_log_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
email_token_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
embeddable_host_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
emoji_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
given_daily_like_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
global_setting_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
group_archived_message_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
group_associated_group_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
group_history_spec.rb DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
group_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
group_user_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
incoming_link_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
incoming_links_report_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
invite_redeemer_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
invite_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
javascript_cache_spec.rb DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
locale_site_setting_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
mailing_list_mode_site_setting_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
notification_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
optimized_image_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
permalink_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
plugin_store_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
post_action_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
post_action_type_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
post_analyzer_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
post_detail_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
post_mover_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
post_reply_key_spec.rb DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
post_reply_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
post_revision_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
post_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
post_timing_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
private_message_topic_tracking_state_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
published_page_spec.rb DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
quoted_post_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
remote_theme_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
report_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
reviewable_claimed_topic_spec.rb DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
reviewable_flagged_post_spec.rb DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
reviewable_history_spec.rb DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
reviewable_post_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
reviewable_queued_post_spec.rb DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
reviewable_score_spec.rb DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
reviewable_spec.rb DEV: Add reviewables tab to the new user menu (#17630) 2022-07-28 11:16:33 +03:00
reviewable_user_spec.rb DEV: Use `describe` for methods in specs 2022-07-27 16:35:27 +02:00
s3_region_site_setting_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
screened_email_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
screened_ip_address_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
screened_url_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
search_log_spec.rb DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
sidebar_section_link_spec.rb FEATURE: Decouple category/tag presence in sidebar from notifi level (#17273) 2022-06-30 14:54:20 +08:00
site_setting_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
site_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
sitemap_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
skipped_email_log_spec.rb DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
stylesheet_cache_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
tag_group_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
tag_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
tag_user_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
theme_field_spec.rb FIX: Ensure theme_uploads_local only has one `/` at beginning (#17719) 2022-07-28 22:20:52 +01:00
theme_modifier_set_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
theme_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
top_menu_item_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
top_topic_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_allowed_user_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_converter_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_embed_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_featured_users_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_group_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_invite_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_link_click_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_link_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_list_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_participants_summary_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_posters_summary_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_tag_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_thumbnail_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_timer_spec.rb DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
topic_tracking_state_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_user_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_view_item_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
translation_override_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
trust_level3_requirements_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
trust_level_and_staff_setting_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
trust_level_setting_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
unsubscribe_key_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
upload_reference_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
upload_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_action_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_api_key_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_archived_message_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_associated_group_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_auth_token_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_avatar_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_badge_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_bookmark_list_spec.rb FEATURE: Promote polymorphic bookmarks to default and migrate (#16729) 2022-05-23 10:07:15 +10:00
user_email_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_export_spec.rb DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
user_field_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_history_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_notification_schedule_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_option_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_profile_spec.rb DEV: Use `describe` for methods in specs 2022-07-27 16:35:27 +02:00
user_profile_view_spec.rb DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
user_search_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_second_factor_spec.rb DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
user_spec.rb DEV: Use `describe` for methods in specs 2022-07-27 16:35:27 +02:00
user_stat_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_status_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_summary_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_visit_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
username_validator_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
watched_word_spec.rb FEATURE: Add support for case-sensitive Watched Words (#17445) 2022-08-02 10:06:03 +02:00
web_crawler_request_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
web_hook_event_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
web_hook_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00