discourse/spec/models
Krzysztof Kotlarek e82e255531
FIX: serialize Flags instead of PostActionType (#28362)
### Why?
Before, all flags were static. Therefore, they were stored in class variables and serialized by SiteSerializer. Recently, we added an option for admins to add their own flags or disable existing flags. Therefore, the class variable had to be dropped because it was unsafe for a multisite environment. However, it started causing performance problems. 

### Solution
When a new Flag system is used, instead of using PostActionType, we can serialize Flags and use fragment cache for performance reasons. 

At the same time, we are still supporting deprecated `replace_flags` API call. When it is used, we fall back to the old solution and the admin cannot add custom flags. In a couple of months, we will be able to drop that API function and clean that code properly. However, because it may still be used, redis cache was introduced to improve performance.

To test backward compatibility you can add this code to any plugin
```ruby
  replace_flags do |flag_settings|
    flag_settings.add(
      4,
      :inappropriate,
      topic_type: true,
      notify_type: true,
      auto_action_type: true,
    )
    flag_settings.add(1001, :trolling, topic_type: true, notify_type: true, auto_action_type: true)
  end
```
2024-08-14 12:13:46 +10:00
..
about_spec.rb DEV: Plugin modifier application for About admins (#27261) 2024-05-30 10:44:53 -05:00
admin_dashboard_data_spec.rb DEV: Upgrade Rails to version 7.1 2024-07-04 10:58:21 +02:00
admin_notice_spec.rb DEV: Database backed admin notices (#26192) 2024-05-23 09:29:08 +08:00
api_key_scope_spec.rb FIX: Logs api scope not working (#25215) 2024-01-10 19:30:10 -07:00
api_key_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
application_request_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
associated_group_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
badge_grouping_spec.rb DEV: Remove unnecessary rails_helper requiring (#26364) 2024-03-26 11:32:01 +01:00
badge_spec.rb FIX: Don't error out when loading a badge with a deleted image (#27688) 2024-07-04 10:03:09 +08:00
badge_type_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
bookmark_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
category_featured_topic_spec.rb DEV: Convert min_trust_to_create_topic to groups (#24740) 2023-12-13 14:50:13 +11:00
category_group_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
category_list_spec.rb DEV: Enable Rails 7.1 defaults 2024-08-12 10:41:13 +02:00
category_setting_spec.rb FEATURE: Configurable auto-bump cooldown (#20507) 2023-03-10 13:45:01 +08:00
category_spec.rb FIX: Make edit categories sidebar modal work more intuitively (#27111) 2024-06-14 11:37:32 -05:00
category_tag_stat_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
category_user_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
child_theme_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
color_scheme_color_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
color_scheme_spec.rb DEV: correctly delete custom scheme (#27203) 2024-05-27 16:35:42 +02:00
developer_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
digest_email_site_setting_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
directory_item_spec.rb DEV: Use freeze_time_safe in more places (#25949) 2024-03-01 10:07:35 +10:00
discourse_connect_spec.rb FIX: store registration ip address when creating user via SSO (#26121) 2024-03-11 15:19:37 +05:30
do_not_disturb_timing_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
draft_sequence_spec.rb FIX: Destroy Drafts when increasing sequences (#27739) 2024-07-10 10:43:11 +03:00
draft_spec.rb DEV: Delete upload references on draft cleanup (#26877) 2024-05-06 14:08:10 +08:00
email_change_request_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
email_log_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
email_token_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
embeddable_host_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
embeddable_host_tag_spec.rb FEATURE: Extend embeddable hosts with Individual tags and author assignments (#26868) 2024-05-16 15:47:01 -04:00
emoji_spec.rb DEV: Fix various spec linting issues (#24672) 2023-12-04 13:45:19 +01:00
flag_spec.rb FIX: serialize Flags instead of PostActionType (#28362) 2024-08-14 12:13:46 +10:00
form_template_spec.rb DEV: Remove unnecessary rails_helper requiring (#26364) 2024-03-26 11:32:01 +01:00
given_daily_like_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
global_setting_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
group_archived_message_spec.rb DEV: Remove full group refreshes from tests (#25414) 2024-01-25 14:28:26 +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: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
group_request_spec.rb DEV: Bump the limits on group request text fields 2023-05-24 09:57:46 +02:00
group_spec.rb UX: Use a dropdown for SSL mode for group SMTP (#27932) 2024-07-18 10:33:14 +10:00
group_user_spec.rb FIX: down downgrade trust level if all requirements are met. (#25953) 2024-03-04 09:30:30 +11:00
incoming_link_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
incoming_links_report_spec.rb DEV: Catch missing translations during test runs (#26258) 2024-05-24 22:15:53 +08:00
invite_redeemer_spec.rb FIX: Don't show that an existing user is invited_by another user (#27665) 2024-07-04 10:27:37 +08:00
invite_spec.rb FIX: should not raise error when both group & site tag preferences are same. (#27704) 2024-07-04 11:53:28 +05:30
javascript_cache_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
locale_site_setting_spec.rb DEV: Add missing Chinese simplified to names.yml (#27847) 2024-07-11 07:54:45 -07:00
mailing_list_mode_site_setting_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
notification_spec.rb PERF: Add indexes to speed up notifications queries by user menu (#26048) 2024-03-06 16:52:19 +08:00
optimized_image_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
permalink_spec.rb FIX: Store special characters in permalink URL as encoded characters 2024-06-03 13:20:24 +02:00
plugin_store_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
post_action_spec.rb FEATURE: custom flag can require additional message (#27908) 2024-07-18 10:10:22 +10:00
post_action_type_spec.rb FIX: serialize Flags instead of PostActionType (#28362) 2024-08-14 12:13:46 +10:00
post_analyzer_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
post_detail_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
post_mover_spec.rb FEATURE: Add option to immediately delete stub topics upon merge (#28228) 2024-08-07 10:05:40 -03:00
post_reply_key_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
post_reply_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
post_revision_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
post_spec.rb FIX: Add post id to the anchor to prevent two identical anchors (#28070) 2024-07-25 13:50:30 +08:00
post_stripper_spec.rb FIX: user got notified about a mention inside a chat message quote (#24229) 2023-11-08 23:13:25 +04:00
post_timing_spec.rb FIX: disable storing invalid post and topic timing when sent from client (#26683) 2024-04-19 18:10:50 +10:00
private_message_topic_tracking_state_spec.rb PERF: avoid publishing user actions to the user who did the action (#26225) 2024-03-18 18:05:46 +01:00
problem_check_tracker_spec.rb DEV: Database backed admin notices (#26192) 2024-05-23 09:29:08 +08:00
published_page_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
quoted_post_spec.rb DEV: Fix a flaky quote post spec (#22891) 2023-08-01 00:48:40 +02:00
remote_theme_spec.rb DEV: Refactor Theme#settings to return a hash instead of array (#25516) 2024-02-01 10:26:56 +08:00
report_spec.rb FEATURE: Topic view stats report (#27760) 2024-07-09 15:39:10 +10:00
reviewable_claimed_topic_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
reviewable_flagged_post_spec.rb FEATURE: add agree and edit (#27088) 2024-05-23 11:21:42 -07:00
reviewable_history_spec.rb DEV: Convert min_trust_to_flag_posts setting to groups (#24864) 2023-12-13 17:18:42 +08:00
reviewable_post_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
reviewable_queued_post_spec.rb DEV: Convert min_trust_level_to_tag_topics to groups (#25273) 2024-01-26 13:25:03 +08:00
reviewable_score_spec.rb DEV: Automatically update groups for test users with explicit TL (#25415) 2024-01-29 17:52:02 +08:00
reviewable_spec.rb FIX: Bump reject_reason limit for reviewables to 2000 characters (#27507) 2024-06-18 15:49:58 +10:00
reviewable_user_spec.rb DEV: reviewable_user spec should assert on delete_user_block instead of delete_user (#24692) 2023-12-04 12:44:32 -03:00
s3_region_site_setting_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
screened_email_spec.rb DEV: Update the rubocop-discourse gem 2023-06-26 11:41:52 +02:00
screened_ip_address_spec.rb DEV: find_each in CSV exports (#22573) 2023-08-17 12:33:52 +10:00
screened_url_spec.rb DEV: Update the rubocop-discourse gem 2023-06-26 11:41:52 +02:00
search_log_spec.rb DEV: Add search_log modifier to prevent search log logging (#28279) 2024-08-08 12:41:10 -05:00
sidebar_section_link_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
sidebar_section_spec.rb FEATURE: Initial admin sidebar navigation (#24789) 2023-12-18 11:48:25 +10:00
sidebar_url_spec.rb FIX: increase sidebar URL limit to 1000 (#23120) 2023-08-17 14:46:24 +10:00
site_setting_spec.rb FEATURE: Allow site settings to be edited throughout admin UI (#26154) 2024-03-18 08:50:39 +10:00
site_spec.rb FIX: Preload all ancestors of sidebar categories (#26715) 2024-05-06 11:55:20 -05:00
sitemap_spec.rb DEV: Remove unnecessary rails_helper requiring (#26364) 2024-03-26 11:32:01 +01:00
skipped_email_log_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
stylesheet_cache_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
tag_group_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
tag_spec.rb DEV: Convert min_trust_level_to_tag_topics to groups (#25273) 2024-01-26 13:25:03 +08:00
tag_user_spec.rb DEV: Convert min_trust_level_to_tag_topics to groups (#25273) 2024-01-26 13:25:03 +08:00
theme_field_spec.rb DEV: Remove experimental_objects_type_for_theme_settings site setting (#26507) 2024-04-04 12:01:31 +08:00
theme_modifier_set_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
theme_setting_spec.rb FIX: Use the proper i18n argument name 2024-06-12 11:11:02 +02:00
theme_settings_migration_spec.rb FEATURE: Theme settings migrations (#24071) 2023-11-02 08:10:15 +03:00
theme_spec.rb DEV: Introduce run_theme_migration spec helper in test environment (#26845) 2024-05-03 06:29:18 +08:00
theme_svg_sprite_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
top_menu_item_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
top_topic_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
topic_allowed_user_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
topic_converter_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
topic_embed_spec.rb FIX: topic embed blank tags or passed with nil do not blank out existing topic tags (#27699) 2024-07-03 14:50:59 -07:00
topic_featured_users_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
topic_group_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
topic_hot_scores_spec.rb DEV: Use freeze_time_safe in more places (#25949) 2024-03-01 10:07:35 +10:00
topic_invite_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
topic_link_click_spec.rb DEV: Convert min_trust_to_post_links to groups (#25298) 2024-01-18 14:08:40 +08:00
topic_link_spec.rb FEATURE: support silent internal links (#25472) 2024-01-30 17:03:58 +11:00
topic_list_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
topic_participant_groups_summary_spec.rb FEATURE: display PM participant group names in the topics list. (#21677) 2023-05-31 19:32:06 +05:30
topic_participants_summary_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
topic_posters_summary_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
topic_spec.rb FIX: Don't count draft views towards topic view stats (#28162) 2024-07-31 11:10:50 +08:00
topic_tag_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
topic_thumbnail_spec.rb DEV: Fix random typos (#22078) 2023-06-13 22:02:21 +02:00
topic_timer_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
topic_tracking_state_spec.rb DEV: Dedicated route for current user notification counts (#26106) 2024-03-15 12:08:37 -04:00
topic_user_spec.rb DEV: Publish DiscourseEvent in TopicUser.track_visit for first visit (#27975) 2024-07-19 10:53:12 -05:00
topic_view_item_spec.rb FEATURE: topic_view_stats table with daily fidelity (#27197) 2024-05-27 15:25:32 +10:00
translation_override_spec.rb DEV: Fix flaky spec related to translation overrides 2024-07-26 13:20:20 +02:00
trust_level_and_staff_setting_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
trust_level_setting_spec.rb DEV: Skip flaky specs (#25111) 2024-01-03 12:32:26 +01:00
trust_level3_requirements_spec.rb DEV: move post flags into database (#27125) 2024-05-23 12:19:07 +10:00
unsubscribe_key_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
upload_reference_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
upload_spec.rb FIX: Don't error out when loading a badge with a deleted image (#27688) 2024-07-04 10:03:09 +08:00
user_action_spec.rb PERF: avoid publishing user actions to the user who did the action (#26225) 2024-03-18 18:05:46 +01:00
user_api_key_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
user_archived_message_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
user_associated_group_spec.rb Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
user_auth_token_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
user_avatar_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
user_badge_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
user_bookmark_list_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
user_email_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
user_export_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
user_field_spec.rb FEATURE: Implement new required options in admin user fields UI (#27079) 2024-05-23 19:18:25 +08:00
user_history_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
user_notification_schedule_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
user_option_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
user_password_spec.rb FEATURE: Allow site admin to mark a user's password as expired (#27314) 2024-06-04 15:42:53 +08:00
user_profile_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
user_profile_view_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
user_search_spec.rb DEV: Update rubocop-discourse to latest version 2024-03-04 15:08:35 +01:00
user_second_factor_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
user_security_key_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
user_spec.rb DEV: Add user modifier to prevent updating ip_address (#28280) 2024-08-08 13:06:08 -05:00
user_stat_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
user_status_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
user_summary_spec.rb PERF: Improve performance of most_replied_to_users (#26373) 2024-04-03 14:20:54 -06:00
user_visit_spec.rb DEV: Allow fab! without block (#24314) 2023-11-09 16:47:59 -06:00
username_validator_spec.rb DEV: Correctly pluralize error messages (#26469) 2024-04-04 15:02:09 +02:00
watched_word_group_spec.rb SECURITY: limit the number of characters in watched word replacements. 2024-07-15 19:25:17 +08:00
watched_word_spec.rb SECURITY: limit the number of characters in watched word replacements. 2024-07-15 19:25:17 +08:00
web_crawler_request_spec.rb DEV: stop leaking data into tables during test (#21403) 2023-05-06 07:15:33 +10:00
web_hook_event_spec.rb DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
web_hook_event_type_spec.rb DEV: Update webhook site setting for topic voting (#27935) 2024-07-17 20:26:48 +08:00
web_hook_events_daily_aggregate_spec.rb FIX: Division by zero error on WebHookEventsDailyAggregate (#27667) 2024-07-01 15:40:52 -03:00
web_hook_spec.rb DEV: Update webhook site setting for topic voting (#27935) 2024-07-17 20:26:48 +08:00