A platform for community discussion. Free, open, simple.
FIX: drop fragment cache for flags (#28001)
Krzysztof Kotlarekf41716d532aa
diff --git a/app/models/post_action_type.rb b/app/models/post_action_type.rbindex 6eeeea19861..8ade7c2977b 100644--- a/app/models/post_action_type.rb+++ b/app/models/post_action_type.rb@@ -1,16 +1,8 @@# frozen_string_literal: trueclass PostActionType < ActiveRecord::Base- after_save :expire_cache- after_destroy :expire_cache-include AnonCacheInvalidator- def expire_cache- ApplicationSerializer.expire_cache_fragment!(/\Apost_action_types_/)- ApplicationSerializer.expire_cache_fragment!(/\Apost_action_flag_types_/)- end-class << selfattr_reader :flag_settings@@ -35,7 +27,6 @@ class PostActionType < ActiveRecord::Base@all_flags = nil@flag_settings = FlagSettings.newReviewableScore.reload_types- PostActionType.new.expire_cacheenddef overridden_by_plugin_or_skipped_db?diff --git a/app/serializers/site_serializer.rb b/app/serializers/site_serializer.rbindex c25a51e794d..7b741a2b299 100644--- a/app/serializers/site_serializer.rb+++ b/app/serializers/site_serializer.rb@@ -111,17 +111,13 @@ class SiteSerializer < ApplicationSerializerenddef post_action_types- cache_fragment("post_action_types_#{I18n.locale}") do- types = ordered_flags(PostActionType.types.values)- ActiveModel::ArraySerializer.new(types).as_json- end+ types = ordered_flags(PostActionType.types.values)+ ActiveModel::ArraySerializer.new(types).as_jsonenddef topic_flag_types- cache_fragment("post_action_flag_types_#{I18n.locale}") do- types = ordered_flags(PostActionType.topic_flag_types.values)- ActiveModel::ArraySerializer.new(types, each_serializer: TopicFlagTypeSerializer).as_json- end+ types = ordered_flags(PostActionType.topic_flag_types.values)+ ActiveModel::ArraySerializer.new(types, each_serializer: TopicFlagTypeSerializer).as_jsonenddef default_archetypediff --git a/spec/models/post_action_type_spec.rb b/spec/models/post_action_type_spec.rbindex 201a83ff503..26ecc2552d5 100644--- a/spec/models/post_action_type_spec.rb+++ b/spec/models/post_action_type_spec.rb@@ -1,24 +1,6 @@# frozen_string_literal: trueRSpec.describe PostActionType do- describe "Callbacks" do- describe "#expiry_cache" do- it "should clear the cache on save" do- cache = ApplicationSerializer.fragment_cache-- cache["post_action_types_#{I18n.locale}"] = "test"- cache["post_action_flag_types_#{I18n.locale}"] = "test2"-- PostActionType.new(name_key: "some_key").save!-- expect(cache["post_action_types_#{I18n.locale}"]).to eq(nil)- expect(cache["post_action_flag_types_#{I18n.locale}"]).to eq(nil)- ensure- ApplicationSerializer.fragment_cache.clear- end- end- end-describe "#types" docontext "when verifying enum sequence" dobefore { @types = PostActionType.types }